@oscarpalmer/atoms 0.107.0 → 0.108.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/group-by.cjs +2 -3
- package/dist/array/group-by.js +2 -3
- package/dist/array/index.cjs +2 -0
- package/dist/array/index.js +2 -1
- package/dist/array/sort.cjs +1 -2
- package/dist/array/sort.js +1 -2
- package/dist/array/to-map.cjs +6 -5
- package/dist/array/to-map.js +6 -5
- package/dist/array/to-record.cjs +2 -3
- package/dist/array/to-record.js +2 -3
- package/dist/array/to-set.cjs +11 -0
- package/dist/array/to-set.js +11 -0
- package/dist/atoms.full.js +34 -19
- package/dist/color/index.cjs +1 -2
- package/dist/color/index.js +1 -2
- package/dist/index.cjs +2 -0
- package/dist/index.js +2 -1
- package/dist/internal/array/chunk.cjs +1 -1
- package/dist/internal/array/chunk.js +1 -1
- package/dist/internal/array/compact.cjs +1 -1
- package/dist/internal/array/compact.js +1 -1
- package/dist/internal/array/find.cjs +1 -1
- package/dist/internal/array/find.js +1 -1
- package/dist/internal/array/group.cjs +1 -1
- package/dist/internal/array/group.js +1 -1
- package/dist/internal/math/aggregate.cjs +2 -2
- package/dist/internal/math/aggregate.js +2 -2
- package/dist/internal/number.cjs +1 -3
- package/dist/internal/number.js +1 -3
- package/dist/internal/value/compare.cjs +1 -2
- package/dist/internal/value/compare.js +1 -2
- package/dist/internal/value/misc.cjs +1 -2
- package/dist/internal/value/misc.js +1 -2
- package/dist/sized.cjs +1 -2
- package/dist/sized.js +1 -2
- package/dist/string/case.cjs +1 -4
- package/dist/string/case.js +1 -4
- package/dist/string/misc.cjs +1 -1
- package/dist/string/misc.js +1 -1
- package/dist/string/template.cjs +1 -2
- package/dist/string/template.js +1 -2
- package/dist/touch.js +1 -2
- package/dist/value/merge.cjs +1 -1
- package/dist/value/merge.js +1 -1
- package/dist/value/partial.cjs +1 -1
- package/dist/value/partial.js +1 -1
- package/package.json +1 -1
- package/src/array/group-by.ts +151 -166
- package/src/array/index.ts +1 -0
- package/src/array/to-map.ts +208 -212
- package/src/array/to-record.ts +198 -214
- package/src/array/to-set.ts +52 -0
- package/src/internal/array/chunk.ts +2 -2
- package/src/internal/array/compact.ts +1 -1
- package/src/internal/array/find.ts +1 -1
- package/src/internal/array/group.ts +1 -1
- package/src/internal/math/aggregate.ts +2 -2
- package/src/value/merge.ts +1 -1
- package/src/value/partial.ts +1 -1
- package/types/array/group-by.d.cts +95 -98
- package/types/array/group-by.d.ts +96 -98
- package/types/array/index.d.cts +306 -295
- package/types/array/index.d.ts +1 -0
- package/types/array/to-map.d.cts +101 -104
- package/types/array/to-map.d.ts +102 -104
- package/types/array/to-record.d.cts +101 -104
- package/types/array/to-record.d.ts +102 -104
- package/types/array/to-set.d.cts +28 -0
- package/types/array/to-set.d.ts +21 -0
- package/types/index.d.cts +306 -295
package/dist/array/group-by.cjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const require_internal_array_group = require("../internal/array/group.cjs");
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
2
|
+
var groupBy = ((array, first, second) => require_internal_array_group.groupValues(array, first, second, false));
|
|
3
|
+
groupBy.arrays = ((array, first, second) => require_internal_array_group.groupValues(array, first, second, true));
|
|
5
4
|
exports.groupBy = groupBy;
|
package/dist/array/group-by.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { groupValues } from "../internal/array/group.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
2
|
+
var groupBy = ((array, first, second) => groupValues(array, first, second, false));
|
|
3
|
+
groupBy.arrays = ((array, first, second) => groupValues(array, first, second, true));
|
|
5
4
|
export { groupBy };
|
package/dist/array/index.cjs
CHANGED
|
@@ -15,6 +15,7 @@ const require_array_sort = require("./sort.cjs");
|
|
|
15
15
|
const require_array_splice = require("./splice.cjs");
|
|
16
16
|
const require_array_to_map = require("./to-map.cjs");
|
|
17
17
|
const require_array_to_record = require("./to-record.cjs");
|
|
18
|
+
const require_array_to_set = require("./to-set.cjs");
|
|
18
19
|
const require_array_unique = require("./unique.cjs");
|
|
19
20
|
exports.chunk = require_internal_array_chunk.chunk;
|
|
20
21
|
exports.compact = require_internal_array_compact.compact;
|
|
@@ -33,4 +34,5 @@ exports.sort = require_array_sort.sort;
|
|
|
33
34
|
exports.splice = require_array_splice.splice;
|
|
34
35
|
exports.toMap = require_array_to_map.toMap;
|
|
35
36
|
exports.toRecord = require_array_to_record.toRecord;
|
|
37
|
+
exports.toSet = require_array_to_set.toSet;
|
|
36
38
|
exports.unique = require_array_unique.unique;
|
package/dist/array/index.js
CHANGED
|
@@ -15,5 +15,6 @@ import { sort } from "./sort.js";
|
|
|
15
15
|
import { splice } from "./splice.js";
|
|
16
16
|
import { toMap } from "./to-map.js";
|
|
17
17
|
import { toRecord } from "./to-record.js";
|
|
18
|
+
import { toSet } from "./to-set.js";
|
|
18
19
|
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 };
|
|
20
|
+
export { chunk, compact, count, exists, filter, find, flatten, getArray, groupBy, indexOf, insert, push, shuffle, sort, splice, toMap, toRecord, toSet, unique };
|
package/dist/array/sort.cjs
CHANGED
|
@@ -19,8 +19,7 @@ function getSorter(value, modifier) {
|
|
|
19
19
|
function sort(array, first, second) {
|
|
20
20
|
if (!Array.isArray(array)) return [];
|
|
21
21
|
if (array.length < 2) return array;
|
|
22
|
-
const
|
|
23
|
-
const modifier = direction === "asc" ? 1 : -1;
|
|
22
|
+
const modifier = (first === true || second === true ? "desc" : "asc") === "asc" ? 1 : -1;
|
|
24
23
|
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
24
|
const { length } = sorters;
|
|
26
25
|
if (length === 0) return array.sort((first$1, second$1) => require_internal_value_compare.compare(first$1, second$1) * modifier);
|
package/dist/array/sort.js
CHANGED
|
@@ -19,8 +19,7 @@ function getSorter(value, modifier) {
|
|
|
19
19
|
function sort(array, first, second) {
|
|
20
20
|
if (!Array.isArray(array)) return [];
|
|
21
21
|
if (array.length < 2) return array;
|
|
22
|
-
const
|
|
23
|
-
const modifier = direction === "asc" ? 1 : -1;
|
|
22
|
+
const modifier = (first === true || second === true ? "desc" : "asc") === "asc" ? 1 : -1;
|
|
24
23
|
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
24
|
const { length } = sorters;
|
|
26
25
|
if (length === 0) return array.sort((first$1, second$1) => compare(first$1, second$1) * modifier);
|
package/dist/array/to-map.cjs
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
const require_internal_array_callbacks = require("../internal/array/callbacks.cjs");
|
|
2
|
-
function
|
|
2
|
+
function getMapValues(array, first, second, arrays) {
|
|
3
3
|
if (!Array.isArray(array)) return /* @__PURE__ */ new Map();
|
|
4
|
-
const asArrays = keyOrArrays === true || valueOrArrays === true || arrays === true;
|
|
5
|
-
const callbacks = require_internal_array_callbacks.getCallbacks(void 0, keyOrArrays, valueOrArrays);
|
|
6
|
-
const map = /* @__PURE__ */ new Map();
|
|
7
4
|
const { length } = array;
|
|
5
|
+
const callbacks = require_internal_array_callbacks.getCallbacks(void 0, first, second);
|
|
6
|
+
const map = /* @__PURE__ */ new Map();
|
|
8
7
|
for (let index = 0; index < length; index += 1) {
|
|
9
8
|
const item = array[index];
|
|
10
9
|
const key = callbacks?.keyed?.(item, index, array) ?? index;
|
|
11
10
|
const value = callbacks?.value?.(item, index, array) ?? item;
|
|
12
|
-
if (
|
|
11
|
+
if (arrays) {
|
|
13
12
|
const existing = map.get(key);
|
|
14
13
|
if (existing == null) map.set(key, [value]);
|
|
15
14
|
else existing.push(value);
|
|
@@ -17,4 +16,6 @@ function toMap(array, keyOrArrays, valueOrArrays, arrays) {
|
|
|
17
16
|
}
|
|
18
17
|
return map;
|
|
19
18
|
}
|
|
19
|
+
var toMap = ((array, first, second, arrays) => getMapValues(array, first, second, arrays));
|
|
20
|
+
toMap.arrays = ((array, first, second) => getMapValues(array, first, second, true));
|
|
20
21
|
exports.toMap = toMap;
|
package/dist/array/to-map.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { getCallbacks } from "../internal/array/callbacks.js";
|
|
2
|
-
function
|
|
2
|
+
function getMapValues(array, first, second, arrays) {
|
|
3
3
|
if (!Array.isArray(array)) return /* @__PURE__ */ new Map();
|
|
4
|
-
const asArrays = keyOrArrays === true || valueOrArrays === true || arrays === true;
|
|
5
|
-
const callbacks = getCallbacks(void 0, keyOrArrays, valueOrArrays);
|
|
6
|
-
const map = /* @__PURE__ */ new Map();
|
|
7
4
|
const { length } = array;
|
|
5
|
+
const callbacks = getCallbacks(void 0, first, second);
|
|
6
|
+
const map = /* @__PURE__ */ new Map();
|
|
8
7
|
for (let index = 0; index < length; index += 1) {
|
|
9
8
|
const item = array[index];
|
|
10
9
|
const key = callbacks?.keyed?.(item, index, array) ?? index;
|
|
11
10
|
const value = callbacks?.value?.(item, index, array) ?? item;
|
|
12
|
-
if (
|
|
11
|
+
if (arrays) {
|
|
13
12
|
const existing = map.get(key);
|
|
14
13
|
if (existing == null) map.set(key, [value]);
|
|
15
14
|
else existing.push(value);
|
|
@@ -17,4 +16,6 @@ function toMap(array, keyOrArrays, valueOrArrays, arrays) {
|
|
|
17
16
|
}
|
|
18
17
|
return map;
|
|
19
18
|
}
|
|
19
|
+
var toMap = ((array, first, second, arrays) => getMapValues(array, first, second, arrays));
|
|
20
|
+
toMap.arrays = ((array, first, second) => getMapValues(array, first, second, true));
|
|
20
21
|
export { toMap };
|
package/dist/array/to-record.cjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const require_internal_array_group = require("../internal/array/group.cjs");
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
2
|
+
var toRecord = ((array, first, second) => require_internal_array_group.groupValues(array, first, second, false));
|
|
3
|
+
toRecord.arrays = ((array, first, second) => require_internal_array_group.groupValues(array, first, second, true));
|
|
5
4
|
exports.toRecord = toRecord;
|
package/dist/array/to-record.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { groupValues } from "../internal/array/group.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
2
|
+
var toRecord = ((array, first, second) => groupValues(array, first, second, false));
|
|
3
|
+
toRecord.arrays = ((array, first, second) => groupValues(array, first, second, true));
|
|
5
4
|
export { toRecord };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const require_internal_array_callbacks = require("../internal/array/callbacks.cjs");
|
|
2
|
+
function toSet(array, value) {
|
|
3
|
+
if (!Array.isArray(array)) return /* @__PURE__ */ new Set();
|
|
4
|
+
const callbacks = require_internal_array_callbacks.getCallbacks(void 0, void 0, value);
|
|
5
|
+
if (callbacks?.value == null) return new Set(array);
|
|
6
|
+
const { length } = array;
|
|
7
|
+
const set = /* @__PURE__ */ new Set();
|
|
8
|
+
for (let index = 0; index < length; index += 1) set.add(callbacks.value(array[index], index, array));
|
|
9
|
+
return set;
|
|
10
|
+
}
|
|
11
|
+
exports.toSet = toSet;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { getCallbacks } from "../internal/array/callbacks.js";
|
|
2
|
+
function toSet(array, value) {
|
|
3
|
+
if (!Array.isArray(array)) return /* @__PURE__ */ new Set();
|
|
4
|
+
const callbacks = getCallbacks(void 0, void 0, value);
|
|
5
|
+
if (callbacks?.value == null) return new Set(array);
|
|
6
|
+
const { length } = array;
|
|
7
|
+
const set = /* @__PURE__ */ new Set();
|
|
8
|
+
for (let index = 0; index < length; index += 1) set.add(callbacks.value(array[index], index, array));
|
|
9
|
+
return set;
|
|
10
|
+
}
|
|
11
|
+
export { toSet };
|
package/dist/atoms.full.js
CHANGED
|
@@ -11,8 +11,8 @@ function chunk(array, size) {
|
|
|
11
11
|
if (array.length === 0) {
|
|
12
12
|
return [];
|
|
13
13
|
}
|
|
14
|
-
const actualSize = typeof size === 'number' && size > 0 && size <= 5_000 ? size : 5_000;
|
|
15
14
|
const { length } = array;
|
|
15
|
+
const actualSize = typeof size === 'number' && size > 0 && size <= 5_000 ? size : 5_000;
|
|
16
16
|
if (length <= actualSize) {
|
|
17
17
|
return [array];
|
|
18
18
|
}
|
|
@@ -29,8 +29,8 @@ function compact(array, strict) {
|
|
|
29
29
|
if (!Array.isArray(array)) {
|
|
30
30
|
return [];
|
|
31
31
|
}
|
|
32
|
-
const isStrict = strict ?? false;
|
|
33
32
|
const { length } = array;
|
|
33
|
+
const isStrict = strict ?? false;
|
|
34
34
|
const compacted = [];
|
|
35
35
|
for (let index = 0; index < length; index += 1) {
|
|
36
36
|
const item = array[index];
|
|
@@ -209,9 +209,9 @@ function findValues(type, array, parameters, count) {
|
|
|
209
209
|
if (array.length === 0) {
|
|
210
210
|
return [];
|
|
211
211
|
}
|
|
212
|
+
const { length } = array;
|
|
212
213
|
const { bool, key, value } = getParameters(parameters);
|
|
213
214
|
const callbacks = getCallbacks(bool, key);
|
|
214
|
-
const { length } = array;
|
|
215
215
|
if (type === 'unique' && callbacks?.keyed == null && length >= 100) {
|
|
216
216
|
return [...new Set(array)];
|
|
217
217
|
}
|
|
@@ -319,9 +319,9 @@ function groupValues(array, key, value, arrays) {
|
|
|
319
319
|
if (!Array.isArray(array) || array.length === 0) {
|
|
320
320
|
return {};
|
|
321
321
|
}
|
|
322
|
+
const { length } = array;
|
|
322
323
|
const callbacks = getCallbacks(undefined, key, value);
|
|
323
324
|
const record = {};
|
|
324
|
-
const { length } = array;
|
|
325
325
|
for (let index = 0; index < length; index += 1) {
|
|
326
326
|
const item = array[index];
|
|
327
327
|
const keyed = callbacks?.keyed?.(item, index, array) ?? index;
|
|
@@ -342,9 +342,8 @@ function groupValues(array, key, value, arrays) {
|
|
|
342
342
|
return record;
|
|
343
343
|
}
|
|
344
344
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
}
|
|
345
|
+
const groupBy = ((array, first, second) => groupValues(array, first, second, false));
|
|
346
|
+
groupBy.arrays = ((array, first, second) => groupValues(array, first, second, true));
|
|
348
347
|
|
|
349
348
|
function indexOf(array, ...parameters) {
|
|
350
349
|
return findValue('index', array, parameters);
|
|
@@ -395,8 +394,8 @@ function push(array, pushed) {
|
|
|
395
394
|
}
|
|
396
395
|
|
|
397
396
|
function aggregate(type, array, key) {
|
|
398
|
-
const
|
|
399
|
-
if (
|
|
397
|
+
const length = Array.isArray(array) ? array.length : 0;
|
|
398
|
+
if (length === 0) {
|
|
400
399
|
return {
|
|
401
400
|
count: 0,
|
|
402
401
|
value: Number.NaN,
|
|
@@ -727,19 +726,18 @@ function splice(array, start, deleteCountOrItems, items) {
|
|
|
727
726
|
return insertValues('splice', array, typeof deleteCountOrItems === 'number' ? items : deleteCountOrItems, start, typeof deleteCountOrItems === 'number' ? deleteCountOrItems : 0);
|
|
728
727
|
}
|
|
729
728
|
|
|
730
|
-
function
|
|
729
|
+
function getMapValues(array, first, second, arrays) {
|
|
731
730
|
if (!Array.isArray(array)) {
|
|
732
731
|
return new Map();
|
|
733
732
|
}
|
|
734
|
-
const asArrays = keyOrArrays === true || valueOrArrays === true || arrays === true;
|
|
735
|
-
const callbacks = getCallbacks(undefined, keyOrArrays, valueOrArrays);
|
|
736
|
-
const map = new Map();
|
|
737
733
|
const { length } = array;
|
|
734
|
+
const callbacks = getCallbacks(undefined, first, second);
|
|
735
|
+
const map = new Map();
|
|
738
736
|
for (let index = 0; index < length; index += 1) {
|
|
739
737
|
const item = array[index];
|
|
740
738
|
const key = callbacks?.keyed?.(item, index, array) ?? index;
|
|
741
739
|
const value = callbacks?.value?.(item, index, array) ?? item;
|
|
742
|
-
if (
|
|
740
|
+
if (arrays) {
|
|
743
741
|
const existing = map.get(key);
|
|
744
742
|
if (existing == null) {
|
|
745
743
|
map.set(key, [value]);
|
|
@@ -754,9 +752,26 @@ function toMap(array, keyOrArrays, valueOrArrays, arrays) {
|
|
|
754
752
|
}
|
|
755
753
|
return map;
|
|
756
754
|
}
|
|
755
|
+
const toMap = ((array, first, second, arrays) => getMapValues(array, first, second, arrays));
|
|
756
|
+
toMap.arrays = ((array, first, second) => getMapValues(array, first, second, true));
|
|
757
|
+
|
|
758
|
+
const toRecord = ((array, first, second) => groupValues(array, first, second, false));
|
|
759
|
+
toRecord.arrays = ((array, first, second) => groupValues(array, first, second, true));
|
|
757
760
|
|
|
758
|
-
function
|
|
759
|
-
|
|
761
|
+
function toSet(array, value) {
|
|
762
|
+
if (!Array.isArray(array)) {
|
|
763
|
+
return new Set();
|
|
764
|
+
}
|
|
765
|
+
const callbacks = getCallbacks(undefined, undefined, value);
|
|
766
|
+
if (callbacks?.value == null) {
|
|
767
|
+
return new Set(array);
|
|
768
|
+
}
|
|
769
|
+
const { length } = array;
|
|
770
|
+
const set = new Set();
|
|
771
|
+
for (let index = 0; index < length; index += 1) {
|
|
772
|
+
set.add(callbacks.value(array[index], index, array));
|
|
773
|
+
}
|
|
774
|
+
return set;
|
|
760
775
|
}
|
|
761
776
|
|
|
762
777
|
function unique(array, key) {
|
|
@@ -2744,9 +2759,9 @@ function mergeValues(values, options, prefix) {
|
|
|
2744
2759
|
if (actual.length === 1) {
|
|
2745
2760
|
return actual[0];
|
|
2746
2761
|
}
|
|
2762
|
+
const { length } = actual;
|
|
2747
2763
|
const isArray = actual.every(Array.isArray);
|
|
2748
2764
|
const result = (isArray ? [] : {});
|
|
2749
|
-
const { length } = actual;
|
|
2750
2765
|
for (let outerIndex = 0; outerIndex < length; outerIndex += 1) {
|
|
2751
2766
|
const item = actual[outerIndex];
|
|
2752
2767
|
const keys = Object.keys(item);
|
|
@@ -2786,8 +2801,8 @@ function partial(value, keys) {
|
|
|
2786
2801
|
keys.length === 0) {
|
|
2787
2802
|
return {};
|
|
2788
2803
|
}
|
|
2789
|
-
const result = {};
|
|
2790
2804
|
const { length } = keys;
|
|
2805
|
+
const result = {};
|
|
2791
2806
|
for (let index = 0; index < length; index += 1) {
|
|
2792
2807
|
const key = keys[index];
|
|
2793
2808
|
result[key] = value[key];
|
|
@@ -2869,4 +2884,4 @@ function unsmush(value) {
|
|
|
2869
2884
|
return unsmushed;
|
|
2870
2885
|
}
|
|
2871
2886
|
|
|
2872
|
-
export { SizedMap, SizedSet, average, between, camelCase, capitalize, chunk, clamp, clone, compact, compare, count, createUuid, debounce, diff, emitter, equal, exists, filter, find, flatten$1 as flatten, fromQuery, getArray, getColor, getForegroundColor, getHSLColor, getHexColor, getNumber, getRGBColor, getRandomBoolean, getRandomCharacters, getRandomColor, getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems, getString, getValue, groupBy, indexOf, insert, isArrayOrPlainObject, isColor, isEmpty, isHSLColor, isHexColor, isKey, isNullable, isNullableOrEmpty, isNullableOrWhitespace, isNumber, isNumerical, isObject$1 as isObject, isPlainObject, isPrimitive, isRGBColor, isTypedArray, join, kebabCase, logger, max, memoize, merge, min, noop, parse, partial, pascalCase, push, round, setValue, shuffle, smush, snakeCase, sort, splice, sum, template, throttle, titleCase, toMap, toQuery, toRecord, truncate, unique, unsmush, words };
|
|
2887
|
+
export { SizedMap, SizedSet, average, between, camelCase, capitalize, chunk, clamp, clone, compact, compare, count, createUuid, debounce, diff, emitter, equal, exists, filter, find, flatten$1 as flatten, fromQuery, getArray, getColor, getForegroundColor, getHSLColor, getHexColor, getNumber, getRGBColor, getRandomBoolean, getRandomCharacters, getRandomColor, getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems, getString, getValue, groupBy, indexOf, insert, isArrayOrPlainObject, isColor, isEmpty, isHSLColor, isHexColor, isKey, isNullable, isNullableOrEmpty, isNullableOrWhitespace, isNumber, isNumerical, isObject$1 as isObject, isPlainObject, isPrimitive, isRGBColor, isTypedArray, join, kebabCase, logger, max, memoize, merge, min, noop, parse, partial, pascalCase, push, round, setValue, shuffle, smush, snakeCase, sort, splice, sum, template, throttle, titleCase, toMap, toQuery, toRecord, toSet, truncate, unique, unsmush, words };
|
package/dist/color/index.cjs
CHANGED
|
@@ -46,8 +46,7 @@ function getColor(value) {
|
|
|
46
46
|
return require_color_is.isColor(value) ? value : new Color(value);
|
|
47
47
|
}
|
|
48
48
|
function getForegroundColor(value) {
|
|
49
|
-
const
|
|
50
|
-
const { blue, green, red } = original.rgb;
|
|
49
|
+
const { blue, green, red } = getColor(value).rgb;
|
|
51
50
|
const values = [
|
|
52
51
|
blue / 255,
|
|
53
52
|
green / 255,
|
package/dist/color/index.js
CHANGED
|
@@ -46,8 +46,7 @@ function getColor(value) {
|
|
|
46
46
|
return isColor(value) ? value : new Color(value);
|
|
47
47
|
}
|
|
48
48
|
function getForegroundColor(value) {
|
|
49
|
-
const
|
|
50
|
-
const { blue, green, red } = original.rgb;
|
|
49
|
+
const { blue, green, red } = getColor(value).rgb;
|
|
51
50
|
const values = [
|
|
52
51
|
blue / 255,
|
|
53
52
|
green / 255,
|
package/dist/index.cjs
CHANGED
|
@@ -31,6 +31,7 @@ const require_array_sort = require("./array/sort.cjs");
|
|
|
31
31
|
const require_array_splice = require("./array/splice.cjs");
|
|
32
32
|
const require_array_to_map = require("./array/to-map.cjs");
|
|
33
33
|
const require_array_to_record = require("./array/to-record.cjs");
|
|
34
|
+
const require_array_to_set = require("./array/to-set.cjs");
|
|
34
35
|
const require_array_unique = require("./array/unique.cjs");
|
|
35
36
|
require("./array/index.cjs");
|
|
36
37
|
const require_color_is = require("./color/is.cjs");
|
|
@@ -133,6 +134,7 @@ exports.titleCase = require_string_case.titleCase;
|
|
|
133
134
|
exports.toMap = require_array_to_map.toMap;
|
|
134
135
|
exports.toQuery = require_query.toQuery;
|
|
135
136
|
exports.toRecord = require_array_to_record.toRecord;
|
|
137
|
+
exports.toSet = require_array_to_set.toSet;
|
|
136
138
|
exports.truncate = require_string_misc.truncate;
|
|
137
139
|
exports.unique = require_array_unique.unique;
|
|
138
140
|
exports.unsmush = require_value_unsmush.unsmush;
|
package/dist/index.js
CHANGED
|
@@ -31,6 +31,7 @@ import { sort } from "./array/sort.js";
|
|
|
31
31
|
import { splice } from "./array/splice.js";
|
|
32
32
|
import { toMap } from "./array/to-map.js";
|
|
33
33
|
import { toRecord } from "./array/to-record.js";
|
|
34
|
+
import { toSet } from "./array/to-set.js";
|
|
34
35
|
import { unique } from "./array/unique.js";
|
|
35
36
|
import "./array/index.js";
|
|
36
37
|
import { isColor, isHSLColor, isHexColor, isRGBColor } from "./color/is.js";
|
|
@@ -49,4 +50,4 @@ import { partial } from "./value/partial.js";
|
|
|
49
50
|
import { smush } from "./value/smush.js";
|
|
50
51
|
import { unsmush } from "./value/unsmush.js";
|
|
51
52
|
import "./value/index.js";
|
|
52
|
-
export { SizedMap, SizedSet, average, between, camelCase, capitalize, chunk, clamp, clone, compact, compare, count, createUuid, debounce, diff, emitter, equal, exists, filter, find, flatten, fromQuery, getArray, getColor, getForegroundColor, getHSLColor, getHexColor, getNumber, getRGBColor, getRandomBoolean, getRandomCharacters, getRandomColor, getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems, getString, getValue, groupBy, indexOf, insert, isArrayOrPlainObject, isColor, isEmpty, isHSLColor, isHexColor, isKey, isNullable, isNullableOrEmpty, isNullableOrWhitespace, isNumber, isNumerical, isObject, isPlainObject, isPrimitive, isRGBColor, isTypedArray, join, kebabCase, logger, max, memoize, merge, min, noop, parse, partial, pascalCase, push, round, setValue, shuffle, smush, snakeCase, sort, splice, sum, template, throttle, titleCase, toMap, toQuery, toRecord, truncate, unique, unsmush, words };
|
|
53
|
+
export { SizedMap, SizedSet, average, between, camelCase, capitalize, chunk, clamp, clone, compact, compare, count, createUuid, debounce, diff, emitter, equal, exists, filter, find, flatten, fromQuery, getArray, getColor, getForegroundColor, getHSLColor, getHexColor, getNumber, getRGBColor, getRandomBoolean, getRandomCharacters, getRandomColor, getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems, getString, getValue, groupBy, indexOf, insert, isArrayOrPlainObject, isColor, isEmpty, isHSLColor, isHexColor, isKey, isNullable, isNullableOrEmpty, isNullableOrWhitespace, isNumber, isNumerical, isObject, isPlainObject, isPrimitive, isRGBColor, isTypedArray, join, kebabCase, logger, max, memoize, merge, min, noop, parse, partial, pascalCase, push, round, setValue, shuffle, smush, snakeCase, sort, splice, sum, template, throttle, titleCase, toMap, toQuery, toRecord, toSet, truncate, unique, unsmush, words };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
function chunk(array, size) {
|
|
2
2
|
if (!Array.isArray(array)) return [];
|
|
3
3
|
if (array.length === 0) return [];
|
|
4
|
-
const actualSize = typeof size === "number" && size > 0 && size <= 5e3 ? size : 5e3;
|
|
5
4
|
const { length } = array;
|
|
5
|
+
const actualSize = typeof size === "number" && size > 0 && size <= 5e3 ? size : 5e3;
|
|
6
6
|
if (length <= actualSize) return [array];
|
|
7
7
|
const chunks = [];
|
|
8
8
|
let index = 0;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
function chunk(array, size) {
|
|
2
2
|
if (!Array.isArray(array)) return [];
|
|
3
3
|
if (array.length === 0) return [];
|
|
4
|
-
const actualSize = typeof size === "number" && size > 0 && size <= 5e3 ? size : 5e3;
|
|
5
4
|
const { length } = array;
|
|
5
|
+
const actualSize = typeof size === "number" && size > 0 && size <= 5e3 ? size : 5e3;
|
|
6
6
|
if (length <= actualSize) return [array];
|
|
7
7
|
const chunks = [];
|
|
8
8
|
let index = 0;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
function compact(array, strict) {
|
|
2
2
|
if (!Array.isArray(array)) return [];
|
|
3
|
-
const isStrict = strict ?? false;
|
|
4
3
|
const { length } = array;
|
|
4
|
+
const isStrict = strict ?? false;
|
|
5
5
|
const compacted = [];
|
|
6
6
|
for (let index = 0; index < length; index += 1) {
|
|
7
7
|
const item = array[index];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
function compact(array, strict) {
|
|
2
2
|
if (!Array.isArray(array)) return [];
|
|
3
|
-
const isStrict = strict ?? false;
|
|
4
3
|
const { length } = array;
|
|
4
|
+
const isStrict = strict ?? false;
|
|
5
5
|
const compacted = [];
|
|
6
6
|
for (let index = 0; index < length; index += 1) {
|
|
7
7
|
const item = array[index];
|
|
@@ -18,9 +18,9 @@ function findValue(type, array, parameters) {
|
|
|
18
18
|
function findValues(type, array, parameters, count) {
|
|
19
19
|
if (!Array.isArray(array)) return count ? void 0 : [];
|
|
20
20
|
if (array.length === 0) return [];
|
|
21
|
+
const { length } = array;
|
|
21
22
|
const { bool, key, value } = getParameters(parameters);
|
|
22
23
|
const callbacks = require_internal_array_callbacks.getCallbacks(bool, key);
|
|
23
|
-
const { length } = array;
|
|
24
24
|
if (type === "unique" && callbacks?.keyed == null && length >= 100) return [...new Set(array)];
|
|
25
25
|
if (callbacks?.bool != null) return array.filter(callbacks.bool);
|
|
26
26
|
if (type === "all" && key == null) return array.filter((item) => item === value);
|
|
@@ -18,9 +18,9 @@ function findValue(type, array, parameters) {
|
|
|
18
18
|
function findValues(type, array, parameters, count) {
|
|
19
19
|
if (!Array.isArray(array)) return count ? void 0 : [];
|
|
20
20
|
if (array.length === 0) return [];
|
|
21
|
+
const { length } = array;
|
|
21
22
|
const { bool, key, value } = getParameters(parameters);
|
|
22
23
|
const callbacks = getCallbacks(bool, key);
|
|
23
|
-
const { length } = array;
|
|
24
24
|
if (type === "unique" && callbacks?.keyed == null && length >= 100) return [...new Set(array)];
|
|
25
25
|
if (callbacks?.bool != null) return array.filter(callbacks.bool);
|
|
26
26
|
if (type === "all" && key == null) return array.filter((item) => item === value);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
const require_internal_array_callbacks = require("./callbacks.cjs");
|
|
2
2
|
function groupValues(array, key, value, arrays) {
|
|
3
3
|
if (!Array.isArray(array) || array.length === 0) return {};
|
|
4
|
+
const { length } = array;
|
|
4
5
|
const callbacks = require_internal_array_callbacks.getCallbacks(void 0, key, value);
|
|
5
6
|
const record = {};
|
|
6
|
-
const { length } = array;
|
|
7
7
|
for (let index = 0; index < length; index += 1) {
|
|
8
8
|
const item = array[index];
|
|
9
9
|
const keyed = callbacks?.keyed?.(item, index, array) ?? index;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { getCallbacks } from "./callbacks.js";
|
|
2
2
|
function groupValues(array, key, value, arrays) {
|
|
3
3
|
if (!Array.isArray(array) || array.length === 0) return {};
|
|
4
|
+
const { length } = array;
|
|
4
5
|
const callbacks = getCallbacks(void 0, key, value);
|
|
5
6
|
const record = {};
|
|
6
|
-
const { length } = array;
|
|
7
7
|
for (let index = 0; index < length; index += 1) {
|
|
8
8
|
const item = array[index];
|
|
9
9
|
const keyed = callbacks?.keyed?.(item, index, array) ?? index;
|
package/dist/internal/number.cjs
CHANGED
|
@@ -2,9 +2,7 @@ const require_internal_is = require("./is.cjs");
|
|
|
2
2
|
function between(value, minimum, maximum) {
|
|
3
3
|
if (!require_internal_is.isNumber(value) || !require_internal_is.isNumber(minimum) || !require_internal_is.isNumber(maximum)) return false;
|
|
4
4
|
if (minimum === maximum) return value === minimum;
|
|
5
|
-
|
|
6
|
-
const min = maximum > minimum ? minimum : maximum;
|
|
7
|
-
return value >= min && value <= max;
|
|
5
|
+
return value >= (maximum > minimum ? minimum : maximum) && value <= (maximum > minimum ? maximum : minimum);
|
|
8
6
|
}
|
|
9
7
|
function clamp(value, min, max, loop) {
|
|
10
8
|
if (!require_internal_is.isNumber(value) || !require_internal_is.isNumber(min) || !require_internal_is.isNumber(max)) return NaN;
|
package/dist/internal/number.js
CHANGED
|
@@ -2,9 +2,7 @@ import { isNumber } from "./is.js";
|
|
|
2
2
|
function between(value, minimum, maximum) {
|
|
3
3
|
if (!isNumber(value) || !isNumber(minimum) || !isNumber(maximum)) return false;
|
|
4
4
|
if (minimum === maximum) return value === minimum;
|
|
5
|
-
|
|
6
|
-
const min = maximum > minimum ? minimum : maximum;
|
|
7
|
-
return value >= min && value <= max;
|
|
5
|
+
return value >= (maximum > minimum ? minimum : maximum) && value <= (maximum > minimum ? maximum : minimum);
|
|
8
6
|
}
|
|
9
7
|
function clamp(value, min, max, loop) {
|
|
10
8
|
if (!isNumber(value) || !isNumber(min) || !isNumber(max)) return NaN;
|
|
@@ -33,8 +33,7 @@ function compareSymbols(first, second) {
|
|
|
33
33
|
}
|
|
34
34
|
function compareValue(first, second, compareStrings) {
|
|
35
35
|
const firstType = typeof first;
|
|
36
|
-
|
|
37
|
-
if (firstType === secondType && firstType in comparators) return comparators[firstType](first, second);
|
|
36
|
+
if (firstType === typeof second && firstType in comparators) return comparators[firstType](first, second);
|
|
38
37
|
if (first instanceof Date && second instanceof Date) return compareNumbers(first.getTime(), second.getTime());
|
|
39
38
|
if (compareStrings) return require_internal_string.getString(first).localeCompare(require_internal_string.getString(second));
|
|
40
39
|
}
|
|
@@ -33,8 +33,7 @@ function compareSymbols(first, second) {
|
|
|
33
33
|
}
|
|
34
34
|
function compareValue(first, second, compareStrings) {
|
|
35
35
|
const firstType = typeof first;
|
|
36
|
-
|
|
37
|
-
if (firstType === secondType && firstType in comparators) return comparators[firstType](first, second);
|
|
36
|
+
if (firstType === typeof second && firstType in comparators) return comparators[firstType](first, second);
|
|
38
37
|
if (first instanceof Date && second instanceof Date) return compareNumbers(first.getTime(), second.getTime());
|
|
39
38
|
if (compareStrings) return getString(first).localeCompare(getString(second));
|
|
40
39
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
const require_internal_string = require("../string.cjs");
|
|
2
2
|
function findKey(needle, haystack) {
|
|
3
3
|
const keys = Object.keys(haystack);
|
|
4
|
-
const
|
|
5
|
-
const index = normalized.indexOf(needle.toLowerCase());
|
|
4
|
+
const index = keys.map((key) => key.toLowerCase()).indexOf(needle.toLowerCase());
|
|
6
5
|
return index > -1 ? keys[index] : needle;
|
|
7
6
|
}
|
|
8
7
|
function getPaths(path, lowercase) {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { ignoreKey } from "../string.js";
|
|
2
2
|
function findKey(needle, haystack) {
|
|
3
3
|
const keys = Object.keys(haystack);
|
|
4
|
-
const
|
|
5
|
-
const index = normalized.indexOf(needle.toLowerCase());
|
|
4
|
+
const index = keys.map((key) => key.toLowerCase()).indexOf(needle.toLowerCase());
|
|
6
5
|
return index > -1 ? keys[index] : needle;
|
|
7
6
|
}
|
|
8
7
|
function getPaths(path, lowercase) {
|
package/dist/sized.cjs
CHANGED
|
@@ -56,8 +56,7 @@ var SizedSet = class extends Set {
|
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
58
|
function getMaximum(first, second) {
|
|
59
|
-
|
|
60
|
-
return require_internal_number.clamp(actual, 1, 2 ** 24);
|
|
59
|
+
return require_internal_number.clamp((typeof first === "number" ? first : typeof second === "number" ? second : void 0) ?? 2 ** 20, 1, 2 ** 24);
|
|
61
60
|
}
|
|
62
61
|
exports.SizedMap = SizedMap;
|
|
63
62
|
exports.SizedSet = SizedSet;
|
package/dist/sized.js
CHANGED
|
@@ -56,7 +56,6 @@ var SizedSet = class extends Set {
|
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
58
|
function getMaximum(first, second) {
|
|
59
|
-
|
|
60
|
-
return clamp(actual, 1, 2 ** 24);
|
|
59
|
+
return clamp((typeof first === "number" ? first : typeof second === "number" ? second : void 0) ?? 2 ** 20, 1, 2 ** 24);
|
|
61
60
|
}
|
|
62
61
|
export { SizedMap, SizedSet };
|
package/dist/string/case.cjs
CHANGED
|
@@ -25,10 +25,7 @@ function toCase(value, delimiter, capitalizeAny, capitalizeFirst) {
|
|
|
25
25
|
const partsLength = parts.length;
|
|
26
26
|
const result = [];
|
|
27
27
|
for (let partIndex = 0; partIndex < partsLength; partIndex += 1) {
|
|
28
|
-
const
|
|
29
|
-
const acronymParts = part.replace(acronymExpression, (full, one, two, three) => three === "s" ? full : `${one}-${two}${three}`);
|
|
30
|
-
const camelCaseParts = acronymParts.replace(camelCaseExpression, "$1-$2");
|
|
31
|
-
const items = camelCaseParts.split("-");
|
|
28
|
+
const items = parts[partIndex].replace(acronymExpression, (full, one, two, three) => three === "s" ? full : `${one}-${two}${three}`).replace(camelCaseExpression, "$1-$2").split("-");
|
|
32
29
|
const itemsLength = items.length;
|
|
33
30
|
const partResult = [];
|
|
34
31
|
let itemCount = 0;
|
package/dist/string/case.js
CHANGED
|
@@ -25,10 +25,7 @@ function toCase(value, delimiter, capitalizeAny, capitalizeFirst) {
|
|
|
25
25
|
const partsLength = parts.length;
|
|
26
26
|
const result = [];
|
|
27
27
|
for (let partIndex = 0; partIndex < partsLength; partIndex += 1) {
|
|
28
|
-
const
|
|
29
|
-
const acronymParts = part.replace(acronymExpression, (full, one, two, three) => three === "s" ? full : `${one}-${two}${three}`);
|
|
30
|
-
const camelCaseParts = acronymParts.replace(camelCaseExpression, "$1-$2");
|
|
31
|
-
const items = camelCaseParts.split("-");
|
|
28
|
+
const items = parts[partIndex].replace(acronymExpression, (full, one, two, three) => three === "s" ? full : `${one}-${two}${three}`).replace(camelCaseExpression, "$1-$2").split("-");
|
|
32
29
|
const itemsLength = items.length;
|
|
33
30
|
const partResult = [];
|
|
34
31
|
let itemCount = 0;
|
package/dist/string/misc.cjs
CHANGED
package/dist/string/misc.js
CHANGED
package/dist/string/template.cjs
CHANGED
|
@@ -9,8 +9,7 @@ function template(value, variables, options) {
|
|
|
9
9
|
return value.replace(pattern, (_, key) => {
|
|
10
10
|
if (values[key] != null) return values[key];
|
|
11
11
|
const value$1 = require_internal_value_get.getValue(variables, key, ignoreCase);
|
|
12
|
-
|
|
13
|
-
values[key] = nullish ? "" : require_internal_string.getString(value$1);
|
|
12
|
+
values[key] = value$1 == null ? "" : require_internal_string.getString(value$1);
|
|
14
13
|
return values[key];
|
|
15
14
|
});
|
|
16
15
|
}
|