@oscarpalmer/atoms 0.101.0 → 0.103.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/array/count.cjs +11 -23
- package/dist/array/count.js +11 -19
- package/dist/array/exists.cjs +3 -11
- package/dist/array/exists.js +3 -7
- package/dist/array/filter.cjs +2 -8
- package/dist/array/filter.js +2 -4
- package/dist/array/find.cjs +2 -8
- package/dist/array/find.js +2 -4
- package/dist/array/flatten.cjs +4 -6
- package/dist/array/flatten.js +4 -2
- package/dist/array/get.cjs +17 -0
- package/dist/array/get.js +17 -0
- package/dist/array/group-by.cjs +2 -13
- package/dist/array/group-by.js +2 -9
- package/dist/array/index-of.cjs +2 -8
- package/dist/array/index-of.js +2 -4
- package/dist/array/index.cjs +36 -41
- package/dist/array/index.js +19 -17
- package/dist/array/insert.cjs +2 -14
- package/dist/array/insert.js +2 -10
- package/dist/array/models.cjs +0 -2
- package/dist/array/models.js +0 -1
- package/dist/array/push.cjs +7 -8
- package/dist/array/push.js +7 -4
- package/dist/array/sort.cjs +43 -62
- package/dist/array/sort.js +43 -58
- package/dist/array/splice.cjs +2 -14
- package/dist/array/splice.js +2 -10
- package/dist/array/to-map.cjs +17 -30
- package/dist/array/to-map.js +17 -26
- package/dist/array/to-record.cjs +2 -13
- package/dist/array/to-record.js +2 -9
- package/dist/array/unique.cjs +3 -11
- package/dist/array/unique.js +3 -7
- package/dist/color/constants.cjs +15 -16
- package/dist/color/constants.js +15 -12
- package/dist/color/get.cjs +44 -47
- package/dist/color/get.js +44 -43
- package/dist/color/index.cjs +90 -83
- package/dist/color/index.js +87 -75
- package/dist/color/is.cjs +39 -36
- package/dist/color/is.js +39 -32
- package/dist/color/misc.cjs +8 -13
- package/dist/color/misc.js +8 -9
- package/dist/color/models.cjs +0 -2
- package/dist/color/models.js +0 -1
- package/dist/color/value.cjs +76 -76
- package/dist/color/value.js +76 -72
- package/dist/emitter.cjs +142 -162
- package/dist/emitter.js +142 -158
- package/dist/function.cjs +119 -123
- package/dist/function.js +119 -120
- package/dist/index.cjs +139 -144
- package/dist/index.js +52 -48
- package/dist/internal/array/callbacks.cjs +10 -19
- package/dist/internal/array/callbacks.js +10 -15
- package/dist/internal/array/chunk.cjs +15 -23
- package/dist/internal/array/chunk.js +15 -19
- package/dist/internal/array/compact.cjs +9 -18
- package/dist/internal/array/compact.js +9 -14
- package/dist/internal/array/find.cjs +41 -63
- package/dist/internal/array/find.js +41 -59
- package/dist/internal/array/group.cjs +16 -29
- package/dist/internal/array/group.js +16 -25
- package/dist/internal/array/insert.cjs +14 -30
- package/dist/internal/array/insert.js +14 -26
- package/dist/internal/array/shuffle.cjs +13 -20
- package/dist/internal/array/shuffle.js +13 -16
- package/dist/internal/function.cjs +28 -26
- package/dist/internal/function.js +21 -21
- package/dist/internal/is.cjs +35 -29
- package/dist/internal/is.js +35 -25
- package/dist/internal/math/aggregate.cjs +29 -36
- package/dist/internal/math/aggregate.js +29 -32
- package/dist/internal/number.cjs +34 -53
- package/dist/internal/number.js +34 -49
- package/dist/internal/random.cjs +13 -17
- package/dist/internal/random.js +13 -13
- package/dist/internal/string.cjs +25 -28
- package/dist/internal/string.js +25 -24
- package/dist/internal/value/compare.cjs +41 -69
- package/dist/internal/value/compare.js +41 -65
- package/dist/internal/value/equal.cjs +76 -154
- package/dist/internal/value/equal.js +76 -150
- package/dist/internal/value/get.cjs +10 -28
- package/dist/internal/value/get.js +10 -24
- package/dist/internal/value/misc.cjs +13 -23
- package/dist/internal/value/misc.js +13 -19
- package/dist/internal/value/set.cjs +29 -39
- package/dist/internal/value/set.js +29 -35
- package/dist/is.cjs +38 -27
- package/dist/is.js +34 -20
- package/dist/logger.cjs +97 -107
- package/dist/logger.js +97 -103
- package/dist/math.cjs +13 -20
- package/dist/math.js +13 -17
- package/dist/models.cjs +0 -2
- package/dist/models.js +0 -1
- package/dist/number.cjs +4 -11
- package/dist/number.js +2 -1
- package/dist/query.cjs +53 -71
- package/dist/query.js +53 -67
- package/dist/random.cjs +37 -33
- package/dist/random.js +36 -29
- package/dist/sized.cjs +93 -111
- package/dist/sized.js +93 -107
- package/dist/string/case.cjs +49 -51
- package/dist/string/case.js +49 -47
- package/dist/string/index.cjs +17 -24
- package/dist/string/index.js +5 -4
- package/dist/string/misc.cjs +26 -24
- package/dist/string/misc.js +26 -20
- package/dist/string/template.cjs +17 -26
- package/dist/string/template.js +17 -22
- package/dist/touch.cjs +18 -27
- package/dist/touch.js +18 -25
- package/dist/value/clone.cjs +75 -123
- package/dist/value/clone.js +75 -119
- package/dist/value/diff.cjs +83 -94
- package/dist/value/diff.js +83 -90
- package/dist/value/index.cjs +20 -27
- package/dist/value/index.js +11 -10
- package/dist/value/merge.cjs +33 -53
- package/dist/value/merge.js +33 -49
- package/dist/value/partial.cjs +11 -15
- package/dist/value/partial.js +11 -11
- package/dist/value/smush.cjs +22 -32
- package/dist/value/smush.js +22 -28
- package/dist/value/unsmush.cjs +26 -35
- package/dist/value/unsmush.js +26 -31
- package/package.json +4 -14
- package/src/array/flatten.ts +3 -3
- package/src/array/get.ts +62 -0
- package/src/array/index.ts +1 -0
- package/src/array/models.ts +13 -0
- package/src/array/sort.ts +1 -1
- package/src/color/index.ts +11 -3
- package/src/color/is.ts +2 -0
- package/src/function.ts +1 -0
- package/src/index.ts +0 -1
- package/src/internal/function.ts +2 -0
- package/src/internal/is.ts +2 -0
- package/src/internal/string.ts +2 -0
- package/src/internal/value/compare.ts +2 -0
- package/src/internal/value/set.ts +2 -0
- package/src/is.ts +7 -0
- package/src/logger.ts +1 -1
- package/src/math.ts +1 -1
- package/src/models.ts +2 -2
- package/src/query.ts +6 -0
- package/src/random.ts +0 -1
- package/src/string/case.ts +2 -0
- package/src/string/index.ts +1 -0
- package/src/string/misc.ts +2 -0
- package/src/string/template.ts +4 -2
- package/src/value/index.ts +1 -1
- package/src/value/merge.ts +1 -1
- package/types/array/flatten.d.cts +2 -2
- package/types/array/flatten.d.ts +2 -2
- package/types/array/get.d.cts +34 -0
- package/types/array/get.d.ts +22 -0
- package/types/array/index.d.cts +56 -30
- package/types/array/index.d.ts +1 -0
- package/types/array/models.d.cts +16 -0
- package/types/array/models.d.ts +7 -0
- package/types/color/index.d.ts +3 -3
- package/types/function.d.cts +1 -1
- package/types/function.d.ts +1 -0
- package/types/index.d.cts +61 -66
- package/types/index.d.ts +0 -1
- package/types/is.d.ts +1 -0
- package/types/logger.d.cts +2 -2
- package/types/logger.d.ts +1 -1
- package/types/math.d.ts +1 -1
- package/types/models.d.cts +1 -1
- package/types/models.d.ts +1 -1
- package/types/query.d.ts +1 -0
- package/types/string/index.d.cts +2 -2
- package/types/string/index.d.ts +1 -0
- package/types/string/template.d.cts +2 -2
- package/types/string/template.d.ts +2 -3
- package/types/value/index.d.ts +1 -0
- package/types/value/merge.d.ts +1 -2
- package/dist/i18n.cjs +0 -146
- package/dist/i18n.js +0 -142
- package/src/i18n.ts +0 -325
- package/types/i18n.d.cts +0 -35
- package/types/i18n.d.ts +0 -32
package/dist/array/count.cjs
CHANGED
|
@@ -1,26 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
|
|
5
|
-
const internal_array_find = require('../internal/array/find.cjs');
|
|
6
|
-
|
|
1
|
+
const require_internal_array_find = require("../internal/array/find.cjs");
|
|
7
2
|
function count(array, ...parameters) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
for (let index = 0; index < length; index += 1) {
|
|
19
|
-
result += Object.is(array[index], value) ? 1 : 0;
|
|
20
|
-
}
|
|
21
|
-
return result;
|
|
22
|
-
}
|
|
23
|
-
return internal_array_find.findValues("all", array, parameters, true)?.length ?? Number.NaN;
|
|
3
|
+
if (Array.isArray(parameters) && parameters.length === 1 && typeof parameters[0] !== "function") {
|
|
4
|
+
if (!Array.isArray(array)) return NaN;
|
|
5
|
+
const { length } = array;
|
|
6
|
+
if (length === 0) return 0;
|
|
7
|
+
const value = parameters[0];
|
|
8
|
+
let result = 0;
|
|
9
|
+
for (let index = 0; index < length; index += 1) result += Object.is(array[index], value) ? 1 : 0;
|
|
10
|
+
return result;
|
|
11
|
+
}
|
|
12
|
+
return require_internal_array_find.findValues("all", array, parameters, true)?.length ?? NaN;
|
|
24
13
|
}
|
|
25
|
-
|
|
26
14
|
exports.count = count;
|
package/dist/array/count.js
CHANGED
|
@@ -1,22 +1,14 @@
|
|
|
1
|
-
import { findValues } from
|
|
2
|
-
|
|
1
|
+
import { findValues } from "../internal/array/find.js";
|
|
3
2
|
function count(array, ...parameters) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
for (let index = 0; index < length; index += 1) {
|
|
15
|
-
result += Object.is(array[index], value) ? 1 : 0;
|
|
16
|
-
}
|
|
17
|
-
return result;
|
|
18
|
-
}
|
|
19
|
-
return findValues("all", array, parameters, true)?.length ?? Number.NaN;
|
|
3
|
+
if (Array.isArray(parameters) && parameters.length === 1 && typeof parameters[0] !== "function") {
|
|
4
|
+
if (!Array.isArray(array)) return NaN;
|
|
5
|
+
const { length } = array;
|
|
6
|
+
if (length === 0) return 0;
|
|
7
|
+
const value = parameters[0];
|
|
8
|
+
let result = 0;
|
|
9
|
+
for (let index = 0; index < length; index += 1) result += Object.is(array[index], value) ? 1 : 0;
|
|
10
|
+
return result;
|
|
11
|
+
}
|
|
12
|
+
return findValues("all", array, parameters, true)?.length ?? NaN;
|
|
20
13
|
}
|
|
21
|
-
|
|
22
14
|
export { count };
|
package/dist/array/exists.cjs
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
|
|
5
|
-
const internal_array_find = require('../internal/array/find.cjs');
|
|
6
|
-
|
|
1
|
+
const require_internal_array_find = require("../internal/array/find.cjs");
|
|
7
2
|
function exists(array, ...parameters) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
return internal_array_find.findValue("index", array, parameters) > -1;
|
|
3
|
+
if (parameters.length === 1 && typeof parameters[0] !== "function") return Array.isArray(array) ? array.includes(parameters[0]) : false;
|
|
4
|
+
return require_internal_array_find.findValue("index", array, parameters) > -1;
|
|
12
5
|
}
|
|
13
|
-
|
|
14
6
|
exports.exists = exists;
|
package/dist/array/exists.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import { findValue } from
|
|
2
|
-
|
|
1
|
+
import { findValue } from "../internal/array/find.js";
|
|
3
2
|
function exists(array, ...parameters) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
return findValue("index", array, parameters) > -1;
|
|
3
|
+
if (parameters.length === 1 && typeof parameters[0] !== "function") return Array.isArray(array) ? array.includes(parameters[0]) : false;
|
|
4
|
+
return findValue("index", array, parameters) > -1;
|
|
8
5
|
}
|
|
9
|
-
|
|
10
6
|
export { exists };
|
package/dist/array/filter.cjs
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
|
|
5
|
-
const internal_array_find = require('../internal/array/find.cjs');
|
|
6
|
-
|
|
1
|
+
const require_internal_array_find = require("../internal/array/find.cjs");
|
|
7
2
|
function filter(array, ...parameters) {
|
|
8
|
-
|
|
3
|
+
return require_internal_array_find.findValues("all", array, parameters);
|
|
9
4
|
}
|
|
10
|
-
|
|
11
5
|
exports.filter = filter;
|
package/dist/array/filter.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { findValues } from
|
|
2
|
-
|
|
1
|
+
import { findValues } from "../internal/array/find.js";
|
|
3
2
|
function filter(array, ...parameters) {
|
|
4
|
-
|
|
3
|
+
return findValues("all", array, parameters);
|
|
5
4
|
}
|
|
6
|
-
|
|
7
5
|
export { filter };
|
package/dist/array/find.cjs
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
|
|
5
|
-
const internal_array_find = require('../internal/array/find.cjs');
|
|
6
|
-
|
|
1
|
+
const require_internal_array_find = require("../internal/array/find.cjs");
|
|
7
2
|
function find(array, ...parameters) {
|
|
8
|
-
|
|
3
|
+
return require_internal_array_find.findValue("value", array, parameters);
|
|
9
4
|
}
|
|
10
|
-
|
|
11
5
|
exports.find = find;
|
package/dist/array/find.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { findValue } from
|
|
2
|
-
|
|
1
|
+
import { findValue } from "../internal/array/find.js";
|
|
3
2
|
function find(array, ...parameters) {
|
|
4
|
-
|
|
3
|
+
return findValue("value", array, parameters);
|
|
5
4
|
}
|
|
6
|
-
|
|
7
5
|
export { find };
|
package/dist/array/flatten.cjs
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Flatten an array _(using native `flat` and maximum depth)_
|
|
3
|
+
*/
|
|
5
4
|
function flatten(array) {
|
|
6
|
-
|
|
5
|
+
return Array.isArray(array) ? array.flat(Number.POSITIVE_INFINITY) : [];
|
|
7
6
|
}
|
|
8
|
-
|
|
9
7
|
exports.flatten = flatten;
|
package/dist/array/flatten.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flatten an array _(using native `flat` and maximum depth)_
|
|
3
|
+
*/
|
|
1
4
|
function flatten(array) {
|
|
2
|
-
|
|
5
|
+
return Array.isArray(array) ? array.flat(Number.POSITIVE_INFINITY) : [];
|
|
3
6
|
}
|
|
4
|
-
|
|
5
7
|
export { flatten };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const require_internal_is = require("../internal/is.cjs");
|
|
2
|
+
function getArray(value, indiced) {
|
|
3
|
+
if (Array.isArray(value)) return value;
|
|
4
|
+
if (require_internal_is.isPlainObject(value)) {
|
|
5
|
+
if (indiced !== true) return Object.values(value);
|
|
6
|
+
const keys = Object.keys(value);
|
|
7
|
+
const { length } = keys;
|
|
8
|
+
const array = [];
|
|
9
|
+
for (let index = 0; index < length; index += 1) {
|
|
10
|
+
const key = keys[index];
|
|
11
|
+
if (!Number.isNaN(Number(key))) array.push(value[key]);
|
|
12
|
+
}
|
|
13
|
+
return array;
|
|
14
|
+
}
|
|
15
|
+
return [value];
|
|
16
|
+
}
|
|
17
|
+
exports.getArray = getArray;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { isPlainObject } from "../internal/is.js";
|
|
2
|
+
function getArray(value, indiced) {
|
|
3
|
+
if (Array.isArray(value)) return value;
|
|
4
|
+
if (isPlainObject(value)) {
|
|
5
|
+
if (indiced !== true) return Object.values(value);
|
|
6
|
+
const keys = Object.keys(value);
|
|
7
|
+
const { length } = keys;
|
|
8
|
+
const array = [];
|
|
9
|
+
for (let index = 0; index < length; index += 1) {
|
|
10
|
+
const key = keys[index];
|
|
11
|
+
if (!Number.isNaN(Number(key))) array.push(value[key]);
|
|
12
|
+
}
|
|
13
|
+
return array;
|
|
14
|
+
}
|
|
15
|
+
return [value];
|
|
16
|
+
}
|
|
17
|
+
export { getArray };
|
package/dist/array/group-by.cjs
CHANGED
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
|
|
5
|
-
const internal_array_group = require('../internal/array/group.cjs');
|
|
6
|
-
|
|
1
|
+
const require_internal_array_group = require("../internal/array/group.cjs");
|
|
7
2
|
function groupBy(array, key, valueOrArrays, arrays) {
|
|
8
|
-
|
|
9
|
-
array,
|
|
10
|
-
key,
|
|
11
|
-
valueOrArrays,
|
|
12
|
-
key === true || valueOrArrays === true || arrays === true
|
|
13
|
-
);
|
|
3
|
+
return require_internal_array_group.groupValues(array, key, valueOrArrays, key === true || valueOrArrays === true || arrays === true);
|
|
14
4
|
}
|
|
15
|
-
|
|
16
5
|
exports.groupBy = groupBy;
|
package/dist/array/group-by.js
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import { groupValues } from
|
|
2
|
-
|
|
1
|
+
import { groupValues } from "../internal/array/group.js";
|
|
3
2
|
function groupBy(array, key, valueOrArrays, arrays) {
|
|
4
|
-
|
|
5
|
-
array,
|
|
6
|
-
key,
|
|
7
|
-
valueOrArrays,
|
|
8
|
-
key === true || valueOrArrays === true || arrays === true
|
|
9
|
-
);
|
|
3
|
+
return groupValues(array, key, valueOrArrays, key === true || valueOrArrays === true || arrays === true);
|
|
10
4
|
}
|
|
11
|
-
|
|
12
5
|
export { groupBy };
|
package/dist/array/index-of.cjs
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
|
|
5
|
-
const internal_array_find = require('../internal/array/find.cjs');
|
|
6
|
-
|
|
1
|
+
const require_internal_array_find = require("../internal/array/find.cjs");
|
|
7
2
|
function indexOf(array, ...parameters) {
|
|
8
|
-
|
|
3
|
+
return require_internal_array_find.findValue("index", array, parameters);
|
|
9
4
|
}
|
|
10
|
-
|
|
11
5
|
exports.indexOf = indexOf;
|
package/dist/array/index-of.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { findValue } from
|
|
2
|
-
|
|
1
|
+
import { findValue } from "../internal/array/find.js";
|
|
3
2
|
function indexOf(array, ...parameters) {
|
|
4
|
-
|
|
3
|
+
return findValue("index", array, parameters);
|
|
5
4
|
}
|
|
6
|
-
|
|
7
5
|
export { indexOf };
|
package/dist/array/index.cjs
CHANGED
|
@@ -1,41 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
exports.
|
|
26
|
-
exports.
|
|
27
|
-
exports.
|
|
28
|
-
exports.
|
|
29
|
-
exports.
|
|
30
|
-
exports.
|
|
31
|
-
exports.
|
|
32
|
-
exports.
|
|
33
|
-
exports.
|
|
34
|
-
exports.
|
|
35
|
-
exports.
|
|
36
|
-
exports.
|
|
37
|
-
exports.sort = array_sort.sort;
|
|
38
|
-
exports.splice = array_splice.splice;
|
|
39
|
-
exports.toMap = array_toMap.toMap;
|
|
40
|
-
exports.toRecord = array_toRecord.toRecord;
|
|
41
|
-
exports.unique = array_unique.unique;
|
|
1
|
+
const require_internal_array_shuffle = require("../internal/array/shuffle.cjs");
|
|
2
|
+
const require_internal_array_compact = require("../internal/array/compact.cjs");
|
|
3
|
+
const require_internal_array_chunk = require("../internal/array/chunk.cjs");
|
|
4
|
+
const require_array_count = require("./count.cjs");
|
|
5
|
+
const require_array_exists = require("./exists.cjs");
|
|
6
|
+
const require_array_filter = require("./filter.cjs");
|
|
7
|
+
const require_array_find = require("./find.cjs");
|
|
8
|
+
const require_array_flatten = require("./flatten.cjs");
|
|
9
|
+
const require_array_get = require("./get.cjs");
|
|
10
|
+
const require_array_group_by = require("./group-by.cjs");
|
|
11
|
+
const require_array_index_of = require("./index-of.cjs");
|
|
12
|
+
const require_array_insert = require("./insert.cjs");
|
|
13
|
+
const require_array_push = require("./push.cjs");
|
|
14
|
+
const require_array_sort = require("./sort.cjs");
|
|
15
|
+
const require_array_splice = require("./splice.cjs");
|
|
16
|
+
const require_array_to_map = require("./to-map.cjs");
|
|
17
|
+
const require_array_to_record = require("./to-record.cjs");
|
|
18
|
+
const require_array_unique = require("./unique.cjs");
|
|
19
|
+
exports.chunk = require_internal_array_chunk.chunk;
|
|
20
|
+
exports.compact = require_internal_array_compact.compact;
|
|
21
|
+
exports.count = require_array_count.count;
|
|
22
|
+
exports.exists = require_array_exists.exists;
|
|
23
|
+
exports.filter = require_array_filter.filter;
|
|
24
|
+
exports.find = require_array_find.find;
|
|
25
|
+
exports.flatten = require_array_flatten.flatten;
|
|
26
|
+
exports.getArray = require_array_get.getArray;
|
|
27
|
+
exports.groupBy = require_array_group_by.groupBy;
|
|
28
|
+
exports.indexOf = require_array_index_of.indexOf;
|
|
29
|
+
exports.insert = require_array_insert.insert;
|
|
30
|
+
exports.push = require_array_push.push;
|
|
31
|
+
exports.shuffle = require_internal_array_shuffle.shuffle;
|
|
32
|
+
exports.sort = require_array_sort.sort;
|
|
33
|
+
exports.splice = require_array_splice.splice;
|
|
34
|
+
exports.toMap = require_array_to_map.toMap;
|
|
35
|
+
exports.toRecord = require_array_to_record.toRecord;
|
|
36
|
+
exports.unique = require_array_unique.unique;
|
package/dist/array/index.js
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
import { shuffle } from "../internal/array/shuffle.js";
|
|
2
|
+
import { compact } from "../internal/array/compact.js";
|
|
3
|
+
import { chunk } from "../internal/array/chunk.js";
|
|
4
|
+
import { count } from "./count.js";
|
|
5
|
+
import { exists } from "./exists.js";
|
|
6
|
+
import { filter } from "./filter.js";
|
|
7
|
+
import { find } from "./find.js";
|
|
8
|
+
import { flatten } from "./flatten.js";
|
|
9
|
+
import { getArray } from "./get.js";
|
|
10
|
+
import { groupBy } from "./group-by.js";
|
|
11
|
+
import { indexOf } from "./index-of.js";
|
|
12
|
+
import { insert } from "./insert.js";
|
|
13
|
+
import { push } from "./push.js";
|
|
14
|
+
import { sort } from "./sort.js";
|
|
15
|
+
import { splice } from "./splice.js";
|
|
16
|
+
import { toMap } from "./to-map.js";
|
|
17
|
+
import { toRecord } from "./to-record.js";
|
|
18
|
+
import { unique } from "./unique.js";
|
|
19
|
+
export { chunk, compact, count, exists, filter, find, flatten, getArray, groupBy, indexOf, insert, push, shuffle, sort, splice, toMap, toRecord, unique };
|
package/dist/array/insert.cjs
CHANGED
|
@@ -1,17 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
|
|
5
|
-
const internal_array_insert = require('../internal/array/insert.cjs');
|
|
6
|
-
|
|
1
|
+
const require_internal_array_insert = require("../internal/array/insert.cjs");
|
|
7
2
|
function insert(array, indexOrItems, items) {
|
|
8
|
-
|
|
9
|
-
"insert",
|
|
10
|
-
array,
|
|
11
|
-
items == null ? indexOrItems : items,
|
|
12
|
-
typeof indexOrItems === "number" ? indexOrItems : array?.length,
|
|
13
|
-
0
|
|
14
|
-
);
|
|
3
|
+
return require_internal_array_insert.insertValues("insert", array, items == null ? indexOrItems : items, typeof indexOrItems === "number" ? indexOrItems : array?.length, 0);
|
|
15
4
|
}
|
|
16
|
-
|
|
17
5
|
exports.insert = insert;
|
package/dist/array/insert.js
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
import { insertValues } from
|
|
2
|
-
|
|
1
|
+
import { insertValues } from "../internal/array/insert.js";
|
|
3
2
|
function insert(array, indexOrItems, items) {
|
|
4
|
-
|
|
5
|
-
"insert",
|
|
6
|
-
array,
|
|
7
|
-
items == null ? indexOrItems : items,
|
|
8
|
-
typeof indexOrItems === "number" ? indexOrItems : array?.length,
|
|
9
|
-
0
|
|
10
|
-
);
|
|
3
|
+
return insertValues("insert", array, items == null ? indexOrItems : items, typeof indexOrItems === "number" ? indexOrItems : array?.length, 0);
|
|
11
4
|
}
|
|
12
|
-
|
|
13
5
|
export { insert };
|
package/dist/array/models.cjs
CHANGED
package/dist/array/models.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
package/dist/array/push.cjs
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
const require_internal_array_insert = require("../internal/array/insert.cjs");
|
|
2
|
+
/**
|
|
3
|
+
* - Push values to the end of an array
|
|
4
|
+
* - Returns the new length
|
|
5
|
+
* - _(Uses chunking to avoid call stack size being exceeded)_
|
|
6
|
+
*/
|
|
7
7
|
function push(array, pushed) {
|
|
8
|
-
|
|
8
|
+
return require_internal_array_insert.insertValues("push", array, pushed, array.length, 0);
|
|
9
9
|
}
|
|
10
|
-
|
|
11
10
|
exports.push = push;
|
package/dist/array/push.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { insertValues } from
|
|
2
|
-
|
|
1
|
+
import { insertValues } from "../internal/array/insert.js";
|
|
2
|
+
/**
|
|
3
|
+
* - Push values to the end of an array
|
|
4
|
+
* - Returns the new length
|
|
5
|
+
* - _(Uses chunking to avoid call stack size being exceeded)_
|
|
6
|
+
*/
|
|
3
7
|
function push(array, pushed) {
|
|
4
|
-
|
|
8
|
+
return insertValues("push", array, pushed, array.length, 0);
|
|
5
9
|
}
|
|
6
|
-
|
|
7
10
|
export { push };
|
package/dist/array/sort.cjs
CHANGED
|
@@ -1,67 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const internal_value_compare = require('../internal/value/compare.cjs');
|
|
6
|
-
const internal_is = require('../internal/is.cjs');
|
|
7
|
-
|
|
1
|
+
const require_internal_is = require("../internal/is.cjs");
|
|
2
|
+
require("../is.cjs");
|
|
3
|
+
const require_internal_value_compare = require("../internal/value/compare.cjs");
|
|
8
4
|
function getSorter(value, modifier) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return sorter;
|
|
23
|
-
}
|
|
5
|
+
const isObject = require_internal_is.isPlainObject(value);
|
|
6
|
+
const sorter = {
|
|
7
|
+
identifier: "",
|
|
8
|
+
modifier
|
|
9
|
+
};
|
|
10
|
+
sorter.compare = isObject && typeof value.compare === "function" ? value.compare : void 0;
|
|
11
|
+
sorter.key = isObject && typeof value.key === "string" ? value.key : typeof value === "string" ? value : void 0;
|
|
12
|
+
sorter.callback = sorter.key == null ? isObject && typeof value.value === "function" ? value.value : typeof value === "function" ? value : void 0 : void 0;
|
|
13
|
+
if (isObject && typeof value.direction === "string") sorter.modifier = value.direction === "ascending" ? 1 : value.direction === "descending" ? -1 : modifier;
|
|
14
|
+
if (sorter.key != null || sorter.callback != null) {
|
|
15
|
+
sorter.identifier = `${sorter.key ?? sorter.callback}`;
|
|
16
|
+
return sorter;
|
|
17
|
+
}
|
|
24
18
|
}
|
|
25
19
|
function sort(array, first, second) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
for (let index = 0; index < length; index += 1) {
|
|
54
|
-
const sorter = sorters[index];
|
|
55
|
-
const { callback, key, modifier: modifier2 } = sorter;
|
|
56
|
-
const firstValue = key == null ? callback?.(first2) : first2[key];
|
|
57
|
-
const secondValue = key == null ? callback?.(second2) : second2[key];
|
|
58
|
-
const compared = (sorter.compare?.(first2, firstValue, second2, secondValue) ?? internal_value_compare.compare(firstValue, secondValue)) * modifier2;
|
|
59
|
-
if (compared !== 0) {
|
|
60
|
-
return compared;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return 0;
|
|
64
|
-
});
|
|
20
|
+
if (!Array.isArray(array)) return [];
|
|
21
|
+
if (array.length < 2) return array;
|
|
22
|
+
const direction = first === true || second === true ? "desc" : "asc";
|
|
23
|
+
const modifier = direction === "asc" ? 1 : -1;
|
|
24
|
+
const sorters = (Array.isArray(first) ? first : [first]).map((item) => getSorter(item, modifier)).filter((sorter) => sorter != null).filter((current, index, sorters$1) => sorters$1.findIndex((next) => next.identifier === current.identifier) === index);
|
|
25
|
+
const { length } = sorters;
|
|
26
|
+
if (length === 0) return array.sort((first$1, second$1) => require_internal_value_compare.compare(first$1, second$1) * modifier);
|
|
27
|
+
if (length === 1) {
|
|
28
|
+
const sorter = sorters[0];
|
|
29
|
+
const { callback, key, modifier: modifier$1 } = sorter;
|
|
30
|
+
return array.sort((first$1, second$1) => {
|
|
31
|
+
const firstValue = key == null ? callback?.(first$1) : first$1[key];
|
|
32
|
+
const secondValue = key == null ? callback?.(second$1) : second$1[key];
|
|
33
|
+
return (sorter.compare?.(first$1, firstValue, second$1, secondValue) ?? require_internal_value_compare.compare(firstValue, secondValue)) * modifier$1;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return array.sort((first$1, second$1) => {
|
|
37
|
+
for (let index = 0; index < length; index += 1) {
|
|
38
|
+
const sorter = sorters[index];
|
|
39
|
+
const { callback, key, modifier: modifier$1 } = sorter;
|
|
40
|
+
const firstValue = key == null ? callback?.(first$1) : first$1[key];
|
|
41
|
+
const secondValue = key == null ? callback?.(second$1) : second$1[key];
|
|
42
|
+
const compared = (sorter.compare?.(first$1, firstValue, second$1, secondValue) ?? require_internal_value_compare.compare(firstValue, secondValue)) * modifier$1;
|
|
43
|
+
if (compared !== 0) return compared;
|
|
44
|
+
}
|
|
45
|
+
return 0;
|
|
46
|
+
});
|
|
65
47
|
}
|
|
66
|
-
|
|
67
48
|
exports.sort = sort;
|