@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.
Files changed (59) hide show
  1. package/dist/js/array/count.cjs +1 -8
  2. package/dist/js/array/count.js +1 -8
  3. package/dist/js/array/exists.cjs +1 -8
  4. package/dist/js/array/exists.js +1 -8
  5. package/dist/js/array/filter.cjs +1 -8
  6. package/dist/js/array/filter.js +1 -8
  7. package/dist/js/array/find.cjs +1 -8
  8. package/dist/js/array/find.js +1 -8
  9. package/dist/js/array/index-of.cjs +1 -8
  10. package/dist/js/array/index-of.js +1 -8
  11. package/dist/js/array/unique.cjs +1 -1
  12. package/dist/js/array/unique.js +1 -1
  13. package/dist/js/internal/array/find.cjs +12 -2
  14. package/dist/js/internal/array/find.js +12 -2
  15. package/package.json +11 -4
  16. package/src/js/array/count.ts +7 -20
  17. package/src/js/array/exists.ts +7 -22
  18. package/src/js/array/filter.ts +7 -20
  19. package/src/js/array/find.ts +7 -20
  20. package/src/js/array/group-by.ts +19 -21
  21. package/src/js/array/index-of.ts +7 -20
  22. package/src/js/array/models.ts +2 -16
  23. package/src/js/array/sort.ts +3 -7
  24. package/src/js/array/to-map.ts +19 -21
  25. package/src/js/array/to-record.ts +17 -19
  26. package/src/js/array/unique.ts +8 -8
  27. package/src/js/internal/array/callbacks.ts +4 -4
  28. package/src/js/internal/array/find.ts +29 -6
  29. package/types/array/count.d.cts +2 -5
  30. package/types/array/count.d.ts +3 -3
  31. package/types/array/exists.d.cts +2 -5
  32. package/types/array/exists.d.ts +3 -3
  33. package/types/array/filter.d.cts +2 -5
  34. package/types/array/filter.d.ts +3 -3
  35. package/types/array/find.d.cts +2 -5
  36. package/types/array/find.d.ts +3 -3
  37. package/types/array/group-by.d.cts +8 -11
  38. package/types/array/group-by.d.ts +10 -11
  39. package/types/array/index-of.d.cts +2 -5
  40. package/types/array/index-of.d.ts +3 -3
  41. package/types/array/index.d.cts +43 -48
  42. package/types/array/models.d.cts +2 -7
  43. package/types/array/models.d.ts +2 -7
  44. package/types/array/sort.d.cts +3 -4
  45. package/types/array/sort.d.ts +3 -3
  46. package/types/array/to-map.d.cts +8 -11
  47. package/types/array/to-map.d.ts +9 -10
  48. package/types/array/to-record.d.cts +8 -11
  49. package/types/array/to-record.d.ts +9 -10
  50. package/types/array/unique.d.cts +3 -5
  51. package/types/array/unique.d.ts +4 -4
  52. package/types/index.d.cts +321 -1019
  53. package/types/internal/array/find.d.cts +2 -2
  54. package/types/internal/array/find.d.ts +2 -2
  55. package/types/models.d.cts +210 -467
  56. package/types/value/get.d.cts +210 -469
  57. package/types/value/index.d.cts +223 -514
  58. package/types/value/set.d.cts +169 -356
  59. package/types/value/smush.d.cts +209 -463
@@ -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> | SortKeyCallback<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> | SortKeyCallback<Item>>,
27
+ keys: Array<Key | SortKey<Item> | ((item: Item) => Key)>,
32
28
  descending?: boolean,
33
29
  ): Item[];
34
30
 
@@ -1,6 +1,5 @@
1
- import type {KeyCallback, ValueCallback} from '~/array/models';
2
1
  import {getCallbacks} from '~/internal/array/callbacks';
3
- import type {Key, KeyedValue} from '~/models';
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<Item, Key extends KeyCallback<Item>>(
31
- array: Item[],
32
- key: Key,
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<Item, Key extends KeyCallback<Item>>(
39
- array: Item[],
40
- key: Key,
41
- arrays: true,
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 ValueCallback<Item>,
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 ValueCallback<Item>,
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 KeyCallback<Item>,
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 KeyCallback<Item>,
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 KeyCallback<Item>,
123
- Value extends ValueCallback<Item>,
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 KeyCallback<Item>,
136
- Value extends ValueCallback<Item>,
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<Key, unknown> {
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<Key, unknown>();
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 {KeyCallback, ValueCallback} from '~/array/models';
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<Item, Key extends KeyCallback<Item>>(
31
- array: Item[],
32
- key: Key,
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<Item, Key extends KeyCallback<Item>>(
39
- array: Item[],
40
- key: Key,
41
- arrays: true,
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 ValueCallback<Item>,
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 ValueCallback<Item>,
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 KeyCallback<Item>,
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 KeyCallback<Item>,
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 KeyCallback<Item>,
131
- Value extends ValueCallback<Item>,
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 KeyCallback<Item>,
144
- Value extends ValueCallback<Item>,
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,
@@ -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 to match with `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 to match with `value`
20
+ * - Use `key` to find a comparison value for an item
21
21
  */
22
- export function unique<Item, Key extends KeyCallback<Item>>(
23
- array: Item[],
24
- key: Key,
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, undefined, key, undefined);
28
+ return findValues('unique', array, [key, undefined]);
29
29
  }
@@ -1,4 +1,4 @@
1
- import type {BooleanCallback, Callbacks, KeyCallback} from '~/array/models';
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 BooleanCallback<unknown>};
26
+ return {bool: bool as GenericCallback};
27
27
  }
28
28
 
29
29
  return {
30
- key: getCallback(key) as KeyCallback<unknown>,
31
- value: getCallback(value) as GenericCallback,
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
- bool: unknown,
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
- bool: unknown,
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
+ }
@@ -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: BooleanCallback<Item>): number;
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 KeyCallback<Item>>(array: Item[], key: Key, value: ReturnType<Key>): number;
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 {};
@@ -1,4 +1,4 @@
1
- import type { BooleanCallback, KeyCallback } from '~/array/models';
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: BooleanCallback<Item>): number;
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 KeyCallback<Item>>(array: Item[], key: Key, value: ReturnType<Key>): number;
17
+ export declare function count<Item, Key extends (item: Item, index: number, array: Item[]) => SimpleKey>(array: Item[], key: Key, value: ReturnType<Key>): number;
@@ -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: BooleanCallback<Item>): boolean;
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 KeyCallback<Item>>(array: Item[], key: Key, value: ReturnType<Key>): boolean;
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 {};
@@ -1,4 +1,4 @@
1
- import type { BooleanCallback, KeyCallback } from './models';
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: BooleanCallback<Item>): boolean;
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 KeyCallback<Item>>(array: Item[], key: Key, value: ReturnType<Key>): boolean;
19
+ export declare function exists<Item, Key extends (item: Item, index: number, array: Item[]) => SimpleKey>(array: Item[], key: Key, value: ReturnType<Key>): boolean;
@@ -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: BooleanCallback<Item>): Item[];
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 KeyCallback<Item>>(array: Item[], key: Key, value: ReturnType<Key>): Item[];
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 {};
@@ -1,4 +1,4 @@
1
- import type { BooleanCallback, KeyCallback } from '~/array/models';
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: BooleanCallback<Item>): Item[];
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 KeyCallback<Item>>(array: Item[], key: Key, value: ReturnType<Key>): Item[];
19
+ export declare function filter<Item, Key extends (item: Item, index: number, array: Item[]) => SimpleKey>(array: Item[], key: Key, value: ReturnType<Key>): Item[];
@@ -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: BooleanCallback<Item>): Item | undefined;
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 KeyCallback<Item>>(array: Item[], key: Key, value: ReturnType<Key>): Item | undefined;
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 {};
@@ -1,4 +1,4 @@
1
- import type { BooleanCallback, KeyCallback } from '~/array/models';
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: BooleanCallback<Item>): Item | undefined;
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 KeyCallback<Item>>(array: Item[], key: Key, value: ReturnType<Key>): Item | undefined;
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 KeyCallback<Item>>(array: Item[], key: Key): Record<ReturnType<Key>, Item>;
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 KeyCallback<Item>>(array: Item[], key: Key, arrays: true): Record<ReturnType<Key>, Item[]>;
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 ValueCallback<Item>>(array: Item[], key: Key, value: Value): Record<KeyedValue<Item, Key>, ReturnType<Value>>;
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 ValueCallback<Item>>(array: Item[], key: Key, value: Value, arrays: true): Record<KeyedValue<Item, Key>, Array<ReturnType<Value>>>;
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 KeyCallback<Item>, Value extends keyof Item>(array: Item[], key: Key, value: Value): Record<ReturnType<Key>, KeyedValue<Item, Value>>;
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 KeyCallback<Item>, Value extends keyof Item>(array: Item[], key: Key, value: Value, arrays: true): Record<ReturnType<Key>, Array<KeyedValue<Item, Value>>>;
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 KeyCallback<Item>, Value extends ValueCallback<Item>>(array: Item[], key: Key, value: Value): Record<ReturnType<Key>, ReturnType<Value>>;
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 KeyCallback<Item>, Value extends ValueCallback<Item>>(array: Item[], key: Key, value: Value, arrays: true): Record<ReturnType<Key>, Array<ReturnType<Value>>>;
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 { KeyCallback, ValueCallback } from '~/array/models';
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 KeyCallback<Item>>(array: Item[], key: Key): Record<ReturnType<Key>, Item>;
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 KeyCallback<Item>>(array: Item[], key: Key, arrays: true): Record<ReturnType<Key>, Item[]>;
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 ValueCallback<Item>>(array: Item[], key: Key, value: Value): Record<KeyedValue<Item, Key>, ReturnType<Value>>;
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 ValueCallback<Item>>(array: Item[], key: Key, value: Value, arrays: true): Record<KeyedValue<Item, Key>, Array<ReturnType<Value>>>;
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 KeyCallback<Item>, Value extends keyof Item>(array: Item[], key: Key, value: Value): Record<ReturnType<Key>, KeyedValue<Item, Value>>;
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 KeyCallback<Item>, Value extends keyof Item>(array: Item[], key: Key, value: Value, arrays: true): Record<ReturnType<Key>, Array<KeyedValue<Item, Value>>>;
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 KeyCallback<Item>, Value extends ValueCallback<Item>>(array: Item[], key: Key, value: Value): Record<ReturnType<Key>, ReturnType<Value>>;
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 KeyCallback<Item>, Value extends ValueCallback<Item>>(array: Item[], key: Key, value: Value, arrays: true): Record<ReturnType<Key>, Array<ReturnType<Value>>>;
51
- export declare function groupValues(array: unknown[], key: unknown, value: unknown, arrays: boolean): Record<Key, unknown>;
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>;