index.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. module.exports = (function() {
  2. var __MODS__ = {};
  3. var __DEFINE__ = function(modId, func, req) { var m = { exports: {}, _tempexports: {} }; __MODS__[modId] = { status: 0, func: func, req: req, m: m }; };
  4. var __REQUIRE__ = function(modId, source) { if(!__MODS__[modId]) return require(source); if(!__MODS__[modId].status) { var m = __MODS__[modId].m; m._exports = m._tempexports; var desp = Object.getOwnPropertyDescriptor(m, "exports"); if (desp && desp.configurable) Object.defineProperty(m, "exports", { set: function (val) { if(typeof val === "object" && val !== m._exports) { m._exports.__proto__ = val.__proto__; Object.keys(val).forEach(function (k) { m._exports[k] = val[k]; }); } m._tempexports = val }, get: function () { return m._tempexports; } }); __MODS__[modId].status = 1; __MODS__[modId].func(__MODS__[modId].req, m, m.exports); } return __MODS__[modId].m.exports; };
  5. var __REQUIRE_WILDCARD__ = function(obj) { if(obj && obj.__esModule) { return obj; } else { var newObj = {}; if(obj != null) { for(var k in obj) { if (Object.prototype.hasOwnProperty.call(obj, k)) newObj[k] = obj[k]; } } newObj.default = obj; return newObj; } };
  6. var __REQUIRE_DEFAULT__ = function(obj) { return obj && obj.__esModule ? obj.default : obj; };
  7. __DEFINE__(1682324647445, function(require, module, exports) {
  8. module.exports = codegen;
  9. /**
  10. * Begins generating a function.
  11. * @memberof util
  12. * @param {string[]} functionParams Function parameter names
  13. * @param {string} [functionName] Function name if not anonymous
  14. * @returns {Codegen} Appender that appends code to the function's body
  15. */
  16. function codegen(functionParams, functionName) {
  17. /* istanbul ignore if */
  18. if (typeof functionParams === "string") {
  19. functionName = functionParams;
  20. functionParams = undefined;
  21. }
  22. var body = [];
  23. /**
  24. * Appends code to the function's body or finishes generation.
  25. * @typedef Codegen
  26. * @type {function}
  27. * @param {string|Object.<string,*>} [formatStringOrScope] Format string or, to finish the function, an object of additional scope variables, if any
  28. * @param {...*} [formatParams] Format parameters
  29. * @returns {Codegen|Function} Itself or the generated function if finished
  30. * @throws {Error} If format parameter counts do not match
  31. */
  32. function Codegen(formatStringOrScope) {
  33. // note that explicit array handling below makes this ~50% faster
  34. // finish the function
  35. if (typeof formatStringOrScope !== "string") {
  36. var source = toString();
  37. if (codegen.verbose)
  38. console.log("codegen: " + source); // eslint-disable-line no-console
  39. source = "return " + source;
  40. if (formatStringOrScope) {
  41. var scopeKeys = Object.keys(formatStringOrScope),
  42. scopeParams = new Array(scopeKeys.length + 1),
  43. scopeValues = new Array(scopeKeys.length),
  44. scopeOffset = 0;
  45. while (scopeOffset < scopeKeys.length) {
  46. scopeParams[scopeOffset] = scopeKeys[scopeOffset];
  47. scopeValues[scopeOffset] = formatStringOrScope[scopeKeys[scopeOffset++]];
  48. }
  49. scopeParams[scopeOffset] = source;
  50. return Function.apply(null, scopeParams).apply(null, scopeValues); // eslint-disable-line no-new-func
  51. }
  52. return Function(source)(); // eslint-disable-line no-new-func
  53. }
  54. // otherwise append to body
  55. var formatParams = new Array(arguments.length - 1),
  56. formatOffset = 0;
  57. while (formatOffset < formatParams.length)
  58. formatParams[formatOffset] = arguments[++formatOffset];
  59. formatOffset = 0;
  60. formatStringOrScope = formatStringOrScope.replace(/%([%dfijs])/g, function replace($0, $1) {
  61. var value = formatParams[formatOffset++];
  62. switch ($1) {
  63. case "d": case "f": return String(Number(value));
  64. case "i": return String(Math.floor(value));
  65. case "j": return JSON.stringify(value);
  66. case "s": return String(value);
  67. }
  68. return "%";
  69. });
  70. if (formatOffset !== formatParams.length)
  71. throw Error("parameter count mismatch");
  72. body.push(formatStringOrScope);
  73. return Codegen;
  74. }
  75. function toString(functionNameOverride) {
  76. return "function " + (functionNameOverride || functionName || "") + "(" + (functionParams && functionParams.join(",") || "") + "){\n " + body.join("\n ") + "\n}";
  77. }
  78. Codegen.toString = toString;
  79. return Codegen;
  80. }
  81. /**
  82. * Begins generating a function.
  83. * @memberof util
  84. * @function codegen
  85. * @param {string} [functionName] Function name if not anonymous
  86. * @returns {Codegen} Appender that appends code to the function's body
  87. * @variation 2
  88. */
  89. /**
  90. * When set to `true`, codegen will log generated code to console. Useful for debugging.
  91. * @name util.codegen.verbose
  92. * @type {boolean}
  93. */
  94. codegen.verbose = false;
  95. }, function(modId) {var map = {}; return __REQUIRE__(map[modId], modId); })
  96. return __REQUIRE__(1682324647445);
  97. })()
  98. //miniprogram-npm-outsideDeps=[]
  99. //# sourceMappingURL=index.js.map