@oscarpalmer/atoms 0.76.0 → 0.77.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/count.cjs +1 -8
- package/dist/js/array/count.js +1 -8
- package/dist/js/array/exists.cjs +1 -8
- package/dist/js/array/exists.js +1 -8
- package/dist/js/array/filter.cjs +1 -8
- package/dist/js/array/filter.js +1 -8
- package/dist/js/array/find.cjs +1 -8
- package/dist/js/array/find.js +1 -8
- package/dist/js/array/index-of.cjs +1 -8
- package/dist/js/array/index-of.js +1 -8
- package/dist/js/array/unique.cjs +1 -1
- package/dist/js/array/unique.js +1 -1
- package/dist/js/internal/array/find.cjs +12 -2
- package/dist/js/internal/array/find.js +12 -2
- package/package.json +11 -4
- package/src/js/array/count.ts +7 -20
- package/src/js/array/exists.ts +7 -22
- package/src/js/array/filter.ts +7 -20
- package/src/js/array/find.ts +7 -20
- package/src/js/array/group-by.ts +19 -21
- package/src/js/array/index-of.ts +7 -20
- package/src/js/array/models.ts +2 -16
- package/src/js/array/sort.ts +3 -7
- package/src/js/array/to-map.ts +19 -21
- package/src/js/array/to-record.ts +17 -19
- package/src/js/array/unique.ts +8 -8
- package/src/js/internal/array/callbacks.ts +4 -4
- package/src/js/internal/array/find.ts +29 -6
- package/types/array/count.d.cts +2 -5
- package/types/array/count.d.ts +3 -3
- package/types/array/exists.d.cts +2 -5
- package/types/array/exists.d.ts +3 -3
- package/types/array/filter.d.cts +2 -5
- package/types/array/filter.d.ts +3 -3
- package/types/array/find.d.cts +2 -5
- package/types/array/find.d.ts +3 -3
- package/types/array/group-by.d.cts +8 -11
- package/types/array/group-by.d.ts +10 -11
- package/types/array/index-of.d.cts +2 -5
- package/types/array/index-of.d.ts +3 -3
- package/types/array/index.d.cts +43 -48
- package/types/array/models.d.cts +2 -7
- package/types/array/models.d.ts +2 -7
- package/types/array/sort.d.cts +3 -4
- package/types/array/sort.d.ts +3 -3
- package/types/array/to-map.d.cts +8 -11
- package/types/array/to-map.d.ts +9 -10
- package/types/array/to-record.d.cts +8 -11
- package/types/array/to-record.d.ts +9 -10
- package/types/array/unique.d.cts +3 -5
- package/types/array/unique.d.ts +4 -4
- package/types/index.d.cts +321 -1019
- package/types/internal/array/find.d.cts +2 -2
- package/types/internal/array/find.d.ts +2 -2
- package/types/models.d.cts +210 -467
- package/types/value/get.d.cts +210 -469
- package/types/value/index.d.cts +223 -514
- package/types/value/set.d.cts +169 -356
- package/types/value/smush.d.cts +209 -463
package/src/js/array/sort.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
SortKey,
|
|
3
|
-
SortKeyCallback,
|
|
4
|
-
SortKeyWithCallback,
|
|
5
|
-
} from '~/array/models';
|
|
1
|
+
import type {SortKey, SortKeyWithCallback} from '~/array/models';
|
|
6
2
|
import {isKey} from '~/is';
|
|
7
3
|
import type {Key, PlainObject} from '~/models';
|
|
8
4
|
import {compare} from '~/value/compare';
|
|
@@ -18,7 +14,7 @@ export function sort<Item>(array: Item[], descending?: boolean): Item[];
|
|
|
18
14
|
*/
|
|
19
15
|
export function sort<Item>(
|
|
20
16
|
array: Item[],
|
|
21
|
-
key: Key | SortKey<Item> |
|
|
17
|
+
key: Key | SortKey<Item> | ((item: Item) => Key),
|
|
22
18
|
descending?: boolean,
|
|
23
19
|
): Item[];
|
|
24
20
|
|
|
@@ -28,7 +24,7 @@ export function sort<Item>(
|
|
|
28
24
|
*/
|
|
29
25
|
export function sort<Item>(
|
|
30
26
|
array: Item[],
|
|
31
|
-
keys: Array<Key | SortKey<Item> |
|
|
27
|
+
keys: Array<Key | SortKey<Item> | ((item: Item) => Key)>,
|
|
32
28
|
descending?: boolean,
|
|
33
29
|
): Item[];
|
|
34
30
|
|
package/src/js/array/to-map.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type {KeyCallback, ValueCallback} from '~/array/models';
|
|
2
1
|
import {getCallbacks} from '~/internal/array/callbacks';
|
|
3
|
-
import type {
|
|
2
|
+
import type {KeyedValue, Key as SimpleKey} from '~/models';
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* Create a map from an array of items _(using their indices as keys)_
|
|
@@ -27,19 +26,18 @@ export function toMap<Item, Key extends keyof Item>(
|
|
|
27
26
|
/**
|
|
28
27
|
* Create a map from an array of items using a specific key
|
|
29
28
|
*/
|
|
30
|
-
export function toMap<
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
): Map<ReturnType<Key>, Item>;
|
|
29
|
+
export function toMap<
|
|
30
|
+
Item,
|
|
31
|
+
Key extends (item: Item, index: number, array: Item[]) => SimpleKey,
|
|
32
|
+
>(array: Item[], key: Key): Map<ReturnType<Key>, Item>;
|
|
34
33
|
|
|
35
34
|
/**
|
|
36
35
|
* Create a map from an array of items using a specific key, and grouping them into arrays
|
|
37
36
|
*/
|
|
38
|
-
export function toMap<
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
): Map<ReturnType<Key>, Item[]>;
|
|
37
|
+
export function toMap<
|
|
38
|
+
Item,
|
|
39
|
+
Key extends (item: Item, index: number, array: Item[]) => SimpleKey,
|
|
40
|
+
>(array: Item[], key: Key, arrays: true): Map<ReturnType<Key>, Item[]>;
|
|
43
41
|
|
|
44
42
|
/**
|
|
45
43
|
* Create a map from an array of items using a specific key and value
|
|
@@ -66,7 +64,7 @@ export function toMap<Item, Key extends keyof Item, Value extends keyof Item>(
|
|
|
66
64
|
export function toMap<
|
|
67
65
|
Item,
|
|
68
66
|
Key extends keyof Item,
|
|
69
|
-
Value extends
|
|
67
|
+
Value extends (item: Item, index: number, array: Item[]) => unknown,
|
|
70
68
|
>(
|
|
71
69
|
array: Item[],
|
|
72
70
|
key: Key,
|
|
@@ -79,7 +77,7 @@ export function toMap<
|
|
|
79
77
|
export function toMap<
|
|
80
78
|
Item,
|
|
81
79
|
Key extends keyof Item,
|
|
82
|
-
Value extends
|
|
80
|
+
Value extends (item: Item, index: number, array: Item[]) => unknown,
|
|
83
81
|
>(
|
|
84
82
|
array: Item[],
|
|
85
83
|
key: Key,
|
|
@@ -92,7 +90,7 @@ export function toMap<
|
|
|
92
90
|
*/
|
|
93
91
|
export function toMap<
|
|
94
92
|
Item,
|
|
95
|
-
Key extends
|
|
93
|
+
Key extends (item: Item, index: number, array: Item[]) => SimpleKey,
|
|
96
94
|
Value extends keyof Item,
|
|
97
95
|
>(
|
|
98
96
|
array: Item[],
|
|
@@ -105,7 +103,7 @@ export function toMap<
|
|
|
105
103
|
*/
|
|
106
104
|
export function toMap<
|
|
107
105
|
Item,
|
|
108
|
-
Key extends
|
|
106
|
+
Key extends (item: Item, index: number, array: Item[]) => SimpleKey,
|
|
109
107
|
Value extends keyof Item,
|
|
110
108
|
>(
|
|
111
109
|
array: Item[],
|
|
@@ -119,8 +117,8 @@ export function toMap<
|
|
|
119
117
|
*/
|
|
120
118
|
export function toMap<
|
|
121
119
|
Item,
|
|
122
|
-
Key extends
|
|
123
|
-
Value extends
|
|
120
|
+
Key extends (item: Item, index: number, array: Item[]) => SimpleKey,
|
|
121
|
+
Value extends (item: Item, index: number, array: Item[]) => unknown,
|
|
124
122
|
>(
|
|
125
123
|
array: Item[],
|
|
126
124
|
key: Key,
|
|
@@ -132,8 +130,8 @@ export function toMap<
|
|
|
132
130
|
*/
|
|
133
131
|
export function toMap<
|
|
134
132
|
Item,
|
|
135
|
-
Key extends
|
|
136
|
-
Value extends
|
|
133
|
+
Key extends (item: Item, index: number, array: Item[]) => SimpleKey,
|
|
134
|
+
Value extends (item: Item, index: number, array: Item[]) => unknown,
|
|
137
135
|
>(
|
|
138
136
|
array: Item[],
|
|
139
137
|
key: Key,
|
|
@@ -146,10 +144,10 @@ export function toMap(
|
|
|
146
144
|
first?: unknown,
|
|
147
145
|
second?: unknown,
|
|
148
146
|
third?: unknown,
|
|
149
|
-
): Map<
|
|
147
|
+
): Map<SimpleKey, unknown> {
|
|
150
148
|
const asArrays = first === true || second === true || third === true;
|
|
151
149
|
const callbacks = getCallbacks(undefined, first, second);
|
|
152
|
-
const map = new Map<
|
|
150
|
+
const map = new Map<SimpleKey, unknown>();
|
|
153
151
|
const {length} = array;
|
|
154
152
|
|
|
155
153
|
for (let index = 0; index < length; index += 1) {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import {groupValues} from '~/array/group-by';
|
|
2
|
-
import type {
|
|
3
|
-
import type {KeyedValue, PlainObject} from '~/models';
|
|
2
|
+
import type {KeyedValue, PlainObject, Key as SimpleKey} from '~/models';
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* Create a record from an array of items _(using their indices as keys)_
|
|
@@ -27,19 +26,18 @@ export function toRecord<Item, Key extends keyof Item>(
|
|
|
27
26
|
/**
|
|
28
27
|
* Create a record from an array of items using a specific key
|
|
29
28
|
*/
|
|
30
|
-
export function toRecord<
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
): Record<ReturnType<Key>, Item>;
|
|
29
|
+
export function toRecord<
|
|
30
|
+
Item,
|
|
31
|
+
Key extends (item: Item, index: number, array: Item[]) => SimpleKey,
|
|
32
|
+
>(array: Item[], key: Key): Record<ReturnType<Key>, Item>;
|
|
34
33
|
|
|
35
34
|
/**
|
|
36
35
|
* Create a record from an array of items using a specific key, and grouping them into arrays
|
|
37
36
|
*/
|
|
38
|
-
export function toRecord<
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
): Record<ReturnType<Key>, Item[]>;
|
|
37
|
+
export function toRecord<
|
|
38
|
+
Item,
|
|
39
|
+
Key extends (item: Item, index: number, array: Item[]) => SimpleKey,
|
|
40
|
+
>(array: Item[], key: Key, arrays: true): Record<ReturnType<Key>, Item[]>;
|
|
43
41
|
|
|
44
42
|
/**
|
|
45
43
|
* Create a record from an array of items using a specific key and value
|
|
@@ -74,7 +72,7 @@ export function toRecord<
|
|
|
74
72
|
export function toRecord<
|
|
75
73
|
Item,
|
|
76
74
|
Key extends keyof Item,
|
|
77
|
-
Value extends
|
|
75
|
+
Value extends (item: Item, index: number, array: Item[]) => unknown,
|
|
78
76
|
>(
|
|
79
77
|
array: Item[],
|
|
80
78
|
key: Key,
|
|
@@ -87,7 +85,7 @@ export function toRecord<
|
|
|
87
85
|
export function toRecord<
|
|
88
86
|
Item,
|
|
89
87
|
Key extends keyof Item,
|
|
90
|
-
Value extends
|
|
88
|
+
Value extends (item: Item, index: number, array: Item[]) => unknown,
|
|
91
89
|
>(
|
|
92
90
|
array: Item[],
|
|
93
91
|
key: Key,
|
|
@@ -100,7 +98,7 @@ export function toRecord<
|
|
|
100
98
|
*/
|
|
101
99
|
export function toRecord<
|
|
102
100
|
Item,
|
|
103
|
-
Key extends
|
|
101
|
+
Key extends (item: Item, index: number, array: Item[]) => SimpleKey,
|
|
104
102
|
Value extends keyof Item,
|
|
105
103
|
>(
|
|
106
104
|
array: Item[],
|
|
@@ -113,7 +111,7 @@ export function toRecord<
|
|
|
113
111
|
*/
|
|
114
112
|
export function toRecord<
|
|
115
113
|
Item,
|
|
116
|
-
Key extends
|
|
114
|
+
Key extends (item: Item, index: number, array: Item[]) => SimpleKey,
|
|
117
115
|
Value extends keyof Item,
|
|
118
116
|
>(
|
|
119
117
|
array: Item[],
|
|
@@ -127,8 +125,8 @@ export function toRecord<
|
|
|
127
125
|
*/
|
|
128
126
|
export function toRecord<
|
|
129
127
|
Item,
|
|
130
|
-
Key extends
|
|
131
|
-
Value extends
|
|
128
|
+
Key extends (item: Item, index: number, array: Item[]) => SimpleKey,
|
|
129
|
+
Value extends (item: Item, index: number, array: Item[]) => unknown,
|
|
132
130
|
>(
|
|
133
131
|
array: Item[],
|
|
134
132
|
key: Key,
|
|
@@ -140,8 +138,8 @@ export function toRecord<
|
|
|
140
138
|
*/
|
|
141
139
|
export function toRecord<
|
|
142
140
|
Item,
|
|
143
|
-
Key extends
|
|
144
|
-
Value extends
|
|
141
|
+
Key extends (item: Item, index: number, array: Item[]) => SimpleKey,
|
|
142
|
+
Value extends (item: Item, index: number, array: Item[]) => unknown,
|
|
145
143
|
>(
|
|
146
144
|
array: Item[],
|
|
147
145
|
key: Key,
|
package/src/js/array/unique.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {KeyCallback} from '~/array/models';
|
|
2
1
|
import {findValues} from '~/internal/array/find';
|
|
2
|
+
import type {Key as SimpleKey} from '~/models';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Get an array of unique items
|
|
@@ -8,7 +8,7 @@ export function unique<Item>(array: Item[]): Item[];
|
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* - Get an array of unique items
|
|
11
|
-
* - Use `key` to find a comparison value
|
|
11
|
+
* - Use `key` to find a comparison value for an item
|
|
12
12
|
*/
|
|
13
13
|
export function unique<Item, Key extends keyof Item>(
|
|
14
14
|
array: Item[],
|
|
@@ -17,13 +17,13 @@ export function unique<Item, Key extends keyof Item>(
|
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* - Get an array of unique items
|
|
20
|
-
* - Use `key` to find a comparison value
|
|
20
|
+
* - Use `key` to find a comparison value for an item
|
|
21
21
|
*/
|
|
22
|
-
export function unique<
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
): Item[];
|
|
22
|
+
export function unique<
|
|
23
|
+
Item,
|
|
24
|
+
Key extends (item: Item, index: number, array: Item[]) => SimpleKey,
|
|
25
|
+
>(array: Item[], key: Key): Item[];
|
|
26
26
|
|
|
27
27
|
export function unique(array: unknown[], key?: unknown): unknown[] {
|
|
28
|
-
return findValues('unique', array,
|
|
28
|
+
return findValues('unique', array, [key, undefined]);
|
|
29
29
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {Callbacks} from '~/array/models';
|
|
2
2
|
import type {GenericCallback, PlainObject} from '~/models';
|
|
3
3
|
|
|
4
4
|
function getCallback(value: unknown): GenericCallback | undefined {
|
|
@@ -23,11 +23,11 @@ export function getCallbacks(
|
|
|
23
23
|
value?: unknown,
|
|
24
24
|
): Callbacks | undefined {
|
|
25
25
|
if (typeof bool === 'function') {
|
|
26
|
-
return {bool: bool as
|
|
26
|
+
return {bool: bool as GenericCallback};
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
return {
|
|
30
|
-
key: getCallback(key)
|
|
31
|
-
value: getCallback(value)
|
|
30
|
+
key: getCallback(key),
|
|
31
|
+
value: getCallback(value),
|
|
32
32
|
};
|
|
33
33
|
}
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import type {FindType} from '~/array/models';
|
|
2
2
|
import {getCallbacks} from '~/internal/array/callbacks';
|
|
3
3
|
|
|
4
|
+
type Parameters = {
|
|
5
|
+
bool?: unknown;
|
|
6
|
+
key?: unknown;
|
|
7
|
+
value?: unknown;
|
|
8
|
+
};
|
|
9
|
+
|
|
4
10
|
export function findValue(
|
|
5
11
|
type: FindType,
|
|
6
12
|
array: unknown[],
|
|
7
|
-
|
|
8
|
-
key: unknown,
|
|
9
|
-
value: unknown,
|
|
13
|
+
parameters: unknown[],
|
|
10
14
|
): unknown {
|
|
15
|
+
const {bool, key, value} = getParameters(parameters);
|
|
16
|
+
|
|
11
17
|
const callbacks = getCallbacks(bool, key);
|
|
12
18
|
|
|
13
19
|
if (callbacks?.bool == null && callbacks?.key == null) {
|
|
@@ -38,11 +44,12 @@ export function findValue(
|
|
|
38
44
|
export function findValues(
|
|
39
45
|
type: 'all' | 'unique',
|
|
40
46
|
array: unknown[],
|
|
41
|
-
|
|
42
|
-
key: unknown,
|
|
43
|
-
value: unknown,
|
|
47
|
+
parameters: unknown[],
|
|
44
48
|
): unknown[] {
|
|
49
|
+
const {bool, key, value} = getParameters(parameters);
|
|
50
|
+
|
|
45
51
|
const callbacks = getCallbacks(bool, key);
|
|
52
|
+
|
|
46
53
|
const {length} = array;
|
|
47
54
|
|
|
48
55
|
if (type === 'unique' && callbacks?.key == null && length >= 100) {
|
|
@@ -78,3 +85,19 @@ export function findValues(
|
|
|
78
85
|
|
|
79
86
|
return result;
|
|
80
87
|
}
|
|
88
|
+
|
|
89
|
+
function getParameters(original: unknown[]): Parameters {
|
|
90
|
+
const {length} = original;
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
bool:
|
|
94
|
+
length === 1 && typeof original[0] === 'function'
|
|
95
|
+
? original[0]
|
|
96
|
+
: undefined,
|
|
97
|
+
key: length === 2 ? original[0] : undefined,
|
|
98
|
+
value:
|
|
99
|
+
length === 1 && typeof original[0] !== 'function'
|
|
100
|
+
? original[0]
|
|
101
|
+
: original[1],
|
|
102
|
+
};
|
|
103
|
+
}
|
package/types/array/count.d.cts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
// Generated by dts-bundle-generator v9.5.1
|
|
2
2
|
|
|
3
3
|
export type Key = number | string;
|
|
4
|
-
export type ArrayCallback<Item, Value> = (item: Item, index: number, array: Item[]) => Value;
|
|
5
|
-
export type BooleanCallback<Item> = ArrayCallback<Item, boolean>;
|
|
6
|
-
export type KeyCallback<Item> = ArrayCallback<Item, Key>;
|
|
7
4
|
/**
|
|
8
5
|
* Get the number of items _(count)_ that match the given value
|
|
9
6
|
*/
|
|
@@ -11,7 +8,7 @@ export declare function count<Item>(array: Item[], value: Item): number;
|
|
|
11
8
|
/**
|
|
12
9
|
* Get the number of items _(count)_ that match the given value
|
|
13
10
|
*/
|
|
14
|
-
export declare function count<Item>(array: Item[], matches:
|
|
11
|
+
export declare function count<Item>(array: Item[], matches: (item: Item, index: number, array: Item[]) => boolean): number;
|
|
15
12
|
/**
|
|
16
13
|
* Get the number of items _(count)_ that match the given value
|
|
17
14
|
*/
|
|
@@ -19,6 +16,6 @@ export declare function count<Item, Key extends keyof Item>(array: Item[], key:
|
|
|
19
16
|
/**
|
|
20
17
|
* Get the number of items _(count)_ that match the given value
|
|
21
18
|
*/
|
|
22
|
-
export declare function count<Item, Key extends
|
|
19
|
+
export declare function count<Item, Key extends (item: Item, index: number, array: Item[]) => Key>(array: Item[], key: Key, value: ReturnType<Key>): number;
|
|
23
20
|
|
|
24
21
|
export {};
|
package/types/array/count.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Key as SimpleKey } from '~/models';
|
|
2
2
|
/**
|
|
3
3
|
* Get the number of items _(count)_ that match the given value
|
|
4
4
|
*/
|
|
@@ -6,7 +6,7 @@ export declare function count<Item>(array: Item[], value: Item): number;
|
|
|
6
6
|
/**
|
|
7
7
|
* Get the number of items _(count)_ that match the given value
|
|
8
8
|
*/
|
|
9
|
-
export declare function count<Item>(array: Item[], matches:
|
|
9
|
+
export declare function count<Item>(array: Item[], matches: (item: Item, index: number, array: Item[]) => boolean): number;
|
|
10
10
|
/**
|
|
11
11
|
* Get the number of items _(count)_ that match the given value
|
|
12
12
|
*/
|
|
@@ -14,4 +14,4 @@ export declare function count<Item, Key extends keyof Item>(array: Item[], key:
|
|
|
14
14
|
/**
|
|
15
15
|
* Get the number of items _(count)_ that match the given value
|
|
16
16
|
*/
|
|
17
|
-
export declare function count<Item, Key extends
|
|
17
|
+
export declare function count<Item, Key extends (item: Item, index: number, array: Item[]) => SimpleKey>(array: Item[], key: Key, value: ReturnType<Key>): number;
|
package/types/array/exists.d.cts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
// Generated by dts-bundle-generator v9.5.1
|
|
2
2
|
|
|
3
3
|
export type Key = number | string;
|
|
4
|
-
export type ArrayCallback<Item, Value> = (item: Item, index: number, array: Item[]) => Value;
|
|
5
|
-
export type BooleanCallback<Item> = ArrayCallback<Item, boolean>;
|
|
6
|
-
export type KeyCallback<Item> = ArrayCallback<Item, Key>;
|
|
7
4
|
/**
|
|
8
5
|
* Does the value exist in array?
|
|
9
6
|
*/
|
|
@@ -11,7 +8,7 @@ export declare function exists<Item>(array: Item[], value: Item): boolean;
|
|
|
11
8
|
/**
|
|
12
9
|
* Does the value exist in array?
|
|
13
10
|
*/
|
|
14
|
-
export declare function exists<Item>(array: Item[], matches:
|
|
11
|
+
export declare function exists<Item>(array: Item[], matches: (item: Item, index: number, array: Item[]) => boolean): boolean;
|
|
15
12
|
/**
|
|
16
13
|
* - Does the value exist in array?
|
|
17
14
|
* - Use `key` to find a comparison value to match with `value`
|
|
@@ -21,6 +18,6 @@ export declare function exists<Item, Key extends keyof Item>(array: Item[], key:
|
|
|
21
18
|
* - Does the value exist in array?
|
|
22
19
|
* - Use `key` to find a comparison value to match with `value`
|
|
23
20
|
*/
|
|
24
|
-
export declare function exists<Item, Key extends
|
|
21
|
+
export declare function exists<Item, Key extends (item: Item, index: number, array: Item[]) => Key>(array: Item[], key: Key, value: ReturnType<Key>): boolean;
|
|
25
22
|
|
|
26
23
|
export {};
|
package/types/array/exists.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Key as SimpleKey } from '~/models';
|
|
2
2
|
/**
|
|
3
3
|
* Does the value exist in array?
|
|
4
4
|
*/
|
|
@@ -6,7 +6,7 @@ export declare function exists<Item>(array: Item[], value: Item): boolean;
|
|
|
6
6
|
/**
|
|
7
7
|
* Does the value exist in array?
|
|
8
8
|
*/
|
|
9
|
-
export declare function exists<Item>(array: Item[], matches:
|
|
9
|
+
export declare function exists<Item>(array: Item[], matches: (item: Item, index: number, array: Item[]) => boolean): boolean;
|
|
10
10
|
/**
|
|
11
11
|
* - Does the value exist in array?
|
|
12
12
|
* - Use `key` to find a comparison value to match with `value`
|
|
@@ -16,4 +16,4 @@ export declare function exists<Item, Key extends keyof Item>(array: Item[], key:
|
|
|
16
16
|
* - Does the value exist in array?
|
|
17
17
|
* - Use `key` to find a comparison value to match with `value`
|
|
18
18
|
*/
|
|
19
|
-
export declare function exists<Item, Key extends
|
|
19
|
+
export declare function exists<Item, Key extends (item: Item, index: number, array: Item[]) => SimpleKey>(array: Item[], key: Key, value: ReturnType<Key>): boolean;
|
package/types/array/filter.d.cts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
// Generated by dts-bundle-generator v9.5.1
|
|
2
2
|
|
|
3
3
|
export type Key = number | string;
|
|
4
|
-
export type ArrayCallback<Item, Value> = (item: Item, index: number, array: Item[]) => Value;
|
|
5
|
-
export type BooleanCallback<Item> = ArrayCallback<Item, boolean>;
|
|
6
|
-
export type KeyCallback<Item> = ArrayCallback<Item, Key>;
|
|
7
4
|
/**
|
|
8
5
|
* Get a filtered array of items matching `value`
|
|
9
6
|
*/
|
|
@@ -11,7 +8,7 @@ export declare function filter<Item>(array: Item[], value: Item): Item[];
|
|
|
11
8
|
/**
|
|
12
9
|
* Get a filtered array of items matching `value`
|
|
13
10
|
*/
|
|
14
|
-
export declare function filter<Item>(array: Item[], matches:
|
|
11
|
+
export declare function filter<Item>(array: Item[], matches: (item: Item, index: number, array: Item[]) => boolean): Item[];
|
|
15
12
|
/**
|
|
16
13
|
* - Get a filtered array of items
|
|
17
14
|
* - Use `key` to find a comparison value to match with `value`
|
|
@@ -21,6 +18,6 @@ export declare function filter<Item, Key extends keyof Item>(array: Item[], key:
|
|
|
21
18
|
* - Get a filtered array of items
|
|
22
19
|
* - Use `key` to find a comparison value to match with `value`
|
|
23
20
|
*/
|
|
24
|
-
export declare function filter<Item, Key extends
|
|
21
|
+
export declare function filter<Item, Key extends (item: Item, index: number, array: Item[]) => Key>(array: Item[], key: Key, value: ReturnType<Key>): Item[];
|
|
25
22
|
|
|
26
23
|
export {};
|
package/types/array/filter.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Key as SimpleKey } from '~/models';
|
|
2
2
|
/**
|
|
3
3
|
* Get a filtered array of items matching `value`
|
|
4
4
|
*/
|
|
@@ -6,7 +6,7 @@ export declare function filter<Item>(array: Item[], value: Item): Item[];
|
|
|
6
6
|
/**
|
|
7
7
|
* Get a filtered array of items matching `value`
|
|
8
8
|
*/
|
|
9
|
-
export declare function filter<Item>(array: Item[], matches:
|
|
9
|
+
export declare function filter<Item>(array: Item[], matches: (item: Item, index: number, array: Item[]) => boolean): Item[];
|
|
10
10
|
/**
|
|
11
11
|
* - Get a filtered array of items
|
|
12
12
|
* - Use `key` to find a comparison value to match with `value`
|
|
@@ -16,4 +16,4 @@ export declare function filter<Item, Key extends keyof Item>(array: Item[], key:
|
|
|
16
16
|
* - Get a filtered array of items
|
|
17
17
|
* - Use `key` to find a comparison value to match with `value`
|
|
18
18
|
*/
|
|
19
|
-
export declare function filter<Item, Key extends
|
|
19
|
+
export declare function filter<Item, Key extends (item: Item, index: number, array: Item[]) => SimpleKey>(array: Item[], key: Key, value: ReturnType<Key>): Item[];
|
package/types/array/find.d.cts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
// Generated by dts-bundle-generator v9.5.1
|
|
2
2
|
|
|
3
3
|
export type Key = number | string;
|
|
4
|
-
export type ArrayCallback<Item, Value> = (item: Item, index: number, array: Item[]) => Value;
|
|
5
|
-
export type BooleanCallback<Item> = ArrayCallback<Item, boolean>;
|
|
6
|
-
export type KeyCallback<Item> = ArrayCallback<Item, Key>;
|
|
7
4
|
/**
|
|
8
5
|
* Get the first item matching `value` _(or `undefined` if no match is found)_
|
|
9
6
|
*/
|
|
@@ -11,7 +8,7 @@ export declare function find<Item>(array: Item[], value: Item): Item | undefined
|
|
|
11
8
|
/**
|
|
12
9
|
* Get the first item matching `value` _(or `undefined` if no match is found)_
|
|
13
10
|
*/
|
|
14
|
-
export declare function find<Item>(array: Item[], matches:
|
|
11
|
+
export declare function find<Item>(array: Item[], matches: (item: Item, index: number, array: Item[]) => boolean): Item | undefined;
|
|
15
12
|
/**
|
|
16
13
|
* - Get the first matching item _(or `undefined` if no match is found)_
|
|
17
14
|
* - Use `key` to find a comparison value to match with `value`
|
|
@@ -21,6 +18,6 @@ export declare function find<Item, Key extends keyof Item>(array: Item[], key: K
|
|
|
21
18
|
* - Get the first matching item _(or `undefined` if no match is found)_
|
|
22
19
|
* - Use `key` to find a comparison value to match with `value`
|
|
23
20
|
*/
|
|
24
|
-
export declare function find<Item, Key extends
|
|
21
|
+
export declare function find<Item, Key extends (item: Item, index: number, array: Item[]) => Key>(array: Item[], key: Key, value: ReturnType<Key>): Item | undefined;
|
|
25
22
|
|
|
26
23
|
export {};
|
package/types/array/find.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Key as SimpleKey } from '~/models';
|
|
2
2
|
/**
|
|
3
3
|
* Get the first item matching `value` _(or `undefined` if no match is found)_
|
|
4
4
|
*/
|
|
@@ -6,7 +6,7 @@ export declare function find<Item>(array: Item[], value: Item): Item | undefined
|
|
|
6
6
|
/**
|
|
7
7
|
* Get the first item matching `value` _(or `undefined` if no match is found)_
|
|
8
8
|
*/
|
|
9
|
-
export declare function find<Item>(array: Item[], matches:
|
|
9
|
+
export declare function find<Item>(array: Item[], matches: (item: Item, index: number, array: Item[]) => boolean): Item | undefined;
|
|
10
10
|
/**
|
|
11
11
|
* - Get the first matching item _(or `undefined` if no match is found)_
|
|
12
12
|
* - Use `key` to find a comparison value to match with `value`
|
|
@@ -16,4 +16,4 @@ export declare function find<Item, Key extends keyof Item>(array: Item[], key: K
|
|
|
16
16
|
* - Get the first matching item _(or `undefined` if no match is found)_
|
|
17
17
|
* - Use `key` to find a comparison value to match with `value`
|
|
18
18
|
*/
|
|
19
|
-
export declare function find<Item, Key extends
|
|
19
|
+
export declare function find<Item, Key extends (item: Item, index: number, array: Item[]) => SimpleKey>(array: Item[], key: Key, value: ReturnType<Key>): Item | undefined;
|
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
export type KeyedValue<Item, Key extends keyof Item> = Item[Key] extends PropertyKey ? Item[Key] : never;
|
|
4
4
|
export type Key = number | string;
|
|
5
|
-
export type ArrayCallback<Item, Value> = (item: Item, index: number, array: Item[]) => Value;
|
|
6
|
-
export type KeyCallback<Item> = ArrayCallback<Item, Key>;
|
|
7
|
-
export type ValueCallback<Item> = ArrayCallback<Item, unknown>;
|
|
8
5
|
/**
|
|
9
6
|
* Create a record from an array of items using a specific key
|
|
10
7
|
*/
|
|
@@ -16,11 +13,11 @@ export declare function groupBy<Item, Key extends keyof Item>(array: Item[], key
|
|
|
16
13
|
/**
|
|
17
14
|
* Create a record from an array of items using a specific key
|
|
18
15
|
*/
|
|
19
|
-
export declare function groupBy<Item, Key extends
|
|
16
|
+
export declare function groupBy<Item, Key extends (item: Item, index: number, array: Item[]) => Key>(array: Item[], key: Key): Record<ReturnType<Key>, Item>;
|
|
20
17
|
/**
|
|
21
18
|
* Create a record from an array of items using a specific key, and grouping them into arrays
|
|
22
19
|
*/
|
|
23
|
-
export declare function groupBy<Item, Key extends
|
|
20
|
+
export declare function groupBy<Item, Key extends (item: Item, index: number, array: Item[]) => Key>(array: Item[], key: Key, arrays: true): Record<ReturnType<Key>, Item[]>;
|
|
24
21
|
/**
|
|
25
22
|
* Create a record from an array of items using a specific key and value
|
|
26
23
|
*/
|
|
@@ -32,27 +29,27 @@ export declare function groupBy<Item, Key extends keyof Item, Value extends keyo
|
|
|
32
29
|
/**
|
|
33
30
|
* Create a record from an array of items using a specific key and value
|
|
34
31
|
*/
|
|
35
|
-
export declare function groupBy<Item, Key extends keyof Item, Value extends
|
|
32
|
+
export declare function groupBy<Item, Key extends keyof Item, Value extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: Key, value: Value): Record<KeyedValue<Item, Key>, ReturnType<Value>>;
|
|
36
33
|
/**
|
|
37
34
|
* Create a record from an array of items using a specific key and value, and grouping them into arrays
|
|
38
35
|
*/
|
|
39
|
-
export declare function groupBy<Item, Key extends keyof Item, Value extends
|
|
36
|
+
export declare function groupBy<Item, Key extends keyof Item, Value extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: Key, value: Value, arrays: true): Record<KeyedValue<Item, Key>, Array<ReturnType<Value>>>;
|
|
40
37
|
/**
|
|
41
38
|
* Create a record from an array of items using a specific key and value
|
|
42
39
|
*/
|
|
43
|
-
export declare function groupBy<Item, Key extends
|
|
40
|
+
export declare function groupBy<Item, Key extends (item: Item, index: number, array: Item[]) => Key, Value extends keyof Item>(array: Item[], key: Key, value: Value): Record<ReturnType<Key>, KeyedValue<Item, Value>>;
|
|
44
41
|
/**
|
|
45
42
|
* Create a record from an array of items using a specific key and value, and grouping them into arrays
|
|
46
43
|
*/
|
|
47
|
-
export declare function groupBy<Item, Key extends
|
|
44
|
+
export declare function groupBy<Item, Key extends (item: Item, index: number, array: Item[]) => Key, Value extends keyof Item>(array: Item[], key: Key, value: Value, arrays: true): Record<ReturnType<Key>, Array<KeyedValue<Item, Value>>>;
|
|
48
45
|
/**
|
|
49
46
|
* Create a record from an array of items using a specific key and value
|
|
50
47
|
*/
|
|
51
|
-
export declare function groupBy<Item, Key extends
|
|
48
|
+
export declare function groupBy<Item, Key extends (item: Item, index: number, array: Item[]) => Key, Value extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: Key, value: Value): Record<ReturnType<Key>, ReturnType<Value>>;
|
|
52
49
|
/**
|
|
53
50
|
* Create a record from an array of items using a specific key and value, and grouping them into arrays
|
|
54
51
|
*/
|
|
55
|
-
export declare function groupBy<Item, Key extends
|
|
52
|
+
export declare function groupBy<Item, Key extends (item: Item, index: number, array: Item[]) => Key, Value extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: Key, value: Value, arrays: true): Record<ReturnType<Key>, Array<ReturnType<Value>>>;
|
|
56
53
|
export declare function groupValues(array: unknown[], key: unknown, value: unknown, arrays: boolean): Record<Key, unknown>;
|
|
57
54
|
|
|
58
55
|
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Key, KeyedValue } from '~/models';
|
|
1
|
+
import type { Key as SimpleKey, KeyedValue } from '~/models';
|
|
3
2
|
/**
|
|
4
3
|
* Create a record from an array of items using a specific key
|
|
5
4
|
*/
|
|
@@ -11,11 +10,11 @@ export declare function groupBy<Item, Key extends keyof Item>(array: Item[], key
|
|
|
11
10
|
/**
|
|
12
11
|
* Create a record from an array of items using a specific key
|
|
13
12
|
*/
|
|
14
|
-
export declare function groupBy<Item, Key extends
|
|
13
|
+
export declare function groupBy<Item, Key extends (item: Item, index: number, array: Item[]) => SimpleKey>(array: Item[], key: Key): Record<ReturnType<Key>, Item>;
|
|
15
14
|
/**
|
|
16
15
|
* Create a record from an array of items using a specific key, and grouping them into arrays
|
|
17
16
|
*/
|
|
18
|
-
export declare function groupBy<Item, Key extends
|
|
17
|
+
export declare function groupBy<Item, Key extends (item: Item, index: number, array: Item[]) => SimpleKey>(array: Item[], key: Key, arrays: true): Record<ReturnType<Key>, Item[]>;
|
|
19
18
|
/**
|
|
20
19
|
* Create a record from an array of items using a specific key and value
|
|
21
20
|
*/
|
|
@@ -27,25 +26,25 @@ export declare function groupBy<Item, Key extends keyof Item, Value extends keyo
|
|
|
27
26
|
/**
|
|
28
27
|
* Create a record from an array of items using a specific key and value
|
|
29
28
|
*/
|
|
30
|
-
export declare function groupBy<Item, Key extends keyof Item, Value extends
|
|
29
|
+
export declare function groupBy<Item, Key extends keyof Item, Value extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: Key, value: Value): Record<KeyedValue<Item, Key>, ReturnType<Value>>;
|
|
31
30
|
/**
|
|
32
31
|
* Create a record from an array of items using a specific key and value, and grouping them into arrays
|
|
33
32
|
*/
|
|
34
|
-
export declare function groupBy<Item, Key extends keyof Item, Value extends
|
|
33
|
+
export declare function groupBy<Item, Key extends keyof Item, Value extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: Key, value: Value, arrays: true): Record<KeyedValue<Item, Key>, Array<ReturnType<Value>>>;
|
|
35
34
|
/**
|
|
36
35
|
* Create a record from an array of items using a specific key and value
|
|
37
36
|
*/
|
|
38
|
-
export declare function groupBy<Item, Key extends
|
|
37
|
+
export declare function groupBy<Item, Key extends (item: Item, index: number, array: Item[]) => SimpleKey, Value extends keyof Item>(array: Item[], key: Key, value: Value): Record<ReturnType<Key>, KeyedValue<Item, Value>>;
|
|
39
38
|
/**
|
|
40
39
|
* Create a record from an array of items using a specific key and value, and grouping them into arrays
|
|
41
40
|
*/
|
|
42
|
-
export declare function groupBy<Item, Key extends
|
|
41
|
+
export declare function groupBy<Item, Key extends (item: Item, index: number, array: Item[]) => SimpleKey, Value extends keyof Item>(array: Item[], key: Key, value: Value, arrays: true): Record<ReturnType<Key>, Array<KeyedValue<Item, Value>>>;
|
|
43
42
|
/**
|
|
44
43
|
* Create a record from an array of items using a specific key and value
|
|
45
44
|
*/
|
|
46
|
-
export declare function groupBy<Item, Key extends
|
|
45
|
+
export declare function groupBy<Item, Key extends (item: Item, index: number, array: Item[]) => SimpleKey, Value extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: Key, value: Value): Record<ReturnType<Key>, ReturnType<Value>>;
|
|
47
46
|
/**
|
|
48
47
|
* Create a record from an array of items using a specific key and value, and grouping them into arrays
|
|
49
48
|
*/
|
|
50
|
-
export declare function groupBy<Item, Key extends
|
|
51
|
-
export declare function groupValues(array: unknown[], key: unknown, value: unknown, arrays: boolean): Record<
|
|
49
|
+
export declare function groupBy<Item, Key extends (item: Item, index: number, array: Item[]) => SimpleKey, Value extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: Key, value: Value, arrays: true): Record<ReturnType<Key>, Array<ReturnType<Value>>>;
|
|
50
|
+
export declare function groupValues(array: unknown[], key: unknown, value: unknown, arrays: boolean): Record<SimpleKey, unknown>;
|