@oscarpalmer/atoms 0.99.0 → 0.100.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/flatten.cjs +9 -0
- package/dist/array/flatten.js +5 -0
- package/dist/array/group-by.cjs +2 -27
- package/dist/array/group-by.js +2 -26
- package/dist/array/index.cjs +13 -19
- package/dist/array/index.js +6 -17
- package/dist/array/insert.cjs +2 -28
- package/dist/array/insert.js +2 -27
- package/dist/array/push.cjs +11 -0
- package/dist/array/push.js +7 -0
- package/dist/array/sort.cjs +38 -38
- package/dist/array/sort.js +38 -38
- package/dist/array/splice.cjs +2 -2
- package/dist/array/splice.js +1 -1
- package/dist/array/to-map.cjs +1 -1
- package/dist/array/to-map.js +1 -1
- package/dist/array/to-record.cjs +2 -2
- package/dist/array/to-record.js +1 -1
- package/dist/array/unique.cjs +1 -4
- package/dist/array/unique.js +1 -4
- package/dist/color/constants.cjs +33 -0
- package/dist/color/constants.js +22 -0
- package/dist/color/get.cjs +50 -0
- package/dist/color/get.js +46 -0
- package/dist/color/index.cjs +98 -0
- package/dist/color/index.js +85 -0
- package/dist/color/is.cjs +58 -0
- package/dist/color/is.js +51 -0
- package/dist/color/misc.cjs +16 -0
- package/dist/color/misc.js +12 -0
- package/dist/color/models.cjs +2 -0
- package/dist/color/models.js +1 -0
- package/dist/color/value.cjs +90 -0
- package/dist/color/value.js +83 -0
- package/dist/emitter.cjs +8 -8
- package/dist/emitter.js +1 -1
- package/dist/function.cjs +52 -41
- package/dist/function.js +51 -39
- package/dist/i18n.cjs +6 -4
- package/dist/i18n.js +6 -4
- package/dist/index.cjs +78 -71
- package/dist/index.js +34 -27
- package/dist/internal/array/callbacks.cjs +1 -4
- package/dist/internal/array/callbacks.js +1 -4
- package/dist/internal/array/find.cjs +4 -4
- package/dist/internal/array/find.js +4 -4
- package/dist/internal/array/group.cjs +32 -0
- package/dist/internal/array/group.js +28 -0
- package/dist/internal/array/insert.cjs +33 -0
- package/dist/internal/array/insert.js +29 -0
- package/dist/{array → internal/array}/shuffle.cjs +4 -4
- package/dist/{array → internal/array}/shuffle.js +1 -1
- package/dist/internal/function.cjs +29 -0
- package/dist/internal/function.js +25 -0
- package/dist/internal/is.cjs +45 -0
- package/dist/internal/is.js +37 -0
- package/dist/internal/math/aggregate.cjs +4 -0
- package/dist/internal/math/aggregate.js +4 -1
- package/dist/internal/number.cjs +67 -0
- package/dist/internal/number.js +61 -0
- package/dist/internal/random.cjs +23 -0
- package/dist/internal/random.js +18 -0
- package/dist/internal/string.cjs +50 -0
- package/dist/internal/string.js +41 -0
- package/dist/{value → internal/value}/compare.cjs +8 -8
- package/dist/{value → internal/value}/compare.js +3 -3
- package/dist/{value → internal/value}/equal.cjs +3 -3
- package/dist/{value → internal/value}/get.cjs +6 -4
- package/dist/{value → internal/value}/get.js +4 -2
- package/dist/internal/value/misc.cjs +34 -0
- package/dist/internal/value/misc.js +29 -0
- package/dist/{value → internal/value}/set.cjs +8 -5
- package/dist/{value → internal/value}/set.js +5 -2
- package/dist/is.cjs +10 -31
- package/dist/is.js +4 -24
- package/dist/logger.cjs +9 -9
- package/dist/logger.js +1 -1
- package/dist/math.cjs +1 -4
- package/dist/math.js +2 -4
- package/dist/number.cjs +6 -49
- package/dist/number.js +1 -48
- package/dist/query.cjs +32 -33
- package/dist/query.js +29 -30
- package/dist/random.cjs +9 -22
- package/dist/random.js +4 -16
- package/dist/sized.cjs +24 -30
- package/dist/sized.js +23 -29
- package/dist/string/case.cjs +5 -5
- package/dist/string/case.js +1 -1
- package/dist/string/index.cjs +4 -3
- package/dist/string/index.js +2 -1
- package/dist/string/misc.cjs +2 -26
- package/dist/string/misc.js +3 -24
- package/dist/string/template.cjs +4 -4
- package/dist/string/template.js +2 -2
- package/dist/value/clone.cjs +12 -2
- package/dist/value/clone.js +11 -1
- package/dist/value/diff.cjs +13 -10
- package/dist/value/diff.js +7 -4
- package/dist/value/index.cjs +11 -21
- package/dist/value/index.js +5 -19
- package/dist/value/merge.cjs +24 -7
- package/dist/value/merge.js +24 -7
- package/dist/value/partial.cjs +18 -0
- package/dist/value/partial.js +14 -0
- package/dist/value/smush.cjs +6 -6
- package/dist/value/smush.js +2 -2
- package/dist/value/unsmush.cjs +4 -4
- package/dist/value/unsmush.js +2 -2
- package/package.json +1 -2
- package/src/array/models.ts +32 -9
- package/src/array/sort.ts +124 -76
- package/src/function.ts +11 -8
- package/src/internal/array/shuffle.ts +1 -1
- package/src/internal/function.ts +36 -0
- package/types/array/count.d.cts +6 -0
- package/types/array/exists.d.cts +6 -0
- package/types/array/filter.d.cts +6 -0
- package/types/array/find.d.cts +6 -0
- package/types/array/flatten.d.cts +9 -0
- package/types/array/flatten.d.ts +5 -0
- package/types/array/group-by.d.cts +7 -2
- package/types/array/group-by.d.ts +0 -1
- package/types/array/index-of.d.cts +6 -0
- package/types/array/index.d.cts +59 -29
- package/types/array/index.d.ts +9 -17
- package/types/array/insert.d.cts +0 -2
- package/types/array/insert.d.ts +0 -2
- package/types/array/models.d.cts +26 -16
- package/types/array/models.d.ts +26 -15
- package/types/array/push.d.cts +10 -0
- package/types/array/push.d.ts +6 -0
- package/types/array/sort.d.cts +42 -16
- package/types/array/sort.d.ts +14 -14
- package/types/array/to-map.d.cts +6 -0
- package/types/array/to-record.d.cts +7 -1
- package/types/array/unique.d.cts +6 -0
- package/types/color/constants.d.cts +23 -0
- package/types/color/constants.d.ts +9 -0
- package/types/color/get.d.cts +23 -0
- package/types/color/get.d.ts +5 -0
- package/types/{color.d.ts → color/index.d.ts} +3 -26
- package/types/color/is.d.cts +53 -0
- package/types/color/is.d.ts +18 -0
- package/types/color/misc.d.cts +8 -0
- package/types/color/misc.d.ts +4 -0
- package/types/color/models.d.cts +20 -0
- package/types/color/models.d.ts +16 -0
- package/types/color/value.d.cts +32 -0
- package/types/color/value.d.ts +19 -0
- package/types/function.d.cts +14 -17
- package/types/function.d.ts +7 -13
- package/types/index.d.cts +201 -157
- package/types/index.d.ts +1 -1
- package/types/internal/array/callbacks.d.cts +1 -1
- package/types/internal/array/callbacks.d.ts +6 -1
- package/types/internal/array/find.d.ts +3 -1
- package/types/internal/array/group.d.cts +9 -0
- package/types/internal/array/group.d.ts +2 -0
- package/types/internal/array/insert.d.cts +5 -0
- package/types/internal/array/insert.d.ts +1 -0
- package/types/internal/function.d.cts +12 -0
- package/types/internal/function.d.ts +8 -0
- package/types/internal/is.d.cts +37 -0
- package/types/internal/is.d.ts +21 -0
- package/types/internal/math/aggregate.d.cts +19 -0
- package/types/internal/math/aggregate.d.ts +16 -0
- package/types/internal/number.d.cts +20 -0
- package/types/internal/number.d.ts +16 -0
- package/types/internal/random.d.cts +12 -0
- package/types/internal/random.d.ts +8 -0
- package/types/internal/string.d.cts +19 -0
- package/types/internal/string.d.ts +15 -0
- package/types/{value → internal/value}/get.d.cts +9 -3
- package/types/{value → internal/value}/get.d.ts +1 -1
- package/types/internal/value/{handle.d.cts → misc.d.cts} +4 -0
- package/types/internal/value/{handle.d.ts → misc.d.ts} +1 -0
- package/types/{value → internal/value}/set.d.cts +9 -3
- package/types/{value → internal/value}/set.d.ts +1 -1
- package/types/is.d.cts +25 -13
- package/types/is.d.ts +2 -18
- package/types/math.d.cts +15 -12
- package/types/math.d.ts +2 -16
- package/types/models.d.cts +20 -5
- package/types/models.d.ts +14 -2
- package/types/number.d.cts +2 -1
- package/types/number.d.ts +1 -15
- package/types/query.d.cts +3 -0
- package/types/random.d.cts +8 -8
- package/types/random.d.ts +1 -8
- package/types/sized.d.cts +8 -10
- package/types/sized.d.ts +8 -10
- package/types/string/index.d.cts +15 -12
- package/types/string/index.d.ts +1 -0
- package/types/string/misc.d.cts +0 -12
- package/types/string/misc.d.ts +0 -12
- package/types/string/template.d.cts +3 -0
- package/types/value/index.d.cts +59 -42
- package/types/value/index.d.ts +5 -9
- package/types/value/merge.d.cts +13 -2
- package/types/value/merge.d.ts +8 -3
- package/types/value/partial.d.cts +12 -0
- package/types/value/partial.d.ts +5 -0
- package/types/value/smush.d.cts +9 -3
- package/types/value/unsmush.d.cts +3 -0
- package/dist/atoms.full.js +0 -2745
- package/dist/attoms.full.js +0 -2840
- package/dist/color.cjs +0 -276
- package/dist/color.js +0 -263
- package/dist/internal/string/key.cjs +0 -10
- package/dist/internal/string/key.js +0 -6
- package/dist/internal/value/handle.cjs +0 -26
- package/dist/internal/value/handle.js +0 -22
- package/dist/internal/value/paths.cjs +0 -11
- package/dist/internal/value/paths.js +0 -7
- package/types/internal/string/key.d.cts +0 -5
- package/types/internal/string/key.d.ts +0 -1
- package/types/internal/value/paths.d.cts +0 -5
- package/types/internal/value/paths.d.ts +0 -1
- package/dist/{array → internal/array}/chunk.cjs +0 -0
- package/dist/{array → internal/array}/chunk.js +0 -0
- package/dist/{array → internal/array}/compact.cjs +0 -0
- package/dist/{array → internal/array}/compact.js +0 -0
- package/dist/{value → internal/value}/equal.js +0 -0
- package/types/{color.d.cts → color/index.d.cts} +16 -16
- /package/types/{array → internal/array}/chunk.d.cts +0 -0
- /package/types/{array → internal/array}/chunk.d.ts +0 -0
- /package/types/{array → internal/array}/compact.d.cts +0 -0
- /package/types/{array → internal/array}/compact.d.ts +0 -0
- /package/types/{array → internal/array}/shuffle.d.cts +0 -0
- /package/types/{array → internal/array}/shuffle.d.ts +0 -0
- /package/types/{value → internal/value}/compare.d.cts +0 -0
- /package/types/{value → internal/value}/compare.d.ts +0 -0
- /package/types/{value → internal/value}/equal.d.cts +0 -0
- /package/types/{value → internal/value}/equal.d.ts +0 -0
package/dist/array/group-by.cjs
CHANGED
|
@@ -2,40 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const internal_array_group = require('../internal/array/group.cjs');
|
|
6
6
|
|
|
7
7
|
function groupBy(array, key, valueOrArrays, arrays) {
|
|
8
|
-
return groupValues(
|
|
8
|
+
return internal_array_group.groupValues(
|
|
9
9
|
array,
|
|
10
10
|
key,
|
|
11
11
|
valueOrArrays,
|
|
12
12
|
key === true || valueOrArrays === true || arrays === true
|
|
13
13
|
);
|
|
14
14
|
}
|
|
15
|
-
function groupValues(array, key, value, arrays) {
|
|
16
|
-
if (!Array.isArray(array) || array.length === 0) {
|
|
17
|
-
return {};
|
|
18
|
-
}
|
|
19
|
-
const callbacks = internal_array_callbacks.getCallbacks(void 0, key, value);
|
|
20
|
-
const record = {};
|
|
21
|
-
const { length } = array;
|
|
22
|
-
for (let index = 0; index < length; index += 1) {
|
|
23
|
-
const item = array[index];
|
|
24
|
-
const keyed = callbacks?.key?.(item, index, array) ?? index;
|
|
25
|
-
const valued = callbacks?.value?.(item, index, array) ?? item;
|
|
26
|
-
if (arrays) {
|
|
27
|
-
const existing = record[keyed];
|
|
28
|
-
if (existing == null) {
|
|
29
|
-
record[keyed] = [valued];
|
|
30
|
-
} else {
|
|
31
|
-
existing.push(valued);
|
|
32
|
-
}
|
|
33
|
-
} else {
|
|
34
|
-
record[keyed] = valued;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return record;
|
|
38
|
-
}
|
|
39
15
|
|
|
40
16
|
exports.groupBy = groupBy;
|
|
41
|
-
exports.groupValues = groupValues;
|
package/dist/array/group-by.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { groupValues } from '../internal/array/group.js';
|
|
2
2
|
|
|
3
3
|
function groupBy(array, key, valueOrArrays, arrays) {
|
|
4
4
|
return groupValues(
|
|
@@ -8,29 +8,5 @@ function groupBy(array, key, valueOrArrays, arrays) {
|
|
|
8
8
|
key === true || valueOrArrays === true || arrays === true
|
|
9
9
|
);
|
|
10
10
|
}
|
|
11
|
-
function groupValues(array, key, value, arrays) {
|
|
12
|
-
if (!Array.isArray(array) || array.length === 0) {
|
|
13
|
-
return {};
|
|
14
|
-
}
|
|
15
|
-
const callbacks = getCallbacks(void 0, key, value);
|
|
16
|
-
const record = {};
|
|
17
|
-
const { length } = array;
|
|
18
|
-
for (let index = 0; index < length; index += 1) {
|
|
19
|
-
const item = array[index];
|
|
20
|
-
const keyed = callbacks?.key?.(item, index, array) ?? index;
|
|
21
|
-
const valued = callbacks?.value?.(item, index, array) ?? item;
|
|
22
|
-
if (arrays) {
|
|
23
|
-
const existing = record[keyed];
|
|
24
|
-
if (existing == null) {
|
|
25
|
-
record[keyed] = [valued];
|
|
26
|
-
} else {
|
|
27
|
-
existing.push(valued);
|
|
28
|
-
}
|
|
29
|
-
} else {
|
|
30
|
-
record[keyed] = valued;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return record;
|
|
34
|
-
}
|
|
35
11
|
|
|
36
|
-
export { groupBy
|
|
12
|
+
export { groupBy };
|
package/dist/array/index.cjs
CHANGED
|
@@ -2,46 +2,40 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
5
|
+
const internal_array_chunk = require('../internal/array/chunk.cjs');
|
|
6
|
+
const internal_array_compact = require('../internal/array/compact.cjs');
|
|
7
|
+
const internal_array_shuffle = require('../internal/array/shuffle.cjs');
|
|
8
8
|
const array_count = require('./count.cjs');
|
|
9
9
|
const array_exists = require('./exists.cjs');
|
|
10
10
|
const array_filter = require('./filter.cjs');
|
|
11
11
|
const array_find = require('./find.cjs');
|
|
12
|
+
const array_flatten = require('./flatten.cjs');
|
|
12
13
|
const array_groupBy = require('./group-by.cjs');
|
|
13
14
|
const array_indexOf = require('./index-of.cjs');
|
|
14
|
-
const
|
|
15
|
+
const array_insert = require('./insert.cjs');
|
|
16
|
+
const array_push = require('./push.cjs');
|
|
15
17
|
const array_sort = require('./sort.cjs');
|
|
16
18
|
const array_splice = require('./splice.cjs');
|
|
17
19
|
const array_toMap = require('./to-map.cjs');
|
|
18
20
|
const array_toRecord = require('./to-record.cjs');
|
|
19
21
|
const array_unique = require('./unique.cjs');
|
|
20
22
|
|
|
21
|
-
function flatten(array) {
|
|
22
|
-
if (!Array.isArray(array)) {
|
|
23
|
-
return [];
|
|
24
|
-
}
|
|
25
|
-
return array.flat(Number.POSITIVE_INFINITY);
|
|
26
|
-
}
|
|
27
|
-
function push(array, pushed) {
|
|
28
|
-
return array_insert.insertValues("push", array, pushed, array.length, 0);
|
|
29
|
-
}
|
|
30
23
|
|
|
31
|
-
|
|
32
|
-
exports.chunk =
|
|
33
|
-
exports.compact =
|
|
24
|
+
|
|
25
|
+
exports.chunk = internal_array_chunk.chunk;
|
|
26
|
+
exports.compact = internal_array_compact.compact;
|
|
27
|
+
exports.shuffle = internal_array_shuffle.shuffle;
|
|
34
28
|
exports.count = array_count.count;
|
|
35
29
|
exports.exists = array_exists.exists;
|
|
36
30
|
exports.filter = array_filter.filter;
|
|
37
31
|
exports.find = array_find.find;
|
|
32
|
+
exports.flatten = array_flatten.flatten;
|
|
38
33
|
exports.groupBy = array_groupBy.groupBy;
|
|
39
34
|
exports.indexOf = array_indexOf.indexOf;
|
|
40
|
-
exports.
|
|
35
|
+
exports.insert = array_insert.insert;
|
|
36
|
+
exports.push = array_push.push;
|
|
41
37
|
exports.sort = array_sort.sort;
|
|
42
38
|
exports.splice = array_splice.splice;
|
|
43
39
|
exports.toMap = array_toMap.toMap;
|
|
44
40
|
exports.toRecord = array_toRecord.toRecord;
|
|
45
41
|
exports.unique = array_unique.unique;
|
|
46
|
-
exports.flatten = flatten;
|
|
47
|
-
exports.push = push;
|
package/dist/array/index.js
CHANGED
|
@@ -1,28 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export { compact } from './compact.js';
|
|
1
|
+
export { chunk } from '../internal/array/chunk.js';
|
|
2
|
+
export { compact } from '../internal/array/compact.js';
|
|
3
|
+
export { shuffle } from '../internal/array/shuffle.js';
|
|
5
4
|
export { count } from './count.js';
|
|
6
5
|
export { exists } from './exists.js';
|
|
7
6
|
export { filter } from './filter.js';
|
|
8
7
|
export { find } from './find.js';
|
|
8
|
+
export { flatten } from './flatten.js';
|
|
9
9
|
export { groupBy } from './group-by.js';
|
|
10
10
|
export { indexOf } from './index-of.js';
|
|
11
|
-
export {
|
|
11
|
+
export { insert } from './insert.js';
|
|
12
|
+
export { push } from './push.js';
|
|
12
13
|
export { sort } from './sort.js';
|
|
13
14
|
export { splice } from './splice.js';
|
|
14
15
|
export { toMap } from './to-map.js';
|
|
15
16
|
export { toRecord } from './to-record.js';
|
|
16
17
|
export { unique } from './unique.js';
|
|
17
|
-
|
|
18
|
-
function flatten(array) {
|
|
19
|
-
if (!Array.isArray(array)) {
|
|
20
|
-
return [];
|
|
21
|
-
}
|
|
22
|
-
return array.flat(Number.POSITIVE_INFINITY);
|
|
23
|
-
}
|
|
24
|
-
function push(array, pushed) {
|
|
25
|
-
return insertValues("push", array, pushed, array.length, 0);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export { flatten, push };
|
package/dist/array/insert.cjs
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const internal_array_insert = require('../internal/array/insert.cjs');
|
|
6
6
|
|
|
7
7
|
function insert(array, indexOrItems, items) {
|
|
8
|
-
return insertValues(
|
|
8
|
+
return internal_array_insert.insertValues(
|
|
9
9
|
"insert",
|
|
10
10
|
array,
|
|
11
11
|
items == null ? indexOrItems : items,
|
|
@@ -13,31 +13,5 @@ function insert(array, indexOrItems, items) {
|
|
|
13
13
|
0
|
|
14
14
|
);
|
|
15
15
|
}
|
|
16
|
-
function insertValues(type, array, items, start, deleteCount) {
|
|
17
|
-
const splice = type === "insert" || type === "splice";
|
|
18
|
-
if (!Array.isArray(array) || typeof start !== "number") {
|
|
19
|
-
return splice ? [] : 0;
|
|
20
|
-
}
|
|
21
|
-
if (!Array.isArray(items) || items.length === 0) {
|
|
22
|
-
return splice ? [] : 0;
|
|
23
|
-
}
|
|
24
|
-
const actualStart = Math.min(Math.max(0, start), array.length);
|
|
25
|
-
const chunked = array_chunk.chunk(items);
|
|
26
|
-
const lastIndex = chunked.length - 1;
|
|
27
|
-
let index = Number(chunked.length);
|
|
28
|
-
let returned;
|
|
29
|
-
while (--index >= 0) {
|
|
30
|
-
const result = array.splice(
|
|
31
|
-
actualStart,
|
|
32
|
-
index === lastIndex ? deleteCount < 0 ? 0 : deleteCount : 0,
|
|
33
|
-
...chunked[index]
|
|
34
|
-
);
|
|
35
|
-
if (returned == null) {
|
|
36
|
-
returned = result;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return type === "insert" ? array : type === "splice" ? returned : array.length;
|
|
40
|
-
}
|
|
41
16
|
|
|
42
17
|
exports.insert = insert;
|
|
43
|
-
exports.insertValues = insertValues;
|
package/dist/array/insert.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { insertValues } from '../internal/array/insert.js';
|
|
2
2
|
|
|
3
3
|
function insert(array, indexOrItems, items) {
|
|
4
4
|
return insertValues(
|
|
@@ -9,30 +9,5 @@ function insert(array, indexOrItems, items) {
|
|
|
9
9
|
0
|
|
10
10
|
);
|
|
11
11
|
}
|
|
12
|
-
function insertValues(type, array, items, start, deleteCount) {
|
|
13
|
-
const splice = type === "insert" || type === "splice";
|
|
14
|
-
if (!Array.isArray(array) || typeof start !== "number") {
|
|
15
|
-
return splice ? [] : 0;
|
|
16
|
-
}
|
|
17
|
-
if (!Array.isArray(items) || items.length === 0) {
|
|
18
|
-
return splice ? [] : 0;
|
|
19
|
-
}
|
|
20
|
-
const actualStart = Math.min(Math.max(0, start), array.length);
|
|
21
|
-
const chunked = chunk(items);
|
|
22
|
-
const lastIndex = chunked.length - 1;
|
|
23
|
-
let index = Number(chunked.length);
|
|
24
|
-
let returned;
|
|
25
|
-
while (--index >= 0) {
|
|
26
|
-
const result = array.splice(
|
|
27
|
-
actualStart,
|
|
28
|
-
index === lastIndex ? deleteCount < 0 ? 0 : deleteCount : 0,
|
|
29
|
-
...chunked[index]
|
|
30
|
-
);
|
|
31
|
-
if (returned == null) {
|
|
32
|
-
returned = result;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return type === "insert" ? array : type === "splice" ? returned : array.length;
|
|
36
|
-
}
|
|
37
12
|
|
|
38
|
-
export { insert
|
|
13
|
+
export { insert };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const internal_array_insert = require('../internal/array/insert.cjs');
|
|
6
|
+
|
|
7
|
+
function push(array, pushed) {
|
|
8
|
+
return internal_array_insert.insertValues("push", array, pushed, array.length, 0);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
exports.push = push;
|
package/dist/array/sort.cjs
CHANGED
|
@@ -2,9 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const internal_value_compare = require('../internal/value/compare.cjs');
|
|
6
|
+
const internal_is = require('../internal/is.cjs');
|
|
7
7
|
|
|
8
|
+
function getSorter(value, modifier) {
|
|
9
|
+
const isObject = internal_is.isPlainObject(value);
|
|
10
|
+
const sorter = {
|
|
11
|
+
identifier: "",
|
|
12
|
+
modifier
|
|
13
|
+
};
|
|
14
|
+
sorter.compare = isObject && typeof value.compare === "function" ? value.compare : void 0;
|
|
15
|
+
sorter.key = isObject && typeof value.key === "string" ? value.key : typeof value === "string" ? value : void 0;
|
|
16
|
+
sorter.callback = sorter.key == null ? isObject && typeof value.value === "function" ? value.value : typeof value === "function" ? value : void 0 : void 0;
|
|
17
|
+
if (isObject && typeof value.direction === "string") {
|
|
18
|
+
sorter.modifier = value.direction === "ascending" ? 1 : value.direction === "descending" ? -1 : modifier;
|
|
19
|
+
}
|
|
20
|
+
if (sorter.key != null || sorter.callback != null) {
|
|
21
|
+
sorter.identifier = `${sorter.key ?? sorter.callback}`;
|
|
22
|
+
return sorter;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
8
25
|
function sort(array, first, second) {
|
|
9
26
|
if (!Array.isArray(array)) {
|
|
10
27
|
return [];
|
|
@@ -13,55 +30,38 @@ function sort(array, first, second) {
|
|
|
13
30
|
return array;
|
|
14
31
|
}
|
|
15
32
|
const direction = first === true || second === true ? "desc" : "asc";
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const keyWithCallback = {
|
|
22
|
-
direction,
|
|
23
|
-
callback: void 0
|
|
24
|
-
};
|
|
25
|
-
if (is.isKey(key)) {
|
|
26
|
-
keyWithCallback.callback = (value) => value[key];
|
|
27
|
-
} else if (typeof key === "function") {
|
|
28
|
-
keyWithCallback.callback = key;
|
|
29
|
-
} else if (typeof key?.value === "function" || is.isKey(key?.value)) {
|
|
30
|
-
keyWithCallback.direction = key?.direction ?? direction;
|
|
31
|
-
keyWithCallback.callback = typeof key.value === "function" ? key.value : (value) => value[key.value];
|
|
32
|
-
}
|
|
33
|
-
if (typeof keyWithCallback.callback === "function") {
|
|
34
|
-
const existing = keys.findIndex(
|
|
35
|
-
(existing2) => existing2.callback.toString() === keyWithCallback.callback.toString()
|
|
36
|
-
);
|
|
37
|
-
if (existing > -1) {
|
|
38
|
-
keys.splice(existing, 1);
|
|
39
|
-
}
|
|
40
|
-
keys.push(keyWithCallback);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
length = keys.length;
|
|
33
|
+
const modifier = direction === "asc" ? 1 : -1;
|
|
34
|
+
const sorters = (Array.isArray(first) ? first : [first]).map((item) => getSorter(item, modifier)).filter((sorter) => sorter != null).filter(
|
|
35
|
+
(current, index, sorters2) => sorters2.findIndex((next) => next.identifier === current.identifier) === index
|
|
36
|
+
);
|
|
37
|
+
const { length } = sorters;
|
|
44
38
|
if (length === 0) {
|
|
45
39
|
return array.sort(
|
|
46
|
-
(first2, second2) =>
|
|
40
|
+
(first2, second2) => internal_value_compare.compare(first2, second2) * modifier
|
|
47
41
|
);
|
|
48
42
|
}
|
|
49
43
|
if (length === 1) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
)
|
|
44
|
+
const sorter = sorters[0];
|
|
45
|
+
const { callback, key, modifier: modifier2 } = sorter;
|
|
46
|
+
return array.sort((first2, second2) => {
|
|
47
|
+
const firstValue = key == null ? callback?.(first2) : first2[key];
|
|
48
|
+
const secondValue = key == null ? callback?.(second2) : second2[key];
|
|
49
|
+
return (sorter.compare?.(first2, firstValue, second2, secondValue) ?? internal_value_compare.compare(firstValue, secondValue)) * modifier2;
|
|
50
|
+
});
|
|
53
51
|
}
|
|
54
|
-
|
|
52
|
+
return array.sort((first2, second2) => {
|
|
55
53
|
for (let index = 0; index < length; index += 1) {
|
|
56
|
-
const
|
|
57
|
-
const
|
|
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;
|
|
58
59
|
if (compared !== 0) {
|
|
59
60
|
return compared;
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
63
|
return 0;
|
|
63
64
|
});
|
|
64
|
-
return sorted;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
exports.sort = sort;
|
package/dist/array/sort.js
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { compare } from '../internal/value/compare.js';
|
|
2
|
+
import { isPlainObject } from '../internal/is.js';
|
|
3
3
|
|
|
4
|
+
function getSorter(value, modifier) {
|
|
5
|
+
const isObject = 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") {
|
|
14
|
+
sorter.modifier = value.direction === "ascending" ? 1 : value.direction === "descending" ? -1 : modifier;
|
|
15
|
+
}
|
|
16
|
+
if (sorter.key != null || sorter.callback != null) {
|
|
17
|
+
sorter.identifier = `${sorter.key ?? sorter.callback}`;
|
|
18
|
+
return sorter;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
4
21
|
function sort(array, first, second) {
|
|
5
22
|
if (!Array.isArray(array)) {
|
|
6
23
|
return [];
|
|
@@ -9,55 +26,38 @@ function sort(array, first, second) {
|
|
|
9
26
|
return array;
|
|
10
27
|
}
|
|
11
28
|
const direction = first === true || second === true ? "desc" : "asc";
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const keyWithCallback = {
|
|
18
|
-
direction,
|
|
19
|
-
callback: void 0
|
|
20
|
-
};
|
|
21
|
-
if (isKey(key)) {
|
|
22
|
-
keyWithCallback.callback = (value) => value[key];
|
|
23
|
-
} else if (typeof key === "function") {
|
|
24
|
-
keyWithCallback.callback = key;
|
|
25
|
-
} else if (typeof key?.value === "function" || isKey(key?.value)) {
|
|
26
|
-
keyWithCallback.direction = key?.direction ?? direction;
|
|
27
|
-
keyWithCallback.callback = typeof key.value === "function" ? key.value : (value) => value[key.value];
|
|
28
|
-
}
|
|
29
|
-
if (typeof keyWithCallback.callback === "function") {
|
|
30
|
-
const existing = keys.findIndex(
|
|
31
|
-
(existing2) => existing2.callback.toString() === keyWithCallback.callback.toString()
|
|
32
|
-
);
|
|
33
|
-
if (existing > -1) {
|
|
34
|
-
keys.splice(existing, 1);
|
|
35
|
-
}
|
|
36
|
-
keys.push(keyWithCallback);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
length = keys.length;
|
|
29
|
+
const modifier = direction === "asc" ? 1 : -1;
|
|
30
|
+
const sorters = (Array.isArray(first) ? first : [first]).map((item) => getSorter(item, modifier)).filter((sorter) => sorter != null).filter(
|
|
31
|
+
(current, index, sorters2) => sorters2.findIndex((next) => next.identifier === current.identifier) === index
|
|
32
|
+
);
|
|
33
|
+
const { length } = sorters;
|
|
40
34
|
if (length === 0) {
|
|
41
35
|
return array.sort(
|
|
42
|
-
(first2, second2) => compare(first2, second2) *
|
|
36
|
+
(first2, second2) => compare(first2, second2) * modifier
|
|
43
37
|
);
|
|
44
38
|
}
|
|
45
39
|
if (length === 1) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
)
|
|
40
|
+
const sorter = sorters[0];
|
|
41
|
+
const { callback, key, modifier: modifier2 } = sorter;
|
|
42
|
+
return array.sort((first2, second2) => {
|
|
43
|
+
const firstValue = key == null ? callback?.(first2) : first2[key];
|
|
44
|
+
const secondValue = key == null ? callback?.(second2) : second2[key];
|
|
45
|
+
return (sorter.compare?.(first2, firstValue, second2, secondValue) ?? compare(firstValue, secondValue)) * modifier2;
|
|
46
|
+
});
|
|
49
47
|
}
|
|
50
|
-
|
|
48
|
+
return array.sort((first2, second2) => {
|
|
51
49
|
for (let index = 0; index < length; index += 1) {
|
|
52
|
-
const
|
|
53
|
-
const
|
|
50
|
+
const sorter = sorters[index];
|
|
51
|
+
const { callback, key, modifier: modifier2 } = sorter;
|
|
52
|
+
const firstValue = key == null ? callback?.(first2) : first2[key];
|
|
53
|
+
const secondValue = key == null ? callback?.(second2) : second2[key];
|
|
54
|
+
const compared = (sorter.compare?.(first2, firstValue, second2, secondValue) ?? compare(firstValue, secondValue)) * modifier2;
|
|
54
55
|
if (compared !== 0) {
|
|
55
56
|
return compared;
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
59
|
return 0;
|
|
59
60
|
});
|
|
60
|
-
return sorted;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
export { sort };
|
package/dist/array/splice.cjs
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const internal_array_insert = require('../internal/array/insert.cjs');
|
|
6
6
|
|
|
7
7
|
function splice(array, start, deleteCountOrItems, items) {
|
|
8
|
-
return
|
|
8
|
+
return internal_array_insert.insertValues(
|
|
9
9
|
"splice",
|
|
10
10
|
array,
|
|
11
11
|
typeof deleteCountOrItems === "number" ? items : deleteCountOrItems,
|
package/dist/array/splice.js
CHANGED
package/dist/array/to-map.cjs
CHANGED
|
@@ -14,7 +14,7 @@ function toMap(array, keyOrArrays, valueOrArrays, arrays) {
|
|
|
14
14
|
const { length } = array;
|
|
15
15
|
for (let index = 0; index < length; index += 1) {
|
|
16
16
|
const item = array[index];
|
|
17
|
-
const key = callbacks?.
|
|
17
|
+
const key = callbacks?.keyed?.(item, index, array) ?? index;
|
|
18
18
|
const value = callbacks?.value?.(item, index, array) ?? item;
|
|
19
19
|
if (asArrays) {
|
|
20
20
|
const existing = map.get(key);
|
package/dist/array/to-map.js
CHANGED
|
@@ -10,7 +10,7 @@ function toMap(array, keyOrArrays, valueOrArrays, arrays) {
|
|
|
10
10
|
const { length } = array;
|
|
11
11
|
for (let index = 0; index < length; index += 1) {
|
|
12
12
|
const item = array[index];
|
|
13
|
-
const key = callbacks?.
|
|
13
|
+
const key = callbacks?.keyed?.(item, index, array) ?? index;
|
|
14
14
|
const value = callbacks?.value?.(item, index, array) ?? item;
|
|
15
15
|
if (asArrays) {
|
|
16
16
|
const existing = map.get(key);
|
package/dist/array/to-record.cjs
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const internal_array_group = require('../internal/array/group.cjs');
|
|
6
6
|
|
|
7
7
|
function toRecord(array, key, valueOrArrays, arrays) {
|
|
8
|
-
return
|
|
8
|
+
return internal_array_group.groupValues(
|
|
9
9
|
array,
|
|
10
10
|
key,
|
|
11
11
|
valueOrArrays,
|
package/dist/array/to-record.js
CHANGED
package/dist/array/unique.cjs
CHANGED
|
@@ -8,10 +8,7 @@ function unique(array, key) {
|
|
|
8
8
|
if (!Array.isArray(array)) {
|
|
9
9
|
return [];
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
return array;
|
|
13
|
-
}
|
|
14
|
-
return internal_array_find.findValues("unique", array, [key, void 0]);
|
|
11
|
+
return array.length > 1 ? internal_array_find.findValues("unique", array, [key, void 0]) : array;
|
|
15
12
|
}
|
|
16
13
|
|
|
17
14
|
exports.unique = unique;
|
package/dist/array/unique.js
CHANGED
|
@@ -4,10 +4,7 @@ function unique(array, key) {
|
|
|
4
4
|
if (!Array.isArray(array)) {
|
|
5
5
|
return [];
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
return array;
|
|
9
|
-
}
|
|
10
|
-
return findValues("unique", array, [key, void 0]);
|
|
7
|
+
return array.length > 1 ? findValues("unique", array, [key, void 0]) : array;
|
|
11
8
|
}
|
|
12
9
|
|
|
13
10
|
export { unique };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const anyPattern = /^#?([a-f0-9]{3}){1,2}$/i;
|
|
6
|
+
const defaultHex = "000000";
|
|
7
|
+
const defaultHsl = {
|
|
8
|
+
hue: 0,
|
|
9
|
+
lightness: 0,
|
|
10
|
+
saturation: 0
|
|
11
|
+
};
|
|
12
|
+
const defaultRgb = {
|
|
13
|
+
blue: 0,
|
|
14
|
+
green: 0,
|
|
15
|
+
red: 0
|
|
16
|
+
};
|
|
17
|
+
const groupedPattern = /^#?([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})$/i;
|
|
18
|
+
const hslKeys = /* @__PURE__ */ new Set([
|
|
19
|
+
"hue",
|
|
20
|
+
"lightness",
|
|
21
|
+
"saturation"
|
|
22
|
+
]);
|
|
23
|
+
const prefixPattern = /^#/;
|
|
24
|
+
const rgbKeys = /* @__PURE__ */ new Set(["blue", "green", "red"]);
|
|
25
|
+
|
|
26
|
+
exports.anyPattern = anyPattern;
|
|
27
|
+
exports.defaultHex = defaultHex;
|
|
28
|
+
exports.defaultHsl = defaultHsl;
|
|
29
|
+
exports.defaultRgb = defaultRgb;
|
|
30
|
+
exports.groupedPattern = groupedPattern;
|
|
31
|
+
exports.hslKeys = hslKeys;
|
|
32
|
+
exports.prefixPattern = prefixPattern;
|
|
33
|
+
exports.rgbKeys = rgbKeys;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const anyPattern = /^#?([a-f0-9]{3}){1,2}$/i;
|
|
2
|
+
const defaultHex = "000000";
|
|
3
|
+
const defaultHsl = {
|
|
4
|
+
hue: 0,
|
|
5
|
+
lightness: 0,
|
|
6
|
+
saturation: 0
|
|
7
|
+
};
|
|
8
|
+
const defaultRgb = {
|
|
9
|
+
blue: 0,
|
|
10
|
+
green: 0,
|
|
11
|
+
red: 0
|
|
12
|
+
};
|
|
13
|
+
const groupedPattern = /^#?([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})$/i;
|
|
14
|
+
const hslKeys = /* @__PURE__ */ new Set([
|
|
15
|
+
"hue",
|
|
16
|
+
"lightness",
|
|
17
|
+
"saturation"
|
|
18
|
+
]);
|
|
19
|
+
const prefixPattern = /^#/;
|
|
20
|
+
const rgbKeys = /* @__PURE__ */ new Set(["blue", "green", "red"]);
|
|
21
|
+
|
|
22
|
+
export { anyPattern, defaultHex, defaultHsl, defaultRgb, groupedPattern, hslKeys, prefixPattern, rgbKeys };
|