Replace flatten implementation to reduce bundle size

pull/4/head
Sven Slootweg 5 years ago
parent aa644fa3f5
commit a1fd0b7adf

@ -1,7 +1,12 @@
{ {
"name": "@validatem/core", "name": "@validatem/core",
"description": "The last validation library you'll ever need.", "description": "The last validation library you'll ever need.",
"keywords": ["validation", "input", "verification", "data"], "keywords": [
"validation",
"input",
"verification",
"data"
],
"version": "0.3.0", "version": "0.3.0",
"main": "index.js", "main": "index.js",
"repository": "http://git.cryto.net/validatem/core.git", "repository": "http://git.cryto.net/validatem/core.git",
@ -18,10 +23,10 @@
"@validatem/normalize-rules": "^0.1.0", "@validatem/normalize-rules": "^0.1.0",
"@validatem/required": "^0.1.0", "@validatem/required": "^0.1.0",
"@validatem/validation-result": "^0.1.1", "@validatem/validation-result": "^0.1.1",
"array.prototype.flat": "^1.2.3",
"assure-array": "^1.0.0", "assure-array": "^1.0.0",
"create-error": "^0.3.1", "create-error": "^0.3.1",
"default-value": "^1.0.0", "default-value": "^1.0.0",
"flatten": "^1.0.3",
"is-arguments": "^1.0.4" "is-arguments": "^1.0.4"
}, },
"devDependencies": { "devDependencies": {

@ -1,7 +1,7 @@
"use strict"; "use strict";
const isArguments = require("is-arguments"); const isArguments = require("is-arguments");
const flat = require("array.prototype.flat"); const flatten = require("flatten");
const ValidationError = require("@validatem/error"); const ValidationError = require("@validatem/error");
const annotateErrors = require("@validatem/annotate-errors"); const annotateErrors = require("@validatem/annotate-errors");
@ -46,7 +46,7 @@ module.exports = createValidationMethod((args, argumentDefinitions) => {
}); });
let combinedErrors = results.map((result) => result.errors); let combinedErrors = results.map((result) => result.errors);
let flattenedErrors = flat(combinedErrors); let flattenedErrors = flatten(combinedErrors); // TODO: Switch to `Array#flat` once Node 10.x goes EOL (April 2021)
let newValues = results.map((result) => result.newValue); let newValues = results.map((result) => result.newValue);

@ -604,6 +604,11 @@ flatted@^2.0.0:
resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.2.tgz#4575b21e2bcee7434aa9be662f4b7b5f9c2b5138" resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.2.tgz#4575b21e2bcee7434aa9be662f4b7b5f9c2b5138"
integrity sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA== 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: fs.realpath@^1.0.0:
version "1.0.0" version "1.0.0"
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"

Loading…
Cancel
Save