Browse Source

Remove item count requirement

Sven Slootweg 1 month ago
parent
commit
426b578acc
3 changed files with 7 additions and 5 deletions
  1. 6 1
      example.js
  2. 1 3
      index.js
  3. 0 1
      package.json

+ 6 - 1
example.js

@ -19,7 +19,12 @@ let arrayB = [
19 19
	{ prop: 4 }
20 20
];
21 21
22
console.log(mergeArray([ arrayA, arrayB ])); // [ { prop: 4 }, { prop: 6 } ]
22
let arrayC = [
23
	{ prop: 5 },
24
	{ prop: 6 }
25
];
26
27
console.log(mergeArray([ arrayA, arrayB, arrayC ])); // [ { prop: 9 }, { prop: 12 } ]
23 28
24 29
// TODO: Document merge functions, also for arrays
25 30

+ 1 - 3
index.js

@ -8,7 +8,6 @@ const { validateArguments, validateValue } = require("@validatem/core");
8 8
const isArray = require("@validatem/is-array");
9 9
const isPlainObject = require("@validatem/is-plain-object");
10 10
const defaultTo = require("@validatem/default-to");
11
const hasLengthOf = require("@validatem/has-length-of");
12 11
const removeNullishItems = require("@validatem/remove-nullish-items");
13 12
const virtualProperty = require("@validatem/virtual-property");
14 13
const wrapPath = require("@validatem/wrap-path");
@ -105,8 +104,7 @@ module.exports = {
105 104
			let [ items ] = validateArguments(arguments, [
106 105
				[ "items", [
107 106
					isArray,
108
					removeNullishItems,
109
					hasLengthOf(2)
107
					removeNullishItems
110 108
				]]
111 109
			]);
112 110

+ 0 - 1
package.json

@ -12,7 +12,6 @@
12 12
  "dependencies": {
13 13
    "@validatem/core": "^0.3.3",
14 14
    "@validatem/default-to": "^0.1.0",
15
    "@validatem/has-length-of": "^0.1.0",
16 15
    "@validatem/is-array": "^0.1.1",
17 16
    "@validatem/is-plain-object": "^0.1.1",
18 17
    "@validatem/remove-nullish-items": "^0.1.0",