change flatten to Array#flat (Node 10.x EOL)

master
f0x 2 years ago
parent 97c30be23d
commit 568337e565

@ -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;
}

@ -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": {

@ -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"

Loading…
Cancel
Save