diff --git a/index.js b/index.js index 15a12d0..e644f33 100644 --- a/index.js +++ b/index.js @@ -3,7 +3,6 @@ const assureArray = require("assure-array"); const isPlainObj = require("is-plain-obj"); const defaultValue = require("default-value"); -const flatten = require("flatten"); const matchSpecial = require("@validatem/match-special"); const isPlainObjectValidator = require("@validatem/is-plain-object"); @@ -14,8 +13,7 @@ const hasShape = require("@validatem/has-shape"); module.exports = function normalizeRules(rules, options) { let normalizeObjects = defaultValue(options.normalizeObjects, false); - // TODO: Switch to `Array#flat` once Node 10.x goes EOL (April 2021) - let flattened = flatten(assureArray(rules)); + let flattened = assureArray(rules).flat(); let actualRules = flattened.filter((rule) => rule != null); if (normalizeObjects) { @@ -34,7 +32,7 @@ module.exports = function normalizeRules(rules, options) { } }); - return flatten(mapped); + return mapped.flat(); } else { return actualRules; } diff --git a/package.json b/package.json index fb13525..d8405f6 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,6 @@ "@validatem/match-special": "^0.1.0", "assure-array": "^1.0.0", "default-value": "^1.0.0", - "flatten": "^1.0.3", "is-plain-obj": "^2.1.0" }, "devDependencies": { diff --git a/yarn.lock b/yarn.lock index fde5c11..4cebdec 100644 --- a/yarn.lock +++ b/yarn.lock @@ -513,11 +513,6 @@ flatted@^2.0.0: resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.2.tgz#4575b21e2bcee7434aa9be662f4b7b5f9c2b5138" integrity sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA== -flatten@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/flatten/-/flatten-1.0.3.tgz#c1283ac9f27b368abc1e36d1ff7b04501a30356b" - integrity sha512-dVsPA/UwQ8+2uoFe5GHtiBMu48dWLTdsuEd7CKGlZlD78r1TTWBvDuFaFGKCo/ZfEr95Uk56vZoX86OsHkUeIg== - fs.realpath@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"