@valkyriestudios/utils 12.36.0 → 12.38.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/array/groupBy.d.ts +3 -3
- package/array/join.d.ts +2 -2
- package/array/split.d.ts +3 -3
- package/caching/LRU.d.ts +16 -10
- package/{array → cjs/array}/groupBy.js +16 -4
- package/{array → cjs/array}/join.js +15 -3
- package/{array → cjs/array}/mapFnAsMap.js +1 -1
- package/{array → cjs/array}/split.js +16 -7
- package/cjs/caching/LRU.js +123 -0
- package/{caching → cjs/caching}/memoize.js +11 -5
- package/{date → cjs/date}/format.js +7 -7
- package/{date → cjs/date}/isFormat.js +5 -2
- package/cjs/formdata/toObject.js +92 -0
- package/{object → cjs/object}/pick.js +2 -2
- package/{string → cjs/string}/humanizeNumber.js +2 -2
- package/cjs/string/isNotEmpty.js +23 -0
- package/{string → cjs/string}/shorten.js +1 -1
- package/esm/array/dedupe.js +52 -0
- package/esm/array/groupBy.js +43 -0
- package/esm/array/index.js +14 -0
- package/esm/array/is.js +4 -0
- package/esm/array/isNotEmpty.js +4 -0
- package/esm/array/join.js +58 -0
- package/esm/array/mapFn.js +22 -0
- package/esm/array/mapFnAsMap.js +21 -0
- package/esm/array/mapKey.js +22 -0
- package/esm/array/mapKeyAsMap.js +22 -0
- package/esm/array/mapPrimitive.js +33 -0
- package/esm/array/shuffle.js +10 -0
- package/esm/array/sort.js +137 -0
- package/esm/array/split.js +43 -0
- package/esm/boolean/index.js +1 -0
- package/esm/boolean/is.js +4 -0
- package/esm/caching/LRU.js +116 -0
- package/esm/caching/index.js +3 -0
- package/esm/caching/memoize.js +37 -0
- package/esm/date/addUTC.js +41 -0
- package/esm/date/convertToDate.js +12 -0
- package/esm/date/diff.js +34 -0
- package/esm/date/endOfUTC.js +50 -0
- package/esm/date/format.js +241 -0
- package/esm/date/index.js +15 -0
- package/esm/date/is.js +4 -0
- package/esm/date/isFormat.js +118 -0
- package/esm/date/isLeap.js +9 -0
- package/esm/date/nowUnix.js +4 -0
- package/esm/date/nowUnixMs.js +4 -0
- package/esm/date/setTimeUTC.js +10 -0
- package/esm/date/startOfUTC.js +50 -0
- package/esm/date/toUTC.js +7 -0
- package/esm/date/toUnix.js +7 -0
- package/esm/deep/freeze.js +21 -0
- package/esm/deep/get.js +84 -0
- package/esm/deep/index.js +8 -0
- package/esm/deep/seal.js +21 -0
- package/esm/deep/set.js +50 -0
- package/esm/equal.js +67 -0
- package/esm/formdata/index.js +2 -0
- package/esm/formdata/is.js +4 -0
- package/esm/formdata/toObject.js +89 -0
- package/esm/function/debounce.js +39 -0
- package/esm/function/index.js +9 -0
- package/esm/function/is.js +4 -0
- package/esm/function/isAsync.js +4 -0
- package/esm/function/noop.js +2 -0
- package/esm/function/noopresolve.js +4 -0
- package/esm/function/noopreturn.js +4 -0
- package/esm/function/sleep.js +6 -0
- package/esm/hash/fnv1A.js +51 -0
- package/esm/hash/guid.js +31 -0
- package/esm/hash/index.js +2 -0
- package/esm/is.js +63 -0
- package/esm/modules/PubSub.js +187 -0
- package/esm/modules/Scheduler.js +343 -0
- package/esm/modules/index.js +2 -0
- package/esm/number/index.js +37 -0
- package/esm/number/is.js +4 -0
- package/esm/number/isAbove.js +4 -0
- package/esm/number/isAboveOrEqual.js +4 -0
- package/esm/number/isBelow.js +4 -0
- package/esm/number/isBelowOrEqual.js +4 -0
- package/esm/number/isBetween.js +7 -0
- package/esm/number/isInteger.js +4 -0
- package/esm/number/isIntegerAbove.js +4 -0
- package/esm/number/isIntegerAboveOrEqual.js +4 -0
- package/esm/number/isIntegerBelow.js +4 -0
- package/esm/number/isIntegerBelowOrEqual.js +4 -0
- package/esm/number/isIntegerBetween.js +7 -0
- package/esm/number/isNumericalNaN.js +4 -0
- package/esm/number/randomBetween.js +7 -0
- package/esm/number/randomIntBetween.js +7 -0
- package/esm/number/round.js +10 -0
- package/esm/number/toPercentage.js +9 -0
- package/esm/object/define.js +7 -0
- package/esm/object/index.js +7 -0
- package/esm/object/is.js +4 -0
- package/esm/object/isNotEmpty.js +9 -0
- package/esm/object/merge.js +31 -0
- package/esm/object/omit.js +30 -0
- package/esm/object/pick.js +33 -0
- package/esm/regexp/index.js +3 -0
- package/esm/regexp/is.js +4 -0
- package/esm/regexp/sanitize.js +7 -0
- package/esm/string/humanizeBytes.js +15 -0
- package/esm/string/humanizeNumber.js +40 -0
- package/esm/string/index.js +7 -0
- package/esm/string/is.js +4 -0
- package/esm/string/isBetween.js +12 -0
- package/esm/string/isNotEmpty.js +20 -0
- package/esm/string/shorten.js +18 -0
- package/formdata/toObject.d.ts +4 -0
- package/index.d.ts +20 -15
- package/package.json +193 -851
- package/caching/LRU.js +0 -72
- package/formdata/toObject.js +0 -70
- package/string/isNotEmpty.js +0 -9
- /package/{array → cjs/array}/dedupe.js +0 -0
- /package/{array → cjs/array}/index.js +0 -0
- /package/{array → cjs/array}/is.js +0 -0
- /package/{array → cjs/array}/isNotEmpty.js +0 -0
- /package/{array → cjs/array}/mapFn.js +0 -0
- /package/{array → cjs/array}/mapKey.js +0 -0
- /package/{array → cjs/array}/mapKeyAsMap.js +0 -0
- /package/{array → cjs/array}/mapPrimitive.js +0 -0
- /package/{array → cjs/array}/shuffle.js +0 -0
- /package/{array → cjs/array}/sort.js +0 -0
- /package/{boolean → cjs/boolean}/index.js +0 -0
- /package/{boolean → cjs/boolean}/is.js +0 -0
- /package/{caching → cjs/caching}/index.js +0 -0
- /package/{date → cjs/date}/addUTC.js +0 -0
- /package/{date → cjs/date}/convertToDate.js +0 -0
- /package/{date → cjs/date}/diff.js +0 -0
- /package/{date → cjs/date}/endOfUTC.js +0 -0
- /package/{date → cjs/date}/index.js +0 -0
- /package/{date → cjs/date}/is.js +0 -0
- /package/{date → cjs/date}/isLeap.js +0 -0
- /package/{date → cjs/date}/nowUnix.js +0 -0
- /package/{date → cjs/date}/nowUnixMs.js +0 -0
- /package/{date → cjs/date}/setTimeUTC.js +0 -0
- /package/{date → cjs/date}/startOfUTC.js +0 -0
- /package/{date → cjs/date}/toUTC.js +0 -0
- /package/{date → cjs/date}/toUnix.js +0 -0
- /package/{deep → cjs/deep}/freeze.js +0 -0
- /package/{deep → cjs/deep}/get.js +0 -0
- /package/{deep → cjs/deep}/index.js +0 -0
- /package/{deep → cjs/deep}/seal.js +0 -0
- /package/{deep → cjs/deep}/set.js +0 -0
- /package/{equal.js → cjs/equal.js} +0 -0
- /package/{formdata → cjs/formdata}/index.js +0 -0
- /package/{formdata → cjs/formdata}/is.js +0 -0
- /package/{function → cjs/function}/debounce.js +0 -0
- /package/{function → cjs/function}/index.js +0 -0
- /package/{function → cjs/function}/is.js +0 -0
- /package/{function → cjs/function}/isAsync.js +0 -0
- /package/{function → cjs/function}/noop.js +0 -0
- /package/{function → cjs/function}/noopresolve.js +0 -0
- /package/{function → cjs/function}/noopreturn.js +0 -0
- /package/{function → cjs/function}/sleep.js +0 -0
- /package/{hash → cjs/hash}/fnv1A.js +0 -0
- /package/{hash → cjs/hash}/guid.js +0 -0
- /package/{hash → cjs/hash}/index.js +0 -0
- /package/{is.js → cjs/is.js} +0 -0
- /package/{modules → cjs/modules}/PubSub.js +0 -0
- /package/{modules → cjs/modules}/Scheduler.js +0 -0
- /package/{modules → cjs/modules}/index.js +0 -0
- /package/{number → cjs/number}/index.js +0 -0
- /package/{number → cjs/number}/is.js +0 -0
- /package/{number → cjs/number}/isAbove.js +0 -0
- /package/{number → cjs/number}/isAboveOrEqual.js +0 -0
- /package/{number → cjs/number}/isBelow.js +0 -0
- /package/{number → cjs/number}/isBelowOrEqual.js +0 -0
- /package/{number → cjs/number}/isBetween.js +0 -0
- /package/{number → cjs/number}/isInteger.js +0 -0
- /package/{number → cjs/number}/isIntegerAbove.js +0 -0
- /package/{number → cjs/number}/isIntegerAboveOrEqual.js +0 -0
- /package/{number → cjs/number}/isIntegerBelow.js +0 -0
- /package/{number → cjs/number}/isIntegerBelowOrEqual.js +0 -0
- /package/{number → cjs/number}/isIntegerBetween.js +0 -0
- /package/{number → cjs/number}/isNumericalNaN.js +0 -0
- /package/{number → cjs/number}/randomBetween.js +0 -0
- /package/{number → cjs/number}/randomIntBetween.js +0 -0
- /package/{number → cjs/number}/round.js +0 -0
- /package/{number → cjs/number}/toPercentage.js +0 -0
- /package/{object → cjs/object}/define.js +0 -0
- /package/{object → cjs/object}/index.js +0 -0
- /package/{object → cjs/object}/is.js +0 -0
- /package/{object → cjs/object}/isNotEmpty.js +0 -0
- /package/{object → cjs/object}/merge.js +0 -0
- /package/{object → cjs/object}/omit.js +0 -0
- /package/{regexp → cjs/regexp}/index.js +0 -0
- /package/{regexp → cjs/regexp}/is.js +0 -0
- /package/{regexp → cjs/regexp}/sanitize.js +0 -0
- /package/{string → cjs/string}/humanizeBytes.js +0 -0
- /package/{string → cjs/string}/index.js +0 -0
- /package/{string → cjs/string}/is.js +0 -0
- /package/{string → cjs/string}/isBetween.js +0 -0
package/array/groupBy.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
type Handler<T> = (val: T) => string | number | boolean;
|
|
1
|
+
type Handler<T> = (val: T) => string | number | boolean | undefined;
|
|
2
2
|
/**
|
|
3
3
|
* Return a grouped object from an array.
|
|
4
4
|
* Take Note: This function will automatically filter out any non/empty objects from the array
|
|
@@ -15,8 +15,8 @@ type Handler<T> = (val: T) => string | number | boolean;
|
|
|
15
15
|
* true: [{tally: 20, name: 'Peter'}, {tally: 40, name: 'Jake'}],
|
|
16
16
|
* }
|
|
17
17
|
*
|
|
18
|
-
* @param {T[]}
|
|
18
|
+
* @param {T[]} val - Array or Set to group
|
|
19
19
|
* @param {Handler<T>|keyof T} handler - String or a function, determines what to group by
|
|
20
20
|
*/
|
|
21
|
-
declare function groupBy<T extends Record<string, any>>(
|
|
21
|
+
declare function groupBy<T extends Record<string, any>>(val: T[] | Set<T>, handler: Handler<T> | keyof T): Record<string, T[]>;
|
|
22
22
|
export { groupBy, groupBy as default };
|
package/array/join.d.ts
CHANGED
|
@@ -39,8 +39,8 @@ interface joinOptions {
|
|
|
39
39
|
/**
|
|
40
40
|
* Join an array of values while autofiltering any non-string/non-number elements
|
|
41
41
|
*
|
|
42
|
-
* @param {
|
|
42
|
+
* @param {T[]|Set<T>} val - Array or Set of values to join
|
|
43
43
|
* @param {joinOptions?} opts - Join options
|
|
44
44
|
*/
|
|
45
|
-
declare function join(val:
|
|
45
|
+
declare function join<T>(val: T[] | Set<T>, opts?: joinOptions): string;
|
|
46
46
|
export { join, join as default };
|
package/array/split.d.ts
CHANGED
|
@@ -2,16 +2,16 @@ type SplitOptions<T> = {
|
|
|
2
2
|
filter_fn?: (el: T) => boolean;
|
|
3
3
|
};
|
|
4
4
|
/**
|
|
5
|
-
* Splits the provided array in a set of batches according to the provided size
|
|
5
|
+
* Splits the provided array or set in a set of batches according to the provided size
|
|
6
6
|
* For Example:
|
|
7
7
|
* split([1, 2, 3, 4, 5], 2) -> [[1,2],[3,4],[5]]
|
|
8
8
|
*
|
|
9
9
|
* For Example w/ filter
|
|
10
10
|
* split([1, false, 3, 4, 5], 2, {filter_fn: el => isInteger(el)}) -> [[1, 3], [4, 5]]
|
|
11
11
|
*
|
|
12
|
-
* @param {
|
|
12
|
+
* @param {T[]|Set<T>} val - Array or Set to split
|
|
13
13
|
* @param {number} size - Size of batches
|
|
14
14
|
* @param {SplitOptions?} opts - Split options
|
|
15
15
|
*/
|
|
16
|
-
declare function split<T>(arr: T[]
|
|
16
|
+
declare function split<T>(arr: T[] | Set<T>, size: number, opts?: SplitOptions<T>): T[][];
|
|
17
17
|
export { split, split as default };
|
package/caching/LRU.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export type LRUCacheOptions = {
|
|
|
8
8
|
/**
|
|
9
9
|
* Least-Recently-Used (LRU) Cache
|
|
10
10
|
*/
|
|
11
|
-
declare class LRUCache<
|
|
11
|
+
declare class LRUCache<V> {
|
|
12
12
|
#private;
|
|
13
13
|
constructor(opts?: LRUCacheOptions);
|
|
14
14
|
/**
|
|
@@ -24,32 +24,38 @@ declare class LRUCache<K, V> {
|
|
|
24
24
|
/**
|
|
25
25
|
* Returns whether or not a key exists in cache
|
|
26
26
|
*
|
|
27
|
-
* @param {
|
|
27
|
+
* @param {string} key - Key to retrieve
|
|
28
28
|
*/
|
|
29
|
-
has(key:
|
|
29
|
+
has(key: string): boolean;
|
|
30
30
|
/**
|
|
31
31
|
* Retrieves a value from the cache
|
|
32
32
|
*
|
|
33
|
-
* @param {
|
|
34
|
-
* @returns {V | undefined} Either the found value or undefined
|
|
33
|
+
* @param {string} key - Key to retrieve
|
|
35
34
|
*/
|
|
36
|
-
get(key:
|
|
35
|
+
get(key: string): V | undefined;
|
|
37
36
|
/**
|
|
38
37
|
* Sets a value on to the cache
|
|
39
38
|
*
|
|
40
|
-
* @param {
|
|
39
|
+
* @param {string} key - Key to set
|
|
41
40
|
* @param {V} value - Value to set for the key
|
|
42
41
|
*/
|
|
43
|
-
set(key:
|
|
42
|
+
set(key: string, value: V): void;
|
|
44
43
|
/**
|
|
45
44
|
* Removes a single value from the cache
|
|
46
45
|
*
|
|
47
|
-
* @param {
|
|
46
|
+
* @param {string} key - Key to remove
|
|
48
47
|
*/
|
|
49
|
-
del(key:
|
|
48
|
+
del(key: string): void;
|
|
50
49
|
/**
|
|
51
50
|
* Clears all contents of the cache
|
|
52
51
|
*/
|
|
53
52
|
clear(): void;
|
|
53
|
+
/**
|
|
54
|
+
* MARK: Private
|
|
55
|
+
*/
|
|
56
|
+
private addToFront;
|
|
57
|
+
private removeNode;
|
|
58
|
+
private moveToFront;
|
|
59
|
+
private evictTail;
|
|
54
60
|
}
|
|
55
61
|
export { LRUCache, LRUCache as default };
|
|
@@ -5,9 +5,21 @@ exports.default = groupBy;
|
|
|
5
5
|
const isNotEmpty_1 = require("../object/isNotEmpty");
|
|
6
6
|
const FALLBACK = '_';
|
|
7
7
|
const defaultHandler = () => FALLBACK;
|
|
8
|
-
function groupBy(
|
|
9
|
-
|
|
8
|
+
function groupBy(val, handler) {
|
|
9
|
+
let normalized;
|
|
10
|
+
if (Array.isArray(val)) {
|
|
11
|
+
if (!val.length)
|
|
12
|
+
return {};
|
|
13
|
+
normalized = val;
|
|
14
|
+
}
|
|
15
|
+
else if (val instanceof Set) {
|
|
16
|
+
if (!val.size)
|
|
17
|
+
return {};
|
|
18
|
+
normalized = [...val];
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
10
21
|
return {};
|
|
22
|
+
}
|
|
11
23
|
const acc = {};
|
|
12
24
|
const n_handler = typeof handler === 'function'
|
|
13
25
|
? handler
|
|
@@ -16,8 +28,8 @@ function groupBy(arr, handler) {
|
|
|
16
28
|
: defaultHandler;
|
|
17
29
|
let key;
|
|
18
30
|
let el;
|
|
19
|
-
for (let i = 0; i <
|
|
20
|
-
el =
|
|
31
|
+
for (let i = 0; i < normalized.length; i++) {
|
|
32
|
+
el = normalized[i];
|
|
21
33
|
if (!(0, isNotEmpty_1.isNotEmptyObject)(el))
|
|
22
34
|
continue;
|
|
23
35
|
key = n_handler(el);
|
|
@@ -6,8 +6,20 @@ const round_1 = require("../number/round");
|
|
|
6
6
|
const isIntegerAboveOrEqual_1 = require("../number/isIntegerAboveOrEqual");
|
|
7
7
|
const SPACE_RGX = /(\s)+/g;
|
|
8
8
|
function join(val, opts) {
|
|
9
|
-
|
|
9
|
+
let normalized;
|
|
10
|
+
if (Array.isArray(val)) {
|
|
11
|
+
if (!val.length)
|
|
12
|
+
return '';
|
|
13
|
+
normalized = val;
|
|
14
|
+
}
|
|
15
|
+
else if (val instanceof Set) {
|
|
16
|
+
if (!val.size)
|
|
17
|
+
return '';
|
|
18
|
+
normalized = [...val];
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
10
21
|
return '';
|
|
22
|
+
}
|
|
11
23
|
const DELIM = typeof opts?.delim === 'string' ? opts.delim : ' ';
|
|
12
24
|
const DEDUPE = opts?.dedupe === true ? new Set() : null;
|
|
13
25
|
const VALTRIM = opts?.valtrim ?? true;
|
|
@@ -15,8 +27,8 @@ function join(val, opts) {
|
|
|
15
27
|
const VALROUND = (0, isIntegerAboveOrEqual_1.isIntegerAboveOrEqual)(opts?.valround, 0) ? opts.valround : false;
|
|
16
28
|
let result = '';
|
|
17
29
|
let has_val = false;
|
|
18
|
-
for (let i = 0; i <
|
|
19
|
-
const el =
|
|
30
|
+
for (let i = 0; i < normalized.length; i++) {
|
|
31
|
+
const el = normalized[i];
|
|
20
32
|
let n_el;
|
|
21
33
|
if (typeof el === 'string') {
|
|
22
34
|
const trimmed = el.trim();
|
|
@@ -15,7 +15,7 @@ function mapFnAsMap(arr, fn, opts) {
|
|
|
15
15
|
if (Object.prototype.toString.call(el) !== '[object Object]')
|
|
16
16
|
continue;
|
|
17
17
|
const hash = fn(el);
|
|
18
|
-
if (Number.isFinite(hash) || (typeof hash === 'string' && hash.
|
|
18
|
+
if (Number.isFinite(hash) || (typeof hash === 'string' && hash.length > 0)) {
|
|
19
19
|
const transformed = TRANSFORM_FN ? TRANSFORM_FN(el) : el;
|
|
20
20
|
map.set(hash, MERGE && map.has(hash) ? (0, merge_1.merge)(map.get(hash), transformed, { union: true }) : transformed);
|
|
21
21
|
}
|
|
@@ -3,18 +3,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.split = split;
|
|
4
4
|
exports.default = split;
|
|
5
5
|
function split(arr, size, opts) {
|
|
6
|
-
if (!
|
|
7
|
-
!Number.isInteger(size) ||
|
|
6
|
+
if (!Number.isInteger(size) ||
|
|
8
7
|
size <= 0)
|
|
9
|
-
throw new Error('split requires
|
|
8
|
+
throw new Error('split requires a positive integer size');
|
|
9
|
+
let normalized;
|
|
10
|
+
if (Array.isArray(arr)) {
|
|
11
|
+
normalized = arr;
|
|
12
|
+
}
|
|
13
|
+
else if (arr instanceof Set) {
|
|
14
|
+
normalized = [...arr];
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
throw new Error('split requires an array or set');
|
|
18
|
+
}
|
|
10
19
|
const FILTER_FN = typeof opts?.filter_fn === 'function' ? opts?.filter_fn : false;
|
|
11
20
|
const result = [];
|
|
12
21
|
let cursor = [];
|
|
13
22
|
let ticker = 0;
|
|
14
|
-
const len =
|
|
23
|
+
const len = normalized.length;
|
|
15
24
|
if (FILTER_FN) {
|
|
16
25
|
for (let i = 0; i < len; i++) {
|
|
17
|
-
const el =
|
|
26
|
+
const el = normalized[i];
|
|
18
27
|
if (FILTER_FN && !FILTER_FN(el))
|
|
19
28
|
continue;
|
|
20
29
|
ticker++;
|
|
@@ -29,8 +38,8 @@ function split(arr, size, opts) {
|
|
|
29
38
|
result.push(cursor);
|
|
30
39
|
}
|
|
31
40
|
else {
|
|
32
|
-
for (let i = 0; i <
|
|
33
|
-
result.push(
|
|
41
|
+
for (let i = 0; i < len; i += size) {
|
|
42
|
+
result.push(normalized.slice(i, i + size));
|
|
34
43
|
}
|
|
35
44
|
}
|
|
36
45
|
return result;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
var _LRUCache_map, _LRUCache_head, _LRUCache_tail, _LRUCache_max_size, _LRUCache_size;
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.default = exports.LRUCache = void 0;
|
|
19
|
+
const is_1 = __importDefault(require("../object/is"));
|
|
20
|
+
const isIntegerAbove_1 = __importDefault(require("../number/isIntegerAbove"));
|
|
21
|
+
class LRUCache {
|
|
22
|
+
constructor(opts = {}) {
|
|
23
|
+
_LRUCache_map.set(this, void 0);
|
|
24
|
+
_LRUCache_head.set(this, null);
|
|
25
|
+
_LRUCache_tail.set(this, null);
|
|
26
|
+
_LRUCache_max_size.set(this, void 0);
|
|
27
|
+
_LRUCache_size.set(this, 0);
|
|
28
|
+
const { max_size = 100 } = (0, is_1.default)(opts) ? opts : {};
|
|
29
|
+
__classPrivateFieldSet(this, _LRUCache_map, Object.create(null), "f");
|
|
30
|
+
__classPrivateFieldSet(this, _LRUCache_max_size, (0, isIntegerAbove_1.default)(max_size, 0) ? max_size : 100, "f");
|
|
31
|
+
}
|
|
32
|
+
get max_size() {
|
|
33
|
+
return __classPrivateFieldGet(this, _LRUCache_max_size, "f");
|
|
34
|
+
}
|
|
35
|
+
set max_size(max_size) {
|
|
36
|
+
if (!(0, isIntegerAbove_1.default)(max_size, 0))
|
|
37
|
+
throw new Error('max_size must be a positive integer');
|
|
38
|
+
__classPrivateFieldSet(this, _LRUCache_max_size, max_size, "f");
|
|
39
|
+
while (__classPrivateFieldGet(this, _LRUCache_size, "f") > max_size)
|
|
40
|
+
this.evictTail();
|
|
41
|
+
}
|
|
42
|
+
has(key) {
|
|
43
|
+
return key in __classPrivateFieldGet(this, _LRUCache_map, "f");
|
|
44
|
+
}
|
|
45
|
+
get(key) {
|
|
46
|
+
const node = __classPrivateFieldGet(this, _LRUCache_map, "f")[key];
|
|
47
|
+
if (!node)
|
|
48
|
+
return undefined;
|
|
49
|
+
this.moveToFront(node);
|
|
50
|
+
return node.value;
|
|
51
|
+
}
|
|
52
|
+
set(key, value) {
|
|
53
|
+
var _a;
|
|
54
|
+
let node = __classPrivateFieldGet(this, _LRUCache_map, "f")[key];
|
|
55
|
+
if (node !== undefined) {
|
|
56
|
+
node.value = value;
|
|
57
|
+
this.moveToFront(node);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
node = { key, value, prev: null, next: null };
|
|
61
|
+
__classPrivateFieldGet(this, _LRUCache_map, "f")[key] = node;
|
|
62
|
+
this.addToFront(node);
|
|
63
|
+
__classPrivateFieldSet(this, _LRUCache_size, (_a = __classPrivateFieldGet(this, _LRUCache_size, "f"), _a++, _a), "f");
|
|
64
|
+
if (__classPrivateFieldGet(this, _LRUCache_tail, "f") && __classPrivateFieldGet(this, _LRUCache_size, "f") > __classPrivateFieldGet(this, _LRUCache_max_size, "f")) {
|
|
65
|
+
this.evictTail();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
del(key) {
|
|
70
|
+
var _a;
|
|
71
|
+
const node = __classPrivateFieldGet(this, _LRUCache_map, "f")[key];
|
|
72
|
+
if (!node)
|
|
73
|
+
return;
|
|
74
|
+
this.removeNode(node);
|
|
75
|
+
delete __classPrivateFieldGet(this, _LRUCache_map, "f")[key];
|
|
76
|
+
__classPrivateFieldSet(this, _LRUCache_size, (_a = __classPrivateFieldGet(this, _LRUCache_size, "f"), _a--, _a), "f");
|
|
77
|
+
}
|
|
78
|
+
clear() {
|
|
79
|
+
__classPrivateFieldSet(this, _LRUCache_map, Object.create(null), "f");
|
|
80
|
+
__classPrivateFieldSet(this, _LRUCache_head, null, "f");
|
|
81
|
+
__classPrivateFieldSet(this, _LRUCache_tail, null, "f");
|
|
82
|
+
__classPrivateFieldSet(this, _LRUCache_size, 0, "f");
|
|
83
|
+
}
|
|
84
|
+
addToFront(node) {
|
|
85
|
+
node.next = __classPrivateFieldGet(this, _LRUCache_head, "f");
|
|
86
|
+
node.prev = null;
|
|
87
|
+
if (__classPrivateFieldGet(this, _LRUCache_head, "f")) {
|
|
88
|
+
__classPrivateFieldGet(this, _LRUCache_head, "f").prev = node;
|
|
89
|
+
}
|
|
90
|
+
__classPrivateFieldSet(this, _LRUCache_head, node, "f");
|
|
91
|
+
if (!__classPrivateFieldGet(this, _LRUCache_tail, "f")) {
|
|
92
|
+
__classPrivateFieldSet(this, _LRUCache_tail, node, "f");
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
removeNode(node) {
|
|
96
|
+
if (node.prev)
|
|
97
|
+
node.prev.next = node.next;
|
|
98
|
+
else
|
|
99
|
+
__classPrivateFieldSet(this, _LRUCache_head, node.next, "f");
|
|
100
|
+
if (node.next)
|
|
101
|
+
node.next.prev = node.prev;
|
|
102
|
+
else
|
|
103
|
+
__classPrivateFieldSet(this, _LRUCache_tail, node.prev, "f");
|
|
104
|
+
node.prev = null;
|
|
105
|
+
node.next = null;
|
|
106
|
+
}
|
|
107
|
+
moveToFront(node) {
|
|
108
|
+
if (__classPrivateFieldGet(this, _LRUCache_head, "f") === node)
|
|
109
|
+
return;
|
|
110
|
+
this.removeNode(node);
|
|
111
|
+
this.addToFront(node);
|
|
112
|
+
}
|
|
113
|
+
evictTail() {
|
|
114
|
+
var _a;
|
|
115
|
+
const old_tail = __classPrivateFieldGet(this, _LRUCache_tail, "f");
|
|
116
|
+
this.removeNode(old_tail);
|
|
117
|
+
delete __classPrivateFieldGet(this, _LRUCache_map, "f")[old_tail.key];
|
|
118
|
+
__classPrivateFieldSet(this, _LRUCache_size, (_a = __classPrivateFieldGet(this, _LRUCache_size, "f"), _a--, _a), "f");
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
exports.LRUCache = LRUCache;
|
|
122
|
+
exports.default = LRUCache;
|
|
123
|
+
_LRUCache_map = new WeakMap(), _LRUCache_head = new WeakMap(), _LRUCache_tail = new WeakMap(), _LRUCache_max_size = new WeakMap(), _LRUCache_size = new WeakMap();
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.memoize = memoize;
|
|
4
7
|
exports.default = memoize;
|
|
5
|
-
const isAsync_1 = require("../function/isAsync");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
+
const isAsync_1 = __importDefault(require("../function/isAsync"));
|
|
9
|
+
const fnv1A_1 = __importDefault(require("../hash/fnv1A"));
|
|
10
|
+
const isIntegerAbove_1 = __importDefault(require("../number/isIntegerAbove"));
|
|
11
|
+
const LRU_1 = __importDefault(require("./LRU"));
|
|
8
12
|
function memoize(fn, resolver, cache_duration_ms = false, cache_max_size = 100) {
|
|
9
13
|
const cache_duration = (0, isIntegerAbove_1.default)(cache_duration_ms, 0) ? cache_duration_ms : false;
|
|
10
14
|
const cache = new LRU_1.default({ max_size: cache_max_size });
|
|
11
15
|
const isResolverFn = typeof resolver === 'function';
|
|
12
16
|
const memoized = (0, isAsync_1.default)(fn)
|
|
13
17
|
? async function (...args) {
|
|
14
|
-
|
|
18
|
+
let key = isResolverFn ? resolver(...args) : args[0];
|
|
19
|
+
key = typeof key === 'string' ? key : Number.isFinite(key) ? String(key) : String((0, fnv1A_1.default)(key));
|
|
15
20
|
const cached_val = cache.get(key);
|
|
16
21
|
const now = Date.now();
|
|
17
22
|
if (cached_val !== undefined && (cache_duration === false || (now - cached_val.ts) < cache_duration)) {
|
|
@@ -22,7 +27,8 @@ function memoize(fn, resolver, cache_duration_ms = false, cache_max_size = 100)
|
|
|
22
27
|
return result;
|
|
23
28
|
}
|
|
24
29
|
: function (...args) {
|
|
25
|
-
|
|
30
|
+
let key = isResolverFn ? resolver(...args) : args[0];
|
|
31
|
+
key = typeof key === 'string' ? key : Number.isFinite(key) ? String(key) : String((0, fnv1A_1.default)(key));
|
|
26
32
|
const cached_val = cache.get(key);
|
|
27
33
|
const now = Date.now();
|
|
28
34
|
if (cached_val !== undefined && (cache_duration === false || (now - cached_val.ts) < cache_duration)) {
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.format = format;
|
|
4
7
|
exports.default = format;
|
|
5
8
|
const convertToDate_1 = require("./convertToDate");
|
|
6
|
-
const LRU_1 = require("../caching/LRU");
|
|
9
|
+
const LRU_1 = __importDefault(require("../caching/LRU"));
|
|
7
10
|
const WEEK_STARTS = {
|
|
8
11
|
mon: 'mon',
|
|
9
12
|
sun: 'sun',
|
|
@@ -17,10 +20,6 @@ try {
|
|
|
17
20
|
}
|
|
18
21
|
catch {
|
|
19
22
|
}
|
|
20
|
-
finally {
|
|
21
|
-
if (typeof DEFAULT_TZ !== 'string')
|
|
22
|
-
DEFAULT_TZ = 'UTC';
|
|
23
|
-
}
|
|
24
23
|
const ESCAPE_RGX = /\[[\s\S]+?]/g;
|
|
25
24
|
const intl_formatters = new LRU_1.default({ max_size: 100 });
|
|
26
25
|
const spec_cache = new LRU_1.default({ max_size: 100 });
|
|
@@ -218,9 +217,10 @@ format.getLocale = function () {
|
|
|
218
217
|
return DEFAULT_LOCALE;
|
|
219
218
|
};
|
|
220
219
|
format.setLocale = function (locale) {
|
|
221
|
-
|
|
220
|
+
const normalized = typeof locale === 'string' ? locale.trim() : false;
|
|
221
|
+
if (!normalized)
|
|
222
222
|
throw new Error('format/setLocale: locale should be a string');
|
|
223
|
-
DEFAULT_LOCALE =
|
|
223
|
+
DEFAULT_LOCALE = normalized;
|
|
224
224
|
};
|
|
225
225
|
format.getZone = function () {
|
|
226
226
|
return DEFAULT_TZ;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.isDateFormat = isDateFormat;
|
|
4
7
|
exports.default = isDateFormat;
|
|
5
|
-
const LRU_1 = require("../caching/LRU");
|
|
8
|
+
const LRU_1 = __importDefault(require("../caching/LRU"));
|
|
6
9
|
const SPECIAL_CHARS = /[.*+?^${}()|[\]\\]/g;
|
|
7
10
|
const TOKENS = [
|
|
8
11
|
['YYYY', /\d{4}/.source, (raw, context) => {
|
|
@@ -93,7 +96,7 @@ function compileSpec(spec, is_chunk = false) {
|
|
|
93
96
|
}
|
|
94
97
|
function isDateFormat(input, spec) {
|
|
95
98
|
if (typeof input !== 'string')
|
|
96
|
-
|
|
99
|
+
return false;
|
|
97
100
|
if (typeof spec !== 'string')
|
|
98
101
|
throw new TypeError('isDateFormat: spec must be a string');
|
|
99
102
|
const { tokens, rgx } = compileSpec(SPEC_ALIASES[spec] || spec);
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toObject = toObject;
|
|
4
|
+
exports.default = toObject;
|
|
5
|
+
const isFormat_1 = require("../date/isFormat");
|
|
6
|
+
const RGX_TOKENS = /[^.[\]]+/g;
|
|
7
|
+
function assign(acc, rawkey, value, single) {
|
|
8
|
+
let cursor = acc;
|
|
9
|
+
const keys = rawkey.match(RGX_TOKENS);
|
|
10
|
+
const keys_len = keys.length;
|
|
11
|
+
for (let i = 0; i < keys_len; i++) {
|
|
12
|
+
const key = keys[i];
|
|
13
|
+
switch (key) {
|
|
14
|
+
case '__proto__':
|
|
15
|
+
case 'constructor':
|
|
16
|
+
case 'prototype':
|
|
17
|
+
return;
|
|
18
|
+
default: {
|
|
19
|
+
if (i < (keys_len - 1)) {
|
|
20
|
+
const n_key = Array.isArray(cursor) ? Number(key) : key;
|
|
21
|
+
if (!cursor[n_key])
|
|
22
|
+
cursor[n_key] = Number.isInteger(+keys[i + 1]) ? [] : {};
|
|
23
|
+
cursor = cursor[n_key];
|
|
24
|
+
}
|
|
25
|
+
else if (!(key in cursor) || (single && single.has(key))) {
|
|
26
|
+
cursor[key] = value;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
const cursor_val = cursor[key];
|
|
30
|
+
if (Array.isArray(cursor_val)) {
|
|
31
|
+
cursor_val.push(value);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
cursor[key] = [cursor_val, value];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function toObject(form, config) {
|
|
42
|
+
if (!(form instanceof FormData))
|
|
43
|
+
throw new Error('formdata/toObject: Value is not an instance of FormData');
|
|
44
|
+
const set = config?.raw === true ? null : new Set(Array.isArray(config?.raw) ? config?.raw : []);
|
|
45
|
+
const set_guard = !!(set && set.size > 0);
|
|
46
|
+
const single = Array.isArray(config?.single) ? new Set(config.single) : null;
|
|
47
|
+
const nBool = config?.normalize_bool !== false;
|
|
48
|
+
const nNull = config?.normalize_null !== false;
|
|
49
|
+
const nDate = config?.normalize_date !== false;
|
|
50
|
+
const nNumber = config?.normalize_number !== false;
|
|
51
|
+
const acc = {};
|
|
52
|
+
if (set === null) {
|
|
53
|
+
form.forEach((value, key) => assign(acc, key, value, single));
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
form.forEach((value, key) => {
|
|
57
|
+
if (set_guard && set.has(key))
|
|
58
|
+
return assign(acc, key, value, single);
|
|
59
|
+
switch (value) {
|
|
60
|
+
case 'true':
|
|
61
|
+
case 'TRUE':
|
|
62
|
+
case 'True':
|
|
63
|
+
assign(acc, key, nBool ? true : value, single);
|
|
64
|
+
break;
|
|
65
|
+
case 'false':
|
|
66
|
+
case 'FALSE':
|
|
67
|
+
case 'False':
|
|
68
|
+
assign(acc, key, nBool ? false : value, single);
|
|
69
|
+
break;
|
|
70
|
+
case 'null':
|
|
71
|
+
case 'NULL':
|
|
72
|
+
case 'Null':
|
|
73
|
+
assign(acc, key, nNull ? null : value, single);
|
|
74
|
+
break;
|
|
75
|
+
default: {
|
|
76
|
+
if (typeof value === 'string' && value.length) {
|
|
77
|
+
if (nNumber) {
|
|
78
|
+
const nVal = Number(value);
|
|
79
|
+
if (!isNaN(nVal))
|
|
80
|
+
return assign(acc, key, nVal, single);
|
|
81
|
+
}
|
|
82
|
+
if (nDate &&
|
|
83
|
+
(0, isFormat_1.isDateFormat)(value, 'ISO'))
|
|
84
|
+
return assign(acc, key, new Date(value), single);
|
|
85
|
+
}
|
|
86
|
+
assign(acc, key, value, single);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return acc;
|
|
92
|
+
}
|
|
@@ -21,12 +21,12 @@ function pick(obj, keys) {
|
|
|
21
21
|
const parts_len = parts.length;
|
|
22
22
|
let cursor = map;
|
|
23
23
|
for (let y = 0; y < parts_len - 1; y++) {
|
|
24
|
-
const part = parts[y]
|
|
24
|
+
const part = parts[y];
|
|
25
25
|
if (!(part in cursor))
|
|
26
26
|
cursor[part] = {};
|
|
27
27
|
cursor = cursor[part];
|
|
28
28
|
}
|
|
29
|
-
cursor[parts[parts_len - 1]
|
|
29
|
+
cursor[parts[parts_len - 1]] = val;
|
|
30
30
|
}
|
|
31
31
|
else if (key in obj) {
|
|
32
32
|
map[key] = obj[key];
|
|
@@ -6,7 +6,7 @@ const round_1 = require("../number/round");
|
|
|
6
6
|
const DEFAULT_UNITS = ['', 'k', 'm', 'b', 't', 'q'];
|
|
7
7
|
function humanizeNumber(val, options = {}) {
|
|
8
8
|
const DELIM = typeof options?.delim === 'string' ? options.delim : ',';
|
|
9
|
-
const SEPARATOR = typeof options?.separator === 'string' && options.separator.
|
|
9
|
+
const SEPARATOR = typeof options?.separator === 'string' && options.separator.length ? options.separator : '.';
|
|
10
10
|
const PRECISION = Number.isInteger(options?.precision) && options.precision >= 0 ? options.precision : 2;
|
|
11
11
|
const DIVIDER = Number.isInteger(options?.divider) && options.divider >= 2 ? options.divider : 1000;
|
|
12
12
|
const REAL = options?.real === true;
|
|
@@ -15,7 +15,7 @@ function humanizeNumber(val, options = {}) {
|
|
|
15
15
|
: options?.units === false
|
|
16
16
|
? false
|
|
17
17
|
: DEFAULT_UNITS;
|
|
18
|
-
let normalized = typeof val === 'string' ? parseFloat(val
|
|
18
|
+
let normalized = typeof val === 'string' ? parseFloat(val) : val;
|
|
19
19
|
if (!Number.isFinite(normalized) || normalized === 0)
|
|
20
20
|
return UNITS ? '0' + UNITS[0] : '0';
|
|
21
21
|
if (REAL)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isNotEmptyString = isNotEmptyString;
|
|
4
|
+
exports.default = isNotEmptyString;
|
|
5
|
+
function isNotEmptyString(val, trimmed = true) {
|
|
6
|
+
if (typeof val !== 'string')
|
|
7
|
+
return false;
|
|
8
|
+
if (trimmed) {
|
|
9
|
+
for (let i = 0; i < val.length; i++) {
|
|
10
|
+
switch (val[i]) {
|
|
11
|
+
case ' ':
|
|
12
|
+
case '\t':
|
|
13
|
+
case '\n':
|
|
14
|
+
case '\r':
|
|
15
|
+
break;
|
|
16
|
+
default:
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
return val.length > 0;
|
|
23
|
+
}
|
|
@@ -17,5 +17,5 @@ function shorten(val, length, postfix = '...', truncate_words = true) {
|
|
|
17
17
|
while (end && sanitized[end] !== ' ' && sanitized[end - 1] !== ' ') {
|
|
18
18
|
end--;
|
|
19
19
|
}
|
|
20
|
-
return sanitized.substring(0, end).
|
|
20
|
+
return sanitized.substring(0, end).trimEnd() + postfix;
|
|
21
21
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const REPL_NAN = 'nan';
|
|
2
|
+
const REPL_TRUE = 'true';
|
|
3
|
+
const REPL_FALSE = 'false';
|
|
4
|
+
const REPL_UNDEF = 'undefined';
|
|
5
|
+
const REPL_NULL = 'null';
|
|
6
|
+
function getTypeString(el) {
|
|
7
|
+
switch (typeof el) {
|
|
8
|
+
case 'string':
|
|
9
|
+
return el;
|
|
10
|
+
case 'number':
|
|
11
|
+
return Number.isNaN(el) || !Number.isFinite(el) ? REPL_NAN : String(el);
|
|
12
|
+
case 'boolean':
|
|
13
|
+
return el ? REPL_TRUE : REPL_FALSE;
|
|
14
|
+
case 'undefined':
|
|
15
|
+
return REPL_UNDEF;
|
|
16
|
+
case 'object':
|
|
17
|
+
if (el === null) {
|
|
18
|
+
return REPL_NULL;
|
|
19
|
+
}
|
|
20
|
+
else if (Array.isArray(el) || el.toString() === '[object Object]') {
|
|
21
|
+
return JSON.stringify(el);
|
|
22
|
+
}
|
|
23
|
+
else if (el instanceof RegExp) {
|
|
24
|
+
return el.toString();
|
|
25
|
+
}
|
|
26
|
+
else if (el instanceof Date) {
|
|
27
|
+
return String(el.getTime());
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return '';
|
|
31
|
+
}
|
|
32
|
+
function dedupe(val, opts) {
|
|
33
|
+
if (!Array.isArray(val))
|
|
34
|
+
return [];
|
|
35
|
+
const FILTER_FN = opts?.filter_fn;
|
|
36
|
+
const set = new Set();
|
|
37
|
+
const acc = [];
|
|
38
|
+
let hash;
|
|
39
|
+
const len = val.length;
|
|
40
|
+
for (let i = 0; i < len; i++) {
|
|
41
|
+
const el = val[i];
|
|
42
|
+
if (FILTER_FN && !FILTER_FN(el))
|
|
43
|
+
continue;
|
|
44
|
+
hash = getTypeString(el);
|
|
45
|
+
if (!set.has(hash)) {
|
|
46
|
+
set.add(hash);
|
|
47
|
+
acc.push(el);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return acc;
|
|
51
|
+
}
|
|
52
|
+
export { dedupe, dedupe as default };
|