@oscarpalmer/atoms 0.74.1 → 0.76.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/js/array/chunk.cjs +18 -0
- package/dist/js/array/{chunk.mjs → chunk.js} +2 -2
- package/dist/js/array/compact.cjs +6 -0
- package/dist/js/array/{compact.mjs → compact.js} +0 -1
- package/dist/js/array/count.cjs +14 -0
- package/dist/js/array/count.js +14 -0
- package/dist/js/array/exists.cjs +14 -0
- package/dist/js/array/exists.js +14 -0
- package/dist/js/array/filter.cjs +14 -0
- package/dist/js/array/filter.js +14 -0
- package/dist/js/array/find.cjs +14 -0
- package/dist/js/array/find.js +14 -0
- package/dist/js/array/group-by.cjs +35 -0
- package/dist/js/array/group-by.js +35 -0
- package/dist/js/array/index-of.cjs +14 -0
- package/dist/js/array/index-of.js +14 -0
- package/dist/js/array/index.cjs +40 -0
- package/dist/js/array/index.js +34 -381
- package/dist/js/array/insert.cjs +31 -0
- package/dist/js/array/insert.js +31 -0
- package/dist/js/array/models.cjs +1 -0
- package/dist/js/array/models.js +1 -0
- package/dist/js/array/shuffle.cjs +13 -0
- package/dist/js/array/{shuffle.mjs → shuffle.js} +2 -3
- package/dist/js/array/sort.cjs +53 -0
- package/dist/js/array/{sort.mjs → sort.js} +13 -9
- package/dist/js/array/splice.cjs +14 -0
- package/dist/js/array/splice.js +14 -0
- package/dist/js/array/to-map.cjs +27 -0
- package/dist/js/array/to-map.js +27 -0
- package/dist/js/array/to-record.cjs +12 -0
- package/dist/js/array/to-record.js +12 -0
- package/dist/js/array/unique.cjs +7 -0
- package/dist/js/array/unique.js +7 -0
- package/dist/js/colour/base.cjs +18 -0
- package/dist/js/colour/{base.mjs → base.js} +4 -3
- package/dist/js/colour/functions.cjs +96 -0
- package/dist/js/colour/{functions.mjs → functions.js} +18 -19
- package/dist/js/colour/hex.cjs +56 -0
- package/dist/js/colour/{hex.mjs → hex.js} +34 -15
- package/dist/js/colour/hsl.cjs +85 -0
- package/dist/js/colour/{hsl.mjs → hsl.js} +40 -12
- package/dist/js/colour/index.cjs +29 -0
- package/dist/js/colour/index.js +14 -272
- package/dist/js/colour/is.cjs +27 -0
- package/dist/js/colour/{is.mjs → is.js} +7 -6
- package/dist/js/colour/rgb.cjs +87 -0
- package/dist/js/colour/{rgb.mjs → rgb.js} +43 -12
- package/dist/js/{emitter.mjs → emitter.cjs} +88 -56
- package/dist/js/emitter.js +85 -56
- package/dist/js/{function.mjs → function.cjs} +66 -46
- package/dist/js/function.js +61 -48
- package/dist/js/index.cjs +136 -0
- package/dist/js/index.js +133 -1724
- package/dist/js/internal/array/callbacks.cjs +23 -0
- package/dist/js/internal/array/callbacks.js +23 -0
- package/dist/js/internal/array/find.cjs +51 -0
- package/dist/js/internal/array/find.js +51 -0
- package/dist/js/internal/value/handle.cjs +21 -0
- package/dist/js/internal/{value-handle.mjs → value/handle.js} +0 -1
- package/dist/js/{is.mjs → is.cjs} +17 -18
- package/dist/js/is.js +15 -27
- package/dist/js/logger.cjs +108 -0
- package/dist/js/logger.js +44 -8
- package/dist/js/{math.mjs → math.cjs} +7 -8
- package/dist/js/math.js +4 -5
- package/dist/js/models.cjs +1 -0
- package/dist/js/models.js +1 -0
- package/dist/js/{number.mjs → number.cjs} +8 -8
- package/dist/js/number.js +5 -5
- package/dist/js/{query.mjs → query.cjs} +18 -18
- package/dist/js/query.js +17 -86
- package/dist/js/{queue.mjs → queue.cjs} +12 -13
- package/dist/js/queue.js +9 -10
- package/dist/js/{random.mjs → random.cjs} +14 -21
- package/dist/js/random.js +9 -26
- package/dist/js/{sized.mjs → sized.cjs} +68 -33
- package/dist/js/sized.js +66 -38
- package/dist/js/string/case.cjs +41 -0
- package/dist/js/string/{case.mjs → case.js} +13 -9
- package/dist/js/string/index.cjs +59 -0
- package/dist/js/string/index.js +30 -100
- package/dist/js/string/template.cjs +21 -0
- package/dist/js/string/{template.mjs → template.js} +4 -5
- package/dist/js/{touch.mjs → touch.cjs} +4 -7
- package/dist/js/touch.js +3 -5
- package/dist/js/value/clone.cjs +76 -0
- package/dist/js/value/{clone.mjs → clone.js} +5 -6
- package/dist/js/value/compare.cjs +59 -0
- package/dist/js/value/{compare.mjs → compare.js} +4 -6
- package/dist/js/value/diff.cjs +75 -0
- package/dist/js/value/{diff.mjs → diff.js} +13 -11
- package/dist/js/value/equal.cjs +106 -0
- package/dist/js/value/{equal.mjs → equal.js} +13 -8
- package/dist/js/value/get.cjs +21 -0
- package/dist/js/value/{get.mjs → get.js} +9 -4
- package/dist/js/value/index.cjs +30 -0
- package/dist/js/value/index.js +19 -510
- package/dist/js/value/merge.cjs +35 -0
- package/dist/js/value/{merge.mjs → merge.js} +7 -6
- package/dist/js/value/set.cjs +25 -0
- package/dist/js/value/{set.mjs → set.js} +3 -4
- package/dist/js/value/smush.cjs +26 -0
- package/dist/js/value/{smush.mjs → smush.js} +3 -4
- package/dist/js/value/unsmush.cjs +39 -0
- package/dist/js/value/{unsmush.mjs → unsmush.js} +10 -7
- package/package.json +50 -47
- package/src/js/array/chunk.ts +6 -5
- package/src/js/array/compact.ts +8 -10
- package/src/js/array/count.ts +39 -19
- package/src/js/array/exists.ts +39 -15
- package/src/js/array/filter.ts +42 -20
- package/src/js/array/find.ts +45 -20
- package/src/js/array/group-by.ts +158 -27
- package/src/js/array/index-of.ts +40 -18
- package/src/js/array/index.ts +10 -9
- package/src/js/array/insert.ts +28 -14
- package/src/js/array/models.ts +18 -15
- package/src/js/array/shuffle.ts +3 -3
- package/src/js/array/sort.ts +32 -34
- package/src/js/array/splice.ts +22 -26
- package/src/js/array/to-map.ts +133 -45
- package/src/js/array/to-record.ts +137 -39
- package/src/js/array/unique.ts +20 -15
- package/src/js/colour/base.ts +3 -3
- package/src/js/colour/functions.ts +4 -6
- package/src/js/colour/hex.ts +5 -5
- package/src/js/colour/hsl.ts +18 -12
- package/src/js/colour/index.ts +1 -1
- package/src/js/colour/is.ts +3 -3
- package/src/js/colour/rgb.ts +17 -11
- package/src/js/emitter.ts +12 -9
- package/src/js/function.ts +17 -17
- package/src/js/index.ts +16 -16
- package/src/js/internal/array/callbacks.ts +33 -0
- package/src/js/internal/{array-find.ts → array/find.ts} +23 -24
- package/src/js/internal/{value-handle.ts → value/handle.ts} +1 -1
- package/src/js/is.ts +2 -2
- package/src/js/logger.ts +14 -14
- package/src/js/math.ts +1 -1
- package/src/js/models.ts +5 -5
- package/src/js/number.ts +2 -2
- package/src/js/query.ts +6 -10
- package/src/js/queue.ts +1 -1
- package/src/js/random.ts +9 -19
- package/src/js/sized.ts +145 -145
- package/src/js/string/case.ts +1 -1
- package/src/js/string/index.ts +13 -7
- package/src/js/string/template.ts +6 -3
- package/src/js/value/clone.ts +3 -7
- package/src/js/value/compare.ts +3 -5
- package/src/js/value/diff.ts +4 -4
- package/src/js/value/equal.ts +2 -2
- package/src/js/value/get.ts +3 -3
- package/src/js/value/index.ts +2 -2
- package/src/js/value/merge.ts +3 -3
- package/src/js/value/set.ts +3 -4
- package/src/js/value/smush.ts +4 -4
- package/src/js/value/unsmush.ts +4 -4
- package/types/array/chunk.d.cts +8 -0
- package/types/array/chunk.d.ts +2 -2
- package/types/array/compact.d.cts +12 -0
- package/types/array/compact.d.ts +4 -4
- package/types/array/count.d.cts +24 -0
- package/types/array/count.d.ts +13 -7
- package/types/array/exists.d.cts +26 -0
- package/types/array/exists.d.ts +11 -3
- package/types/array/filter.d.cts +26 -0
- package/types/array/filter.d.ts +14 -6
- package/types/array/find.d.cts +26 -0
- package/types/array/find.d.ts +14 -6
- package/types/array/group-by.d.cts +58 -0
- package/types/array/group-by.d.ts +49 -5
- package/types/array/index-of.d.cts +26 -0
- package/types/array/index-of.d.ts +14 -6
- package/types/array/index.d.cts +239 -95
- package/types/array/index.d.ts +7 -6
- package/types/array/insert.d.cts +16 -0
- package/types/array/insert.d.ts +10 -5
- package/types/array/models.d.cts +14 -11
- package/types/array/models.d.ts +14 -12
- package/types/array/shuffle.d.cts +8 -0
- package/types/array/shuffle.d.ts +2 -2
- package/types/array/sort.d.cts +24 -0
- package/types/array/sort.d.ts +10 -10
- package/types/array/splice.d.cts +22 -0
- package/types/array/splice.d.ts +4 -4
- package/types/array/to-map.d.cts +61 -0
- package/types/array/to-map.d.ts +42 -20
- package/types/array/to-record.d.cts +61 -0
- package/types/array/to-record.d.ts +42 -20
- package/types/array/unique.d.cts +21 -0
- package/types/array/unique.d.ts +10 -6
- package/types/colour/base.d.cts +153 -0
- package/types/colour/base.d.ts +2 -2
- package/types/colour/functions.d.cts +173 -0
- package/types/colour/functions.d.ts +3 -3
- package/types/colour/hex.d.cts +157 -0
- package/types/colour/hex.d.ts +4 -4
- package/types/colour/hsl.d.cts +157 -0
- package/types/colour/hsl.d.ts +16 -10
- package/types/colour/index.d.cts +28 -16
- package/types/colour/index.d.ts +1 -1
- package/types/colour/is.d.cts +170 -0
- package/types/colour/is.d.ts +3 -3
- package/types/colour/rgb.d.cts +157 -0
- package/types/colour/rgb.d.ts +15 -9
- package/types/emitter.d.cts +11 -8
- package/types/emitter.d.ts +11 -8
- package/types/function.d.cts +10 -10
- package/types/function.d.ts +11 -11
- package/types/index.d.cts +1120 -736
- package/types/index.d.ts +16 -16
- package/types/internal/array/callbacks.d.cts +11 -0
- package/types/internal/array/callbacks.d.ts +2 -0
- package/types/internal/array/find.d.cts +7 -0
- package/types/internal/array/find.d.ts +3 -0
- package/types/internal/value/handle.d.cts +37 -0
- package/types/internal/{value-handle.d.ts → value/handle.d.ts} +1 -1
- package/types/is.d.ts +1 -1
- package/types/logger.d.cts +13 -21
- package/types/logger.d.ts +13 -21
- package/types/math.d.cts +1 -1
- package/types/math.d.ts +1 -1
- package/types/models.d.cts +4 -4
- package/types/models.d.ts +1 -4
- package/types/number.d.cts +2 -2
- package/types/number.d.ts +2 -2
- package/types/query.d.cts +2 -2
- package/types/query.d.ts +3 -3
- package/types/queue.d.cts +1 -1
- package/types/queue.d.ts +1 -1
- package/types/random.d.cts +8 -12
- package/types/random.d.ts +8 -12
- package/types/sized.d.cts +6 -6
- package/types/sized.d.ts +6 -6
- package/types/string/case.d.cts +28 -0
- package/types/string/index.d.cts +30 -27
- package/types/string/index.d.ts +3 -3
- package/types/string/template.d.cts +50 -0
- package/types/string/template.d.ts +4 -1
- package/types/value/clone.d.cts +8 -0
- package/types/value/clone.d.ts +4 -2
- package/types/value/compare.d.cts +8 -0
- package/types/value/diff.d.cts +25 -0
- package/types/value/equal.d.cts +12 -0
- package/types/value/get.d.cts +1319 -0
- package/types/value/get.d.ts +1 -1
- package/types/value/index.d.cts +8 -6
- package/types/value/index.d.ts +2 -2
- package/types/value/merge.d.cts +72 -0
- package/types/value/merge.d.ts +2 -2
- package/types/value/set.d.cts +1011 -0
- package/types/value/set.d.ts +1 -1
- package/types/value/smush.d.cts +1368 -0
- package/types/value/smush.d.ts +2 -2
- package/types/value/unsmush.d.cts +141 -0
- package/types/value/unsmush.d.ts +2 -2
- package/dist/js/array/count.mjs +0 -8
- package/dist/js/array/exists.mjs +0 -8
- package/dist/js/array/filter.mjs +0 -8
- package/dist/js/array/find.mjs +0 -8
- package/dist/js/array/group-by.mjs +0 -33
- package/dist/js/array/index-of.mjs +0 -8
- package/dist/js/array/index.mjs +0 -34
- package/dist/js/array/insert.mjs +0 -22
- package/dist/js/array/models.mjs +0 -0
- package/dist/js/array/splice.mjs +0 -9
- package/dist/js/array/to-map.mjs +0 -27
- package/dist/js/array/to-record.mjs +0 -8
- package/dist/js/array/unique.mjs +0 -8
- package/dist/js/colour/index.mjs +0 -30
- package/dist/js/index.mjs +0 -17
- package/dist/js/internal/array-callbacks.mjs +0 -19
- package/dist/js/internal/array-find.mjs +0 -51
- package/dist/js/logger.mjs +0 -69
- package/dist/js/models.mjs +0 -0
- package/dist/js/string/index.mjs +0 -44
- package/dist/js/value/index.mjs +0 -23
- package/src/js/internal/array-callbacks.ts +0 -28
- package/types/internal/array-callbacks.d.ts +0 -2
- package/types/internal/array-find.d.ts +0 -4
package/types/array/index.d.cts
CHANGED
|
@@ -1,194 +1,338 @@
|
|
|
1
1
|
// Generated by dts-bundle-generator v9.5.1
|
|
2
2
|
|
|
3
|
+
export type KeyedValue<Item, Key extends keyof Item> = Item[Key] extends PropertyKey ? Item[Key] : never;
|
|
3
4
|
export type NestedArrayType<Value> = Value extends Array<infer NestedValue> ? NestedArrayType<NestedValue> : Value;
|
|
4
5
|
export type Key = number | string;
|
|
5
6
|
/**
|
|
6
|
-
*
|
|
7
|
+
* Chunk an array _(into smaller arrays of a specified size)_
|
|
7
8
|
*/
|
|
8
|
-
export declare function chunk<
|
|
9
|
+
export declare function chunk<Item>(array: Item[], size?: number): Item[][];
|
|
9
10
|
/**
|
|
10
|
-
*
|
|
11
|
+
* Compact an array _(removing all `null` and `undefined` values)_
|
|
11
12
|
*/
|
|
12
|
-
export declare function compact<
|
|
13
|
+
export declare function compact<Item>(array: Item[]): Exclude<Item, null | undefined>[];
|
|
13
14
|
/**
|
|
14
|
-
*
|
|
15
|
+
* Compact an array _(removing all falsey values)_
|
|
15
16
|
*/
|
|
16
|
-
export declare function compact<
|
|
17
|
-
export type ArrayCallback<
|
|
18
|
-
export type BooleanCallback<
|
|
19
|
-
export type KeyCallback<
|
|
20
|
-
export type SortKey<
|
|
17
|
+
export declare function compact<Item>(array: Item[], strict: true): Exclude<Item, 0 | "" | false | null | undefined>[];
|
|
18
|
+
export type ArrayCallback<Item, Value> = (item: Item, index: number, array: Item[]) => Value;
|
|
19
|
+
export type BooleanCallback<Item> = ArrayCallback<Item, boolean>;
|
|
20
|
+
export type KeyCallback<Item> = ArrayCallback<Item, Key>;
|
|
21
|
+
export type SortKey<Item> = {
|
|
21
22
|
direction: "asc" | "desc";
|
|
22
|
-
value: Key | SortKeyCallback<
|
|
23
|
+
value: Key | SortKeyCallback<Item>;
|
|
23
24
|
};
|
|
24
|
-
export type SortKeyCallback<
|
|
25
|
+
export type SortKeyCallback<Item> = (item: Item) => unknown;
|
|
26
|
+
export type ValueCallback<Item> = ArrayCallback<Item, unknown>;
|
|
25
27
|
/**
|
|
26
|
-
*
|
|
28
|
+
* Get the number of items _(count)_ that match the given value
|
|
27
29
|
*/
|
|
28
|
-
export declare function count<
|
|
30
|
+
export declare function count<Item>(array: Item[], value: Item): number;
|
|
29
31
|
/**
|
|
30
|
-
*
|
|
31
|
-
|
|
32
|
+
* Get the number of items _(count)_ that match the given value
|
|
33
|
+
*/
|
|
34
|
+
export declare function count<Item>(array: Item[], matches: BooleanCallback<Item>): number;
|
|
35
|
+
/**
|
|
36
|
+
* Get the number of items _(count)_ that match the given value
|
|
32
37
|
*/
|
|
33
|
-
export declare function count<
|
|
38
|
+
export declare function count<Item, Key extends keyof Item>(array: Item[], key: Key, value: Item[Key]): number;
|
|
39
|
+
/**
|
|
40
|
+
* Get the number of items _(count)_ that match the given value
|
|
41
|
+
*/
|
|
42
|
+
export declare function count<Item, Key extends KeyCallback<Item>>(array: Item[], key: Key, value: ReturnType<Key>): number;
|
|
34
43
|
/**
|
|
35
44
|
* Does the value exist in array?
|
|
36
45
|
*/
|
|
37
|
-
export declare function exists<
|
|
46
|
+
export declare function exists<Item>(array: Item[], value: Item): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Does the value exist in array?
|
|
49
|
+
*/
|
|
50
|
+
export declare function exists<Item>(array: Item[], matches: BooleanCallback<Item>): boolean;
|
|
38
51
|
/**
|
|
39
52
|
* - Does the value exist in array?
|
|
40
53
|
* - Use `key` to find a comparison value to match with `value`
|
|
41
54
|
*/
|
|
42
|
-
export declare function exists<
|
|
55
|
+
export declare function exists<Item, Key extends keyof Item>(array: Item[], key: Key, value: Item[Key]): boolean;
|
|
43
56
|
/**
|
|
44
|
-
*
|
|
57
|
+
* - Does the value exist in array?
|
|
58
|
+
* - Use `key` to find a comparison value to match with `value`
|
|
45
59
|
*/
|
|
46
|
-
export declare function
|
|
60
|
+
export declare function exists<Item, Key extends KeyCallback<Item>>(array: Item[], key: Key, value: ReturnType<Key>): boolean;
|
|
47
61
|
/**
|
|
48
|
-
*
|
|
62
|
+
* Get a filtered array of items matching `value`
|
|
63
|
+
*/
|
|
64
|
+
export declare function filter<Item>(array: Item[], value: Item): Item[];
|
|
65
|
+
/**
|
|
66
|
+
* Get a filtered array of items matching `value`
|
|
67
|
+
*/
|
|
68
|
+
export declare function filter<Item>(array: Item[], matches: BooleanCallback<Item>): Item[];
|
|
69
|
+
/**
|
|
70
|
+
* - Get a filtered array of items
|
|
71
|
+
* - Use `key` to find a comparison value to match with `value`
|
|
72
|
+
*/
|
|
73
|
+
export declare function filter<Item, Key extends keyof Item>(array: Item[], key: Key, value: Item[Key]): Item[];
|
|
74
|
+
/**
|
|
75
|
+
* - Get a filtered array of items
|
|
49
76
|
* - Use `key` to find a comparison value to match with `value`
|
|
50
77
|
*/
|
|
51
|
-
export declare function filter<
|
|
78
|
+
export declare function filter<Item, Key extends KeyCallback<Item>>(array: Item[], key: Key, value: ReturnType<Key>): Item[];
|
|
79
|
+
/**
|
|
80
|
+
* Get the first item matching `value` _(or `undefined` if no match is found)_
|
|
81
|
+
*/
|
|
82
|
+
export declare function find<Item>(array: Item[], value: Item): Item | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* Get the first item matching `value` _(or `undefined` if no match is found)_
|
|
85
|
+
*/
|
|
86
|
+
export declare function find<Item>(array: Item[], matches: BooleanCallback<Item>): Item | undefined;
|
|
52
87
|
/**
|
|
53
|
-
*
|
|
88
|
+
* - Get the first matching item _(or `undefined` if no match is found)_
|
|
89
|
+
* - Use `key` to find a comparison value to match with `value`
|
|
54
90
|
*/
|
|
55
|
-
export declare function find<
|
|
91
|
+
export declare function find<Item, Key extends keyof Item>(array: Item[], key: Key, value: Item[Key]): Item | undefined;
|
|
56
92
|
/**
|
|
57
|
-
* -
|
|
93
|
+
* - Get the first matching item _(or `undefined` if no match is found)_
|
|
58
94
|
* - Use `key` to find a comparison value to match with `value`
|
|
59
95
|
*/
|
|
60
|
-
export declare function find<
|
|
96
|
+
export declare function find<Item, Key extends KeyCallback<Item>>(array: Item[], key: Key, value: ReturnType<Key>): Item | undefined;
|
|
97
|
+
/**
|
|
98
|
+
* Create a record from an array of items using a specific key
|
|
99
|
+
*/
|
|
100
|
+
export declare function groupBy<Item, Key extends keyof Item>(array: Item[], key: Key): Record<KeyedValue<Item, Key>, Item>;
|
|
101
|
+
/**
|
|
102
|
+
* Create a record from an array of items using a specific key, and grouping them into arrays
|
|
103
|
+
*/
|
|
104
|
+
export declare function groupBy<Item, Key extends keyof Item>(array: Item[], key: Key, arrays: true): Record<KeyedValue<Item, Key>, Item[]>;
|
|
105
|
+
/**
|
|
106
|
+
* Create a record from an array of items using a specific key
|
|
107
|
+
*/
|
|
108
|
+
export declare function groupBy<Item, Key extends KeyCallback<Item>>(array: Item[], key: Key): Record<ReturnType<Key>, Item>;
|
|
109
|
+
/**
|
|
110
|
+
* Create a record from an array of items using a specific key, and grouping them into arrays
|
|
111
|
+
*/
|
|
112
|
+
export declare function groupBy<Item, Key extends KeyCallback<Item>>(array: Item[], key: Key, arrays: true): Record<ReturnType<Key>, Item[]>;
|
|
113
|
+
/**
|
|
114
|
+
* Create a record from an array of items using a specific key and value
|
|
115
|
+
*/
|
|
116
|
+
export declare function groupBy<Item, Key extends keyof Item, Value extends keyof Item>(array: Item[], key: Key, value: Value): Record<KeyedValue<Item, Key>, KeyedValue<Item, Value>>;
|
|
117
|
+
/**
|
|
118
|
+
* Create a record from an array of items using a specific key and value, and grouping them into arrays
|
|
119
|
+
*/
|
|
120
|
+
export declare function groupBy<Item, Key extends keyof Item, Value extends keyof Item>(array: Item[], key: Key, value: Value, arrays: true): Record<KeyedValue<Item, Key>, Array<KeyedValue<Item, Value>>>;
|
|
121
|
+
/**
|
|
122
|
+
* Create a record from an array of items using a specific key and value
|
|
123
|
+
*/
|
|
124
|
+
export declare function groupBy<Item, Key extends keyof Item, Value extends ValueCallback<Item>>(array: Item[], key: Key, value: Value): Record<KeyedValue<Item, Key>, ReturnType<Value>>;
|
|
125
|
+
/**
|
|
126
|
+
* Create a record from an array of items using a specific key and value, and grouping them into arrays
|
|
127
|
+
*/
|
|
128
|
+
export declare function groupBy<Item, Key extends keyof Item, Value extends ValueCallback<Item>>(array: Item[], key: Key, value: Value, arrays: true): Record<KeyedValue<Item, Key>, Array<ReturnType<Value>>>;
|
|
129
|
+
/**
|
|
130
|
+
* Create a record from an array of items using a specific key and value
|
|
131
|
+
*/
|
|
132
|
+
export declare function groupBy<Item, Key extends KeyCallback<Item>, Value extends keyof Item>(array: Item[], key: Key, value: Value): Record<ReturnType<Key>, KeyedValue<Item, Value>>;
|
|
133
|
+
/**
|
|
134
|
+
* Create a record from an array of items using a specific key and value, and grouping them into arrays
|
|
135
|
+
*/
|
|
136
|
+
export declare function groupBy<Item, Key extends KeyCallback<Item>, Value extends keyof Item>(array: Item[], key: Key, value: Value, arrays: true): Record<ReturnType<Key>, Array<KeyedValue<Item, Value>>>;
|
|
61
137
|
/**
|
|
62
|
-
*
|
|
138
|
+
* Create a record from an array of items using a specific key and value
|
|
63
139
|
*/
|
|
64
|
-
export declare function groupBy<Value
|
|
140
|
+
export declare function groupBy<Item, Key extends KeyCallback<Item>, Value extends ValueCallback<Item>>(array: Item[], key: Key, value: Value): Record<ReturnType<Key>, ReturnType<Value>>;
|
|
65
141
|
/**
|
|
66
|
-
*
|
|
142
|
+
* Create a record from an array of items using a specific key and value, and grouping them into arrays
|
|
67
143
|
*/
|
|
68
|
-
export declare function
|
|
144
|
+
export declare function groupBy<Item, Key extends KeyCallback<Item>, Value extends ValueCallback<Item>>(array: Item[], key: Key, value: Value, arrays: true): Record<ReturnType<Key>, Array<ReturnType<Value>>>;
|
|
69
145
|
/**
|
|
70
|
-
*
|
|
146
|
+
* Get the index for the first item matching `value` _(or `-1` if no match is found)_
|
|
147
|
+
*/
|
|
148
|
+
export declare function indexOf<Item>(array: Item[], value: Item): number;
|
|
149
|
+
/**
|
|
150
|
+
* Get the index for the first item matching `value` _(or `-1` if no match is found)_
|
|
151
|
+
*/
|
|
152
|
+
export declare function indexOf<Item>(array: Item[], matches: BooleanCallback<Item>): number;
|
|
153
|
+
/**
|
|
154
|
+
* - Get the index for the first matching item _(or `-1` if no match is found)_
|
|
71
155
|
* - Use `key` to find a comparison value to match with `value`
|
|
72
156
|
*/
|
|
73
|
-
export declare function indexOf<
|
|
157
|
+
export declare function indexOf<Item, Key extends keyof Item>(array: Item[], key: Key, value: Item[Key]): number;
|
|
74
158
|
/**
|
|
75
|
-
* -
|
|
76
|
-
* -
|
|
159
|
+
* - Get the index for the first matching item _(or `-1` if no match is found)_
|
|
160
|
+
* - Use `key` to find a comparison value to match with `value`
|
|
77
161
|
*/
|
|
78
|
-
export declare function
|
|
162
|
+
export declare function indexOf<Item, Key extends KeyCallback<Item>>(array: Item[], key: Key, value: ReturnType<Key>): number;
|
|
79
163
|
/**
|
|
80
|
-
*
|
|
164
|
+
* - Insert values into an array _(at the end)_
|
|
165
|
+
* - _(Uses chunking to avoid stack overflow_)
|
|
81
166
|
*/
|
|
82
|
-
export declare function
|
|
167
|
+
export declare function insert<Item>(array: Item[], items: Item[]): void;
|
|
83
168
|
/**
|
|
84
|
-
*
|
|
169
|
+
* - Insert values into an array at a specified index
|
|
170
|
+
* - _(Uses chunking to avoid stack overflow_)
|
|
85
171
|
*/
|
|
86
|
-
export declare function
|
|
172
|
+
export declare function insert<Item>(array: Item[], index: number, items: Item[]): void;
|
|
87
173
|
/**
|
|
88
|
-
*
|
|
89
|
-
* - Ascending by default, but can be changed by setting `descending` to `true`, or using a `SortKey`
|
|
174
|
+
* Shuffle an array
|
|
90
175
|
*/
|
|
91
|
-
export declare function
|
|
176
|
+
export declare function shuffle<Item>(array: Item[]): Item[];
|
|
92
177
|
/**
|
|
93
|
-
*
|
|
94
|
-
* - Ascending by default, but can be changed by setting `descending` to `true`, or using `SortKey`
|
|
178
|
+
* Sort an array of items _(defaults to ascending)_
|
|
95
179
|
*/
|
|
96
|
-
export declare function sort<
|
|
180
|
+
export declare function sort<Item>(array: Item[], descending?: boolean): Item[];
|
|
181
|
+
/**
|
|
182
|
+
* - Sort an array of items, using a `key` to sort by a specific value
|
|
183
|
+
* - Defaults to ascending, but can be changed by setting `descending` to `true`, or using a `SortKey`
|
|
184
|
+
*/
|
|
185
|
+
export declare function sort<Item>(array: Item[], key: Key | SortKey<Item> | SortKeyCallback<Item>, descending?: boolean): Item[];
|
|
186
|
+
/**
|
|
187
|
+
* - Sort an array of items, using multiple `keys` to sort by specific values
|
|
188
|
+
* - Defaults to ascending, but can be changed by setting `descending` to `true`, or using `SortKey`
|
|
189
|
+
*/
|
|
190
|
+
export declare function sort<Item>(array: Item[], keys: Array<Key | SortKey<Item> | SortKeyCallback<Item>>, descending?: boolean): Item[];
|
|
97
191
|
/**
|
|
98
192
|
* Removes and returns all items from an array starting from a specific index
|
|
99
193
|
*/
|
|
100
|
-
export declare function splice<
|
|
194
|
+
export declare function splice<Item>(array: Item[], start: number): Item[];
|
|
101
195
|
/**
|
|
102
196
|
* Removes and returns _(up to)_ a specific amount of items from an array, starting from a specific index
|
|
103
197
|
*/
|
|
104
|
-
export declare function splice<
|
|
198
|
+
export declare function splice<Item>(array: Item[], start: number, amount: number): Item[];
|
|
105
199
|
/**
|
|
106
200
|
* - Splices values into an array and returns any removed values
|
|
107
201
|
* - Uses chunking to avoid stack overflow
|
|
108
202
|
*/
|
|
109
|
-
export declare function splice<
|
|
203
|
+
export declare function splice<Item>(array: Item[], start: number, added: Item[]): Item[];
|
|
110
204
|
/**
|
|
111
205
|
* - Splices values into an array and returns any removed values
|
|
112
206
|
* - Uses chunking to avoid stack overflow
|
|
113
207
|
*/
|
|
114
|
-
export declare function splice<
|
|
208
|
+
export declare function splice<Item>(array: Item[], start: number, amount: number, added: Item[]): Item[];
|
|
209
|
+
/**
|
|
210
|
+
* Create a map from an array of items _(using their indices as keys)_
|
|
211
|
+
*/
|
|
212
|
+
export declare function toMap<Item>(array: Item[]): Map<number, Item>;
|
|
213
|
+
/**
|
|
214
|
+
* Create a map from an array of items using a specific key
|
|
215
|
+
*/
|
|
216
|
+
export declare function toMap<Item, Key extends keyof Item>(array: Item[], key: Key): Map<KeyedValue<Item, Key>, Item>;
|
|
217
|
+
/**
|
|
218
|
+
* Create a map from an array of items using a specific key, and grouping them into arrays
|
|
219
|
+
*/
|
|
220
|
+
export declare function toMap<Item, Key extends keyof Item>(array: Item[], key: Key, arrays: true): Map<KeyedValue<Item, Key>, Item[]>;
|
|
221
|
+
/**
|
|
222
|
+
* Create a map from an array of items using a specific key
|
|
223
|
+
*/
|
|
224
|
+
export declare function toMap<Item, Key extends KeyCallback<Item>>(array: Item[], key: Key): Map<ReturnType<Key>, Item>;
|
|
225
|
+
/**
|
|
226
|
+
* Create a map from an array of items using a specific key, and grouping them into arrays
|
|
227
|
+
*/
|
|
228
|
+
export declare function toMap<Item, Key extends KeyCallback<Item>>(array: Item[], key: Key, arrays: true): Map<ReturnType<Key>, Item[]>;
|
|
229
|
+
/**
|
|
230
|
+
* Create a map from an array of items using a specific key and value
|
|
231
|
+
*/
|
|
232
|
+
export declare function toMap<Item, Key extends keyof Item, Value extends keyof Item>(array: Item[], key: Key, value: Value): Map<KeyedValue<Item, Key>, KeyedValue<Item, Value>>;
|
|
233
|
+
/**
|
|
234
|
+
* Create a map from an array of items using a specific key and value, and grouping them into arrays
|
|
235
|
+
*/
|
|
236
|
+
export declare function toMap<Item, Key extends keyof Item, Value extends keyof Item>(array: Item[], key: Key, value: Value, arrays: true): Map<KeyedValue<Item, Key>, Array<KeyedValue<Item, Value>>>;
|
|
237
|
+
/**
|
|
238
|
+
* Create a map from an array of items using a specific key and value
|
|
239
|
+
*/
|
|
240
|
+
export declare function toMap<Item, Key extends keyof Item, Value extends ValueCallback<Item>>(array: Item[], key: Key, value: Value): Map<KeyedValue<Item, Key>, ReturnType<Value>>;
|
|
241
|
+
/**
|
|
242
|
+
* Create a map from an array of items using a specific key and value, and grouping them into arrays
|
|
243
|
+
*/
|
|
244
|
+
export declare function toMap<Item, Key extends keyof Item, Value extends ValueCallback<Item>>(array: Item[], key: Key, value: Value, arrays: true): Map<KeyedValue<Item, Key>, Array<ReturnType<Value>>>;
|
|
245
|
+
/**
|
|
246
|
+
* Create a map from an array of items using a specific key and value
|
|
247
|
+
*/
|
|
248
|
+
export declare function toMap<Item, Key extends KeyCallback<Item>, Value extends keyof Item>(array: Item[], key: Key, value: Value): Map<ReturnType<Key>, KeyedValue<Item, Value>>;
|
|
249
|
+
/**
|
|
250
|
+
* Create a map from an array of items using a specific key and value, and grouping them into arrays
|
|
251
|
+
*/
|
|
252
|
+
export declare function toMap<Item, Key extends KeyCallback<Item>, Value extends keyof Item>(array: Item[], key: Key, value: Value, arrays: true): Map<ReturnType<Key>, Array<KeyedValue<Item, Value>>>;
|
|
115
253
|
/**
|
|
116
|
-
*
|
|
254
|
+
* Create a map from an array of items using a specific key and value
|
|
117
255
|
*/
|
|
118
|
-
export declare function toMap<Value
|
|
256
|
+
export declare function toMap<Item, Key extends KeyCallback<Item>, Value extends ValueCallback<Item>>(array: Item[], key: Key, value: Value): Map<ReturnType<Key>, ReturnType<Value>>;
|
|
119
257
|
/**
|
|
120
|
-
*
|
|
258
|
+
* Create a map from an array of items using a specific key and value, and grouping them into arrays
|
|
121
259
|
*/
|
|
122
|
-
export declare function toMap<Value
|
|
260
|
+
export declare function toMap<Item, Key extends KeyCallback<Item>, Value extends ValueCallback<Item>>(array: Item[], key: Key, value: Value, arrays: true): Map<ReturnType<Key>, Array<ReturnType<Value>>>;
|
|
123
261
|
/**
|
|
124
|
-
*
|
|
125
|
-
* - Uses `key` to find an identifcation value to use as keys
|
|
262
|
+
* Create a record from an array of items _(using their indices as keys)_
|
|
126
263
|
*/
|
|
127
|
-
export declare function
|
|
264
|
+
export declare function toRecord<Item>(array: Item[]): Record<number, Item>;
|
|
128
265
|
/**
|
|
129
|
-
*
|
|
130
|
-
* - Uses `key` to find an identifcation value to use as keys
|
|
131
|
-
* - Groups values into arrays
|
|
266
|
+
* Create a record from an array of items using a specific key
|
|
132
267
|
*/
|
|
133
|
-
export declare function
|
|
268
|
+
export declare function toRecord<Item, Key extends keyof Item>(array: Item[], key: Key): Record<KeyedValue<Item, Key>, Item>;
|
|
134
269
|
/**
|
|
135
|
-
*
|
|
136
|
-
* - Uses `key` to find an identifcation value to use as keys
|
|
270
|
+
* Create a record from an array of items using a specific key, and grouping them into arrays
|
|
137
271
|
*/
|
|
138
|
-
export declare function
|
|
272
|
+
export declare function toRecord<Item, Key extends keyof Item>(array: Item[], key: Key, arrays: true): Record<KeyedValue<Item, Key>, Item[]>;
|
|
139
273
|
/**
|
|
140
|
-
*
|
|
141
|
-
* - Uses `key` to find an identifcation value to use as keys
|
|
142
|
-
* - Groups values into arrays
|
|
274
|
+
* Create a record from an array of items using a specific key
|
|
143
275
|
*/
|
|
144
|
-
export declare function
|
|
276
|
+
export declare function toRecord<Item, Key extends KeyCallback<Item>>(array: Item[], key: Key): Record<ReturnType<Key>, Item>;
|
|
145
277
|
/**
|
|
146
|
-
*
|
|
278
|
+
* Create a record from an array of items using a specific key, and grouping them into arrays
|
|
147
279
|
*/
|
|
148
|
-
export declare function toRecord<
|
|
280
|
+
export declare function toRecord<Item, Key extends KeyCallback<Item>>(array: Item[], key: Key, arrays: true): Record<ReturnType<Key>, Item[]>;
|
|
149
281
|
/**
|
|
150
|
-
*
|
|
282
|
+
* Create a record from an array of items using a specific key and value
|
|
151
283
|
*/
|
|
152
|
-
export declare function toRecord<Value>(array:
|
|
284
|
+
export declare function toRecord<Item, Key extends keyof Item, Value extends keyof Item>(array: Item[], key: Key, value: Value): Record<KeyedValue<Item, Key>, KeyedValue<Item, Value>>;
|
|
153
285
|
/**
|
|
154
|
-
*
|
|
155
|
-
* - Uses `key` to find an identifcation value to use as keys
|
|
286
|
+
* Create a record from an array of items using a specific key and value, and grouping them into arrays
|
|
156
287
|
*/
|
|
157
|
-
export declare function toRecord<Value>(array:
|
|
288
|
+
export declare function toRecord<Item, Key extends keyof Item, Value extends keyof Item>(array: Item[], key: Key, value: Value, arrays: true): Record<KeyedValue<Item, Key>, Array<KeyedValue<Item, Value>>>;
|
|
158
289
|
/**
|
|
159
|
-
*
|
|
160
|
-
* - Uses `key` to find an identifcation value to use as keys
|
|
161
|
-
* - Groups values into arrays
|
|
290
|
+
* Create a record from an array of items using a specific key and value
|
|
162
291
|
*/
|
|
163
|
-
export declare function toRecord<Value
|
|
292
|
+
export declare function toRecord<Item, Key extends keyof Item, Value extends ValueCallback<Item>>(array: Item[], key: Key, value: Value): Record<KeyedValue<Item, Key>, ReturnType<Value>>;
|
|
164
293
|
/**
|
|
165
|
-
*
|
|
166
|
-
* - Uses `key` to find an identifcation value to use as keys
|
|
294
|
+
* Create a record from an array of items using a specific key and value, and grouping them into arrays
|
|
167
295
|
*/
|
|
168
|
-
export declare function toRecord<Value
|
|
296
|
+
export declare function toRecord<Item, Key extends keyof Item, Value extends ValueCallback<Item>>(array: Item[], key: Key, value: Value, arrays: true): Record<KeyedValue<Item, Key>, Array<ReturnType<Value>>>;
|
|
169
297
|
/**
|
|
170
|
-
*
|
|
171
|
-
* - Uses `key` to find an identifcation value to use as keys
|
|
172
|
-
* - Groups values into arrays
|
|
298
|
+
* Create a record from an array of items using a specific key and value
|
|
173
299
|
*/
|
|
174
|
-
export declare function toRecord<Value>(array:
|
|
300
|
+
export declare function toRecord<Item, Key extends KeyCallback<Item>, Value extends keyof Item>(array: Item[], key: Key, value: Value): Record<ReturnType<Key>, KeyedValue<Item, Value>>;
|
|
175
301
|
/**
|
|
176
|
-
*
|
|
302
|
+
* Create a record from an array of items using a specific key and value, and grouping them into arrays
|
|
177
303
|
*/
|
|
178
|
-
export declare function
|
|
304
|
+
export declare function toRecord<Item, Key extends KeyCallback<Item>, Value extends keyof Item>(array: Item[], key: Key, value: Value, arrays: true): Record<ReturnType<Key>, Array<KeyedValue<Item, Value>>>;
|
|
179
305
|
/**
|
|
180
|
-
*
|
|
306
|
+
* Create a record from an array of items using a specific key and value
|
|
307
|
+
*/
|
|
308
|
+
export declare function toRecord<Item, Key extends KeyCallback<Item>, Value extends ValueCallback<Item>>(array: Item[], key: Key, value: Value): Record<ReturnType<Key>, ReturnType<Value>>;
|
|
309
|
+
/**
|
|
310
|
+
* Create a record from an array of items using a specific key and value, and grouping them into arrays
|
|
311
|
+
*/
|
|
312
|
+
export declare function toRecord<Item, Key extends KeyCallback<Item>, Value extends ValueCallback<Item>>(array: Item[], key: Key, value: Value, arrays: true): Record<ReturnType<Key>, Array<ReturnType<Value>>>;
|
|
313
|
+
/**
|
|
314
|
+
* Get an array of unique items
|
|
315
|
+
*/
|
|
316
|
+
export declare function unique<Item>(array: Item[]): Item[];
|
|
317
|
+
/**
|
|
318
|
+
* - Get an array of unique items
|
|
181
319
|
* - Use `key` to find a comparison value to match with `value`
|
|
182
320
|
*/
|
|
183
|
-
export declare function unique<
|
|
321
|
+
export declare function unique<Item, Key extends keyof Item>(array: Item[], key: Key): Item[];
|
|
184
322
|
/**
|
|
185
|
-
*
|
|
323
|
+
* - Get an array of unique items
|
|
324
|
+
* - Use `key` to find a comparison value to match with `value`
|
|
186
325
|
*/
|
|
187
|
-
export declare function
|
|
326
|
+
export declare function unique<Item, Key extends KeyCallback<Item>>(array: Item[], key: Key): Item[];
|
|
188
327
|
/**
|
|
189
|
-
*
|
|
190
|
-
|
|
328
|
+
* Flatten an array _(using native `flat` and maximum depth)_
|
|
329
|
+
*/
|
|
330
|
+
export declare function flatten<Item>(array: Item[]): NestedArrayType<Item>[];
|
|
331
|
+
/**
|
|
332
|
+
* - Push values to the end of an array
|
|
333
|
+
* - Returns the new length
|
|
334
|
+
* - _(Uses chunking to avoid stack overflow)_
|
|
191
335
|
*/
|
|
192
|
-
export declare function push<
|
|
336
|
+
export declare function push<Item>(array: Item[], pushed: Item[]): number;
|
|
193
337
|
|
|
194
338
|
export {};
|
package/types/array/index.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import type { NestedArrayType } from '
|
|
1
|
+
import type { NestedArrayType } from '~/models';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Flatten an array _(using native `flat` and maximum depth)_
|
|
4
4
|
*/
|
|
5
|
-
export declare function flatten<
|
|
5
|
+
export declare function flatten<Item>(array: Item[]): NestedArrayType<Item>[];
|
|
6
6
|
/**
|
|
7
|
-
* -
|
|
8
|
-
* -
|
|
7
|
+
* - Push values to the end of an array
|
|
8
|
+
* - Returns the new length
|
|
9
|
+
* - _(Uses chunking to avoid stack overflow)_
|
|
9
10
|
*/
|
|
10
|
-
export declare function push<
|
|
11
|
+
export declare function push<Item>(array: Item[], pushed: Item[]): number;
|
|
11
12
|
export * from './chunk';
|
|
12
13
|
export * from './compact';
|
|
13
14
|
export * from './count';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Generated by dts-bundle-generator v9.5.1
|
|
2
|
+
|
|
3
|
+
export type InsertType = "push" | "splice";
|
|
4
|
+
/**
|
|
5
|
+
* - Insert values into an array _(at the end)_
|
|
6
|
+
* - _(Uses chunking to avoid stack overflow_)
|
|
7
|
+
*/
|
|
8
|
+
export declare function insert<Item>(array: Item[], items: Item[]): void;
|
|
9
|
+
/**
|
|
10
|
+
* - Insert values into an array at a specified index
|
|
11
|
+
* - _(Uses chunking to avoid stack overflow_)
|
|
12
|
+
*/
|
|
13
|
+
export declare function insert<Item>(array: Item[], index: number, items: Item[]): void;
|
|
14
|
+
export declare function insertValues<Item>(type: InsertType, array: Item[], items: Item[], start: number, deleteCount: number): unknown;
|
|
15
|
+
|
|
16
|
+
export {};
|
package/types/array/insert.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import type { InsertType } from '
|
|
1
|
+
import type { InsertType } from '~/array/models';
|
|
2
2
|
/**
|
|
3
|
-
* -
|
|
4
|
-
* - Uses chunking to avoid stack
|
|
3
|
+
* - Insert values into an array _(at the end)_
|
|
4
|
+
* - _(Uses chunking to avoid stack overflow_)
|
|
5
5
|
*/
|
|
6
|
-
export declare function insert<
|
|
7
|
-
|
|
6
|
+
export declare function insert<Item>(array: Item[], items: Item[]): void;
|
|
7
|
+
/**
|
|
8
|
+
* - Insert values into an array at a specified index
|
|
9
|
+
* - _(Uses chunking to avoid stack overflow_)
|
|
10
|
+
*/
|
|
11
|
+
export declare function insert<Item>(array: Item[], index: number, items: Item[]): void;
|
|
12
|
+
export declare function insertValues<Item>(type: InsertType, array: Item[], items: Item[], start: number, deleteCount: number): unknown;
|
package/types/array/models.d.cts
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
// Generated by dts-bundle-generator v9.5.1
|
|
2
2
|
|
|
3
|
+
export type GenericCallback = (...args: any[]) => any;
|
|
3
4
|
export type Key = number | string;
|
|
4
|
-
export type ArrayCallback<
|
|
5
|
-
export type BooleanCallback<
|
|
6
|
-
export type Callbacks
|
|
7
|
-
bool?:
|
|
8
|
-
key?:
|
|
5
|
+
export type ArrayCallback<Item, Value> = (item: Item, index: number, array: Item[]) => Value;
|
|
6
|
+
export type BooleanCallback<Item> = ArrayCallback<Item, boolean>;
|
|
7
|
+
export type Callbacks = {
|
|
8
|
+
bool?: GenericCallback;
|
|
9
|
+
key?: GenericCallback;
|
|
10
|
+
value?: GenericCallback;
|
|
9
11
|
};
|
|
10
12
|
export type FindType = "index" | "value";
|
|
11
13
|
export type InsertType = "push" | "splice";
|
|
12
|
-
export type KeyCallback<
|
|
13
|
-
export type SortKey<
|
|
14
|
+
export type KeyCallback<Item> = ArrayCallback<Item, Key>;
|
|
15
|
+
export type SortKey<Item> = {
|
|
14
16
|
direction: "asc" | "desc";
|
|
15
|
-
value: Key | SortKeyCallback<
|
|
17
|
+
value: Key | SortKeyCallback<Item>;
|
|
16
18
|
};
|
|
17
|
-
export type SortKeyCallback<
|
|
18
|
-
export type SortKeyWithCallback<
|
|
19
|
-
callback: SortKeyCallback<
|
|
19
|
+
export type SortKeyCallback<Item> = (item: Item) => unknown;
|
|
20
|
+
export type SortKeyWithCallback<Item> = {
|
|
21
|
+
callback: SortKeyCallback<Item>;
|
|
20
22
|
direction: "asc" | "desc";
|
|
21
23
|
};
|
|
24
|
+
export type ValueCallback<Item> = ArrayCallback<Item, unknown>;
|
|
22
25
|
|
|
23
26
|
export {};
|
package/types/array/models.d.ts
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import type { Key } from '
|
|
2
|
-
export type ArrayCallback<
|
|
3
|
-
export type BooleanCallback<
|
|
4
|
-
export type Callbacks
|
|
5
|
-
bool?:
|
|
6
|
-
key?:
|
|
1
|
+
import type { GenericCallback, Key } from '~/models';
|
|
2
|
+
export type ArrayCallback<Item, Value> = (item: Item, index: number, array: Item[]) => Value;
|
|
3
|
+
export type BooleanCallback<Item> = ArrayCallback<Item, boolean>;
|
|
4
|
+
export type Callbacks = {
|
|
5
|
+
bool?: GenericCallback;
|
|
6
|
+
key?: GenericCallback;
|
|
7
|
+
value?: GenericCallback;
|
|
7
8
|
};
|
|
8
9
|
export type FindType = 'index' | 'value';
|
|
9
10
|
export type InsertType = 'push' | 'splice';
|
|
10
|
-
export type KeyCallback<
|
|
11
|
-
export type SortKey<
|
|
11
|
+
export type KeyCallback<Item> = ArrayCallback<Item, Key>;
|
|
12
|
+
export type SortKey<Item> = {
|
|
12
13
|
direction: 'asc' | 'desc';
|
|
13
|
-
value: Key | SortKeyCallback<
|
|
14
|
+
value: Key | SortKeyCallback<Item>;
|
|
14
15
|
};
|
|
15
|
-
export type SortKeyCallback<
|
|
16
|
-
export type SortKeyWithCallback<
|
|
17
|
-
callback: SortKeyCallback<
|
|
16
|
+
export type SortKeyCallback<Item> = (item: Item) => unknown;
|
|
17
|
+
export type SortKeyWithCallback<Item> = {
|
|
18
|
+
callback: SortKeyCallback<Item>;
|
|
18
19
|
direction: 'asc' | 'desc';
|
|
19
20
|
};
|
|
21
|
+
export type ValueCallback<Item> = ArrayCallback<Item, unknown>;
|
package/types/array/shuffle.d.ts
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Generated by dts-bundle-generator v9.5.1
|
|
2
|
+
|
|
3
|
+
export type Key = number | string;
|
|
4
|
+
export type SortKey<Item> = {
|
|
5
|
+
direction: "asc" | "desc";
|
|
6
|
+
value: Key | SortKeyCallback<Item>;
|
|
7
|
+
};
|
|
8
|
+
export type SortKeyCallback<Item> = (item: Item) => unknown;
|
|
9
|
+
/**
|
|
10
|
+
* Sort an array of items _(defaults to ascending)_
|
|
11
|
+
*/
|
|
12
|
+
export declare function sort<Item>(array: Item[], descending?: boolean): Item[];
|
|
13
|
+
/**
|
|
14
|
+
* - Sort an array of items, using a `key` to sort by a specific value
|
|
15
|
+
* - Defaults to ascending, but can be changed by setting `descending` to `true`, or using a `SortKey`
|
|
16
|
+
*/
|
|
17
|
+
export declare function sort<Item>(array: Item[], key: Key | SortKey<Item> | SortKeyCallback<Item>, descending?: boolean): Item[];
|
|
18
|
+
/**
|
|
19
|
+
* - Sort an array of items, using multiple `keys` to sort by specific values
|
|
20
|
+
* - Defaults to ascending, but can be changed by setting `descending` to `true`, or using `SortKey`
|
|
21
|
+
*/
|
|
22
|
+
export declare function sort<Item>(array: Item[], keys: Array<Key | SortKey<Item> | SortKeyCallback<Item>>, descending?: boolean): Item[];
|
|
23
|
+
|
|
24
|
+
export {};
|