@babel/helper-validator-option
Advanced tools
Comparing version 7.18.6 to 7.21.0
@@ -10,23 +10,18 @@ "use strict"; | ||
} = Math; | ||
function levenshtein(a, b) { | ||
let t = [], | ||
u = [], | ||
i, | ||
j; | ||
u = [], | ||
i, | ||
j; | ||
const m = a.length, | ||
n = b.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++) { | ||
@@ -36,12 +31,11 @@ for (u = [i], j = 1; j <= n; j++) { | ||
} | ||
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 |
@@ -18,5 +18,5 @@ "use strict"; | ||
}); | ||
var _validator = require("./validator"); | ||
var _findSuggestion = require("./find-suggestion"); | ||
var _findSuggestion = require("./find-suggestion"); | ||
//# sourceMappingURL=index.js.map |
@@ -7,5 +7,3 @@ "use strict"; | ||
exports.OptionValidator = void 0; | ||
var _findSuggestion = require("./find-suggestion"); | ||
class OptionValidator { | ||
@@ -15,6 +13,4 @@ constructor(descriptor) { | ||
} | ||
validateTopLevelOptions(options, TopLevelOptionShape) { | ||
const validOptionNames = Object.keys(TopLevelOptionShape); | ||
for (const option of Object.keys(options)) { | ||
@@ -27,3 +23,2 @@ if (!validOptionNames.includes(option)) { | ||
} | ||
validateBooleanOption(name, value, defaultValue) { | ||
@@ -35,6 +30,4 @@ if (value === undefined) { | ||
} | ||
return value; | ||
} | ||
validateStringOption(name, value, defaultValue) { | ||
@@ -46,6 +39,4 @@ if (value === undefined) { | ||
} | ||
return value; | ||
} | ||
invariant(condition, message) { | ||
@@ -56,9 +47,8 @@ if (!condition) { | ||
} | ||
formatMessage(message) { | ||
return `${this.descriptor}: ${message}`; | ||
} | ||
} | ||
exports.OptionValidator = OptionValidator; | ||
exports.OptionValidator = OptionValidator; | ||
//# sourceMappingURL=validator.js.map |
{ | ||
"name": "@babel/helper-validator-option", | ||
"version": "7.18.6", | ||
"version": "7.21.0", | ||
"description": "Validate plugin/preset options", | ||
@@ -5,0 +5,0 @@ "repository": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11444
9
102