提交
This commit is contained in:
@@ -0,0 +1,127 @@
|
||||
module.exports = (function() {
|
||||
var __MODS__ = {};
|
||||
var __DEFINE__ = function(modId, func, req) { var m = { exports: {}, _tempexports: {} }; __MODS__[modId] = { status: 0, func: func, req: req, m: m }; };
|
||||
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; };
|
||||
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; } };
|
||||
var __REQUIRE_DEFAULT__ = function(obj) { return obj && obj.__esModule ? obj.default : obj; };
|
||||
__DEFINE__(1745998156290, function(require, module, exports) {
|
||||
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "OptionValidator", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _validator.OptionValidator;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "findSuggestion", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _findSuggestion.findSuggestion;
|
||||
}
|
||||
});
|
||||
var _validator = require("./validator.js");
|
||||
var _findSuggestion = require("./find-suggestion.js");
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
|
||||
}, function(modId) {var map = {"./validator.js":1745998156291,"./find-suggestion.js":1745998156292}; return __REQUIRE__(map[modId], modId); })
|
||||
__DEFINE__(1745998156291, function(require, module, exports) {
|
||||
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.OptionValidator = void 0;
|
||||
var _findSuggestion = require("./find-suggestion.js");
|
||||
class OptionValidator {
|
||||
constructor(descriptor) {
|
||||
this.descriptor = descriptor;
|
||||
}
|
||||
validateTopLevelOptions(options, TopLevelOptionShape) {
|
||||
const validOptionNames = Object.keys(TopLevelOptionShape);
|
||||
for (const option of Object.keys(options)) {
|
||||
if (!validOptionNames.includes(option)) {
|
||||
throw new Error(this.formatMessage(`'${option}' is not a valid top-level option.
|
||||
- Did you mean '${(0, _findSuggestion.findSuggestion)(option, validOptionNames)}'?`));
|
||||
}
|
||||
}
|
||||
}
|
||||
validateBooleanOption(name, value, defaultValue) {
|
||||
if (value === undefined) {
|
||||
return defaultValue;
|
||||
} else {
|
||||
this.invariant(typeof value === "boolean", `'${name}' option must be a boolean.`);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
validateStringOption(name, value, defaultValue) {
|
||||
if (value === undefined) {
|
||||
return defaultValue;
|
||||
} else {
|
||||
this.invariant(typeof value === "string", `'${name}' option must be a string.`);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
invariant(condition, message) {
|
||||
if (!condition) {
|
||||
throw new Error(this.formatMessage(message));
|
||||
}
|
||||
}
|
||||
formatMessage(message) {
|
||||
return `${this.descriptor}: ${message}`;
|
||||
}
|
||||
}
|
||||
exports.OptionValidator = OptionValidator;
|
||||
|
||||
//# sourceMappingURL=validator.js.map
|
||||
|
||||
}, function(modId) { var map = {"./find-suggestion.js":1745998156292}; return __REQUIRE__(map[modId], modId); })
|
||||
__DEFINE__(1745998156292, function(require, module, exports) {
|
||||
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.findSuggestion = findSuggestion;
|
||||
const {
|
||||
min
|
||||
} = Math;
|
||||
function levenshtein(a, b) {
|
||||
let t = [],
|
||||
u = [],
|
||||
i,
|
||||
j;
|
||||
const m = a.length,
|
||||
n = b.length;
|
||||
if (!m) {
|
||||
return n;
|
||||
}
|
||||
if (!n) {
|
||||
return m;
|
||||
}
|
||||
for (j = 0; j <= n; j++) {
|
||||
t[j] = j;
|
||||
}
|
||||
for (i = 1; i <= m; i++) {
|
||||
for (u = [i], j = 1; j <= n; j++) {
|
||||
u[j] = a[i - 1] === b[j - 1] ? t[j - 1] : min(t[j - 1], t[j], u[j - 1]) + 1;
|
||||
}
|
||||
t = u;
|
||||
}
|
||||
return u[n];
|
||||
}
|
||||
function findSuggestion(str, arr) {
|
||||
const distances = arr.map(el => levenshtein(el, str));
|
||||
return arr[distances.indexOf(min(...distances))];
|
||||
}
|
||||
|
||||
//# sourceMappingURL=find-suggestion.js.map
|
||||
|
||||
}, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); })
|
||||
return __REQUIRE__(1745998156290);
|
||||
})()
|
||||
//miniprogram-npm-outsideDeps=[]
|
||||
//# sourceMappingURL=index.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["index.js","validator.js","find-suggestion.js"],"names":[],"mappings":";;;;;;;AAAA;AACA;AACA;AACA,ACHA;ADIA,ACHA;ADIA,ACHA;ACFA,AFMA,ACHA;ACFA,AFMA,ACHA;ACFA,AFMA,ACHA;ACFA,AFMA,ACHA;ACFA,AFMA,ACHA;ACFA,AFMA,ACHA;ACFA,AFMA,ACHA;ACFA,AFMA,ACHA;ACFA,AFMA,ACHA;ACFA,AFMA,ACHA;ACFA,AFMA,ACHA;ACFA,AFMA,ACHA;ACFA,AFMA,ACHA;ACFA,AFMA,ACHA;ACFA,AFMA,ACHA;ACFA,AFMA,ACHA;ACFA,ADGA;ACFA,ADGA;ACFA,ADGA;ACFA,ADGA;ACFA,ADGA;ACFA,ADGA;ACFA,ADGA;ACFA,ADGA;ACFA,ADGA;ACFA,ADGA;ACFA,ADGA;ACFA,ADGA;ACFA,ADGA;ACFA,ADGA;ACFA,ADGA;ACFA,ADGA;ACFA,ADGA;ACFA,ADGA;ACFA,ADGA;ACFA,ADGA;ACFA,ADGA;ACFA,ADGA;ACFA,ADGA;ACFA,ADGA;AACA;AACA;AACA;AACA;AACA;AACA","file":"index.js","sourcesContent":["\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nObject.defineProperty(exports, \"OptionValidator\", {\n enumerable: true,\n get: function () {\n return _validator.OptionValidator;\n }\n});\nObject.defineProperty(exports, \"findSuggestion\", {\n enumerable: true,\n get: function () {\n return _findSuggestion.findSuggestion;\n }\n});\nvar _validator = require(\"./validator.js\");\nvar _findSuggestion = require(\"./find-suggestion.js\");\n\n//# sourceMappingURL=index.js.map\n","\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.OptionValidator = void 0;\nvar _findSuggestion = require(\"./find-suggestion.js\");\nclass OptionValidator {\n constructor(descriptor) {\n this.descriptor = descriptor;\n }\n validateTopLevelOptions(options, TopLevelOptionShape) {\n const validOptionNames = Object.keys(TopLevelOptionShape);\n for (const option of Object.keys(options)) {\n if (!validOptionNames.includes(option)) {\n throw new Error(this.formatMessage(`'${option}' is not a valid top-level option.\n- Did you mean '${(0, _findSuggestion.findSuggestion)(option, validOptionNames)}'?`));\n }\n }\n }\n validateBooleanOption(name, value, defaultValue) {\n if (value === undefined) {\n return defaultValue;\n } else {\n this.invariant(typeof value === \"boolean\", `'${name}' option must be a boolean.`);\n }\n return value;\n }\n validateStringOption(name, value, defaultValue) {\n if (value === undefined) {\n return defaultValue;\n } else {\n this.invariant(typeof value === \"string\", `'${name}' option must be a string.`);\n }\n return value;\n }\n invariant(condition, message) {\n if (!condition) {\n throw new Error(this.formatMessage(message));\n }\n }\n formatMessage(message) {\n return `${this.descriptor}: ${message}`;\n }\n}\nexports.OptionValidator = OptionValidator;\n\n//# sourceMappingURL=validator.js.map\n","\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.findSuggestion = findSuggestion;\nconst {\n min\n} = Math;\nfunction levenshtein(a, b) {\n let t = [],\n u = [],\n i,\n j;\n const m = a.length,\n n = b.length;\n if (!m) {\n return n;\n }\n if (!n) {\n return m;\n }\n for (j = 0; j <= n; j++) {\n t[j] = j;\n }\n for (i = 1; i <= m; i++) {\n for (u = [i], j = 1; j <= n; j++) {\n u[j] = a[i - 1] === b[j - 1] ? t[j - 1] : min(t[j - 1], t[j], u[j - 1]) + 1;\n }\n t = u;\n }\n return u[n];\n}\nfunction findSuggestion(str, arr) {\n const distances = arr.map(el => levenshtein(el, str));\n return arr[distances.indexOf(min(...distances))];\n}\n\n//# sourceMappingURL=find-suggestion.js.map\n"]}
|
||||
Reference in New Issue
Block a user