MCPcopy
hub / github.com/riot/riot / requireShared

Function requireShared

riot+compiler.js:2701–2793  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2699 var hasRequiredShared;
2700
2701 function requireShared () {
2702 if (hasRequiredShared) return shared;
2703 hasRequiredShared = 1;
2704 Object.defineProperty(shared, "__esModule", { value: true });
2705 shared.maybeSetModuleExports = void 0;
2706 var tslib_1 = require$$0;
2707 var types_1 = tslib_1.__importDefault(requireTypes());
2708 function default_1(fork) {
2709 var types = fork.use(types_1.default);
2710 var Type = types.Type;
2711 var builtin = types.builtInTypes;
2712 var isNumber = builtin.number;
2713 // An example of constructing a new type with arbitrary constraints from
2714 // an existing type.
2715 function geq(than) {
2716 return Type.from(function (value) { return isNumber.check(value) && value >= than; }, isNumber + " >= " + than);
2717 }
2718 // Default value-returning functions that may optionally be passed as a
2719 // third argument to Def.prototype.field.
2720 var defaults = {
2721 // Functions were used because (among other reasons) that's the most
2722 // elegant way to allow for the emptyArray one always to give a new
2723 // array instance.
2724 "null": function () { return null; },
2725 "emptyArray": function () { return []; },
2726 "false": function () { return false; },
2727 "true": function () { return true; },
2728 "undefined": function () { },
2729 "use strict": function () { return "use strict"; }
2730 };
2731 var naiveIsPrimitive = Type.or(builtin.string, builtin.number, builtin.boolean, builtin.null, builtin.undefined);
2732 var isPrimitive = Type.from(function (value) {
2733 if (value === null)
2734 return true;
2735 var type = typeof value;
2736 if (type === "object" ||
2737 type === "function") {
2738 return false;
2739 }
2740 return true;
2741 }, naiveIsPrimitive.toString());
2742 return {
2743 geq: geq,
2744 defaults: defaults,
2745 isPrimitive: isPrimitive,
2746 };
2747 }
2748 shared.default = default_1;
2749 // This function accepts a getter function that should return an object
2750 // conforming to the NodeModule interface above. Typically, this means calling
2751 // maybeSetModuleExports(() => module) at the very end of any module that has a
2752 // default export, so the default export value can replace module.exports and
2753 // thus CommonJS consumers can continue to rely on require("./that/module")
2754 // returning the default-exported value, rather than always returning an exports
2755 // object with a default property equal to that value. This function should help
2756 // preserve backwards compatibility for CommonJS consumers, as a replacement for
2757 // the ts-add-module-exports package.
2758 function maybeSetModuleExports(moduleGetter) {

Callers 15

requireTypesFunction · 0.85
requirePathFunction · 0.85
requireScopeFunction · 0.85
requireNodePathFunction · 0.85
requirePathVisitorFunction · 0.85
requireEquivFunction · 0.85
requireForkFunction · 0.85
requireCore$1Function · 0.85
requireEs2016$1Function · 0.85
requireEs2020$1Function · 0.85
requireEs2021$1Function · 0.85
requireCoreFunction · 0.85

Calls 1

requireTypesFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…