@oscarpalmer/atoms 0.201.0 → 0.203.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 (156) hide show
  1. package/dist/array/difference.d.mts +4 -5
  2. package/dist/array/exists.d.mts +5 -6
  3. package/dist/array/filter.d.mts +10 -11
  4. package/dist/array/find.d.mts +10 -11
  5. package/dist/array/first.d.mts +10 -11
  6. package/dist/array/flatten.d.mts +2 -3
  7. package/dist/array/from.d.mts +7 -8
  8. package/dist/array/group-by.d.mts +16 -185
  9. package/dist/array/insert.d.mts +3 -4
  10. package/dist/array/intersection.d.mts +4 -5
  11. package/dist/array/last.d.mts +10 -11
  12. package/dist/array/move.d.mts +9 -10
  13. package/dist/array/partition.d.mts +5 -6
  14. package/dist/array/push.d.mts +2 -3
  15. package/dist/array/reverse.d.mts +2 -3
  16. package/dist/array/select.d.mts +11 -12
  17. package/dist/array/single.d.mts +4 -5
  18. package/dist/array/slice.d.mts +12 -13
  19. package/dist/array/sort.d.mts +31 -32
  20. package/dist/array/sort.mjs +41 -33
  21. package/dist/array/splice.d.mts +5 -6
  22. package/dist/array/swap.d.mts +8 -9
  23. package/dist/array/to-map.d.mts +18 -175
  24. package/dist/array/to-record.d.mts +18 -175
  25. package/dist/array/to-set.d.mts +4 -5
  26. package/dist/array/toggle.d.mts +4 -5
  27. package/dist/array/union.d.mts +4 -5
  28. package/dist/array/unique.d.mts +4 -5
  29. package/dist/array/update.d.mts +4 -5
  30. package/dist/beacon.d.mts +8 -9
  31. package/dist/beacon.mjs +90 -65
  32. package/dist/color/constants.d.mts +14 -13
  33. package/dist/color/constants.mjs +9 -2
  34. package/dist/color/index.d.mts +2 -2
  35. package/dist/color/instance.d.mts +3 -3
  36. package/dist/color/instance.mjs +125 -61
  37. package/dist/color/misc/alpha.d.mts +4 -5
  38. package/dist/color/misc/format.d.mts +6 -7
  39. package/dist/color/misc/format.mjs +15 -12
  40. package/dist/color/misc/get.d.mts +14 -15
  41. package/dist/color/misc/is.d.mts +16 -17
  42. package/dist/color/misc/is.mjs +3 -4
  43. package/dist/color/misc/state.d.mts +8 -10
  44. package/dist/color/misc/state.mjs +22 -20
  45. package/dist/color/models.d.mts +25 -19
  46. package/dist/color/space/hex.d.mts +9 -10
  47. package/dist/color/space/hsl.d.mts +8 -9
  48. package/dist/color/space/hwb.d.mts +9 -10
  49. package/dist/color/space/rgb.d.mts +11 -12
  50. package/dist/function/limit.d.mts +9 -8
  51. package/dist/function/limit.mjs +5 -5
  52. package/dist/function/once.d.mts +26 -6
  53. package/dist/function/once.mjs +135 -76
  54. package/dist/function/retry.d.mts +5 -6
  55. package/dist/function/retry.mjs +3 -3
  56. package/dist/index.d.mts +244 -584
  57. package/dist/index.mjs +1191 -810
  58. package/dist/internal/abort.d.mts +3 -4
  59. package/dist/internal/array/callbacks.d.mts +4 -5
  60. package/dist/internal/array/chunk.d.mts +2 -3
  61. package/dist/internal/array/compact.d.mts +3 -4
  62. package/dist/internal/array/find.d.mts +10 -11
  63. package/dist/internal/array/get.d.mts +7 -8
  64. package/dist/internal/array/group.d.mts +2 -3
  65. package/dist/internal/array/index-of.d.mts +10 -11
  66. package/dist/internal/array/insert.d.mts +5 -6
  67. package/dist/internal/array/match.d.mts +17 -18
  68. package/dist/internal/array/overlap.d.mts +2 -3
  69. package/dist/internal/array/sets.d.mts +5 -6
  70. package/dist/internal/array/shuffle.d.mts +2 -3
  71. package/dist/internal/array/update.d.mts +2 -3
  72. package/dist/internal/defaults.d.mts +3 -4
  73. package/dist/internal/function/assert.d.mts +10 -11
  74. package/dist/internal/function/limit.d.mts +41 -0
  75. package/dist/internal/function/limit.mjs +110 -0
  76. package/dist/internal/function/memoize.d.mts +4 -5
  77. package/dist/internal/function/memoize.mjs +53 -31
  78. package/dist/internal/function/misc.d.mts +2 -3
  79. package/dist/internal/function/work.d.mts +53 -54
  80. package/dist/internal/herald.d.mts +8 -9
  81. package/dist/internal/herald.mjs +38 -26
  82. package/dist/internal/is.d.mts +19 -20
  83. package/dist/internal/math/aggregate.d.mts +14 -15
  84. package/dist/internal/math/misc.d.mts +3 -4
  85. package/dist/internal/number.d.mts +4 -5
  86. package/dist/internal/random.d.mts +3 -4
  87. package/dist/internal/result/misc.d.mts +29 -14
  88. package/dist/internal/result/misc.mjs +4 -0
  89. package/dist/internal/result/models.d.mts +9 -10
  90. package/dist/internal/sized/map.d.mts +2 -3
  91. package/dist/internal/sized/misc.d.mts +2 -3
  92. package/dist/internal/string/case.d.mts +9 -10
  93. package/dist/internal/string/misc.d.mts +8 -9
  94. package/dist/internal/subscription.d.mts +14 -15
  95. package/dist/internal/subscription.mjs +69 -57
  96. package/dist/internal/value/compare.d.mts +17 -9
  97. package/dist/internal/value/compare.mjs +7 -7
  98. package/dist/internal/value/equal.d.mts +34 -15
  99. package/dist/internal/value/equal.mjs +28 -13
  100. package/dist/internal/value/get.d.mts +3 -4
  101. package/dist/internal/value/handlers.d.mts +19 -9
  102. package/dist/internal/value/handlers.mjs +50 -50
  103. package/dist/internal/value/has.d.mts +6 -7
  104. package/dist/internal/value/misc.d.mts +6 -7
  105. package/dist/internal/value/partial.d.mts +3 -4
  106. package/dist/internal/value/set.d.mts +4 -5
  107. package/dist/is.d.mts +13 -13
  108. package/dist/logger.d.mts +5 -4
  109. package/dist/logger.mjs +61 -54
  110. package/dist/math.d.mts +20 -20
  111. package/dist/models.d.mts +58 -46
  112. package/dist/promise/constants.d.mts +14 -15
  113. package/dist/promise/delay.d.mts +3 -4
  114. package/dist/promise/delay.mjs +4 -4
  115. package/dist/promise/helpers.d.mts +7 -8
  116. package/dist/promise/index.d.mts +13 -14
  117. package/dist/promise/misc.d.mts +6 -6
  118. package/dist/promise/models.d.mts +16 -17
  119. package/dist/promise/timed.d.mts +4 -5
  120. package/dist/promise/timed.mjs +5 -5
  121. package/dist/query.d.mts +3 -4
  122. package/dist/queue.d.mts +14 -15
  123. package/dist/queue.mjs +185 -129
  124. package/dist/random.d.mts +8 -8
  125. package/dist/result/index.d.mts +8 -9
  126. package/dist/result/match.d.mts +6 -7
  127. package/dist/result/misc.d.mts +3 -3
  128. package/dist/result/work/flow.d.mts +28 -29
  129. package/dist/result/work/pipe.d.mts +24 -25
  130. package/dist/sized/set.d.mts +2 -3
  131. package/dist/string/fuzzy.d.mts +21 -12
  132. package/dist/string/fuzzy.mjs +77 -49
  133. package/dist/string/index.d.mts +8 -8
  134. package/dist/string/match.d.mts +4 -5
  135. package/dist/string/normalize.d.mts +8 -9
  136. package/dist/string/normalize.mjs +9 -4
  137. package/dist/string/template.d.mts +9 -9
  138. package/dist/string/template.mjs +11 -4
  139. package/dist/value/clone.d.mts +21 -13
  140. package/dist/value/clone.mjs +22 -20
  141. package/dist/value/collection.d.mts +4 -5
  142. package/dist/value/diff.d.mts +5 -6
  143. package/dist/value/freeze.d.mts +18 -19
  144. package/dist/value/freeze.mjs +1 -1
  145. package/dist/value/merge.d.mts +13 -14
  146. package/dist/value/merge.mjs +21 -5
  147. package/dist/value/omit.d.mts +2 -3
  148. package/dist/value/pick.d.mts +2 -3
  149. package/dist/value/shake.d.mts +3 -4
  150. package/dist/value/smush.d.mts +3 -4
  151. package/dist/value/transform.d.mts +15 -10
  152. package/dist/value/transform.mjs +12 -7
  153. package/dist/value/unsmush.d.mts +3 -4
  154. package/package.json +1 -1
  155. package/dist/internal/function/timer.d.mts +0 -10
  156. package/dist/internal/function/timer.mjs +0 -87
@@ -17,7 +17,7 @@ import { PlainObject } from "../models.mjs";
17
17
  * ); // => [{id: 1}, {id: 3}]
18
18
  * ```
19
19
  */
20
- declare function difference<First, Second>(first: First[], second: Second[], callback: (item: First | Second) => unknown): First[];
20
+ export declare function difference<First, Second>(first: First[], second: Second[], callback: (item: First | Second) => unknown): First[];
21
21
  /**
22
22
  * Get the items from the first array that are not in the second array
23
23
  *
@@ -35,7 +35,7 @@ declare function difference<First, Second>(first: First[], second: Second[], cal
35
35
  * ); // => [{id: 1}, {id: 3}]
36
36
  * ```
37
37
  */
38
- declare function difference<First extends PlainObject, Second extends PlainObject, SharedKey extends keyof First & keyof Second>(first: First[], second: Second[], key: SharedKey): First[];
38
+ export declare function difference<First extends PlainObject, Second extends PlainObject, SharedKey extends keyof First & keyof Second>(first: First[], second: Second[], key: SharedKey): First[];
39
39
  /**
40
40
  * Get the items from the first array that are not in the second array
41
41
  *
@@ -51,6 +51,5 @@ declare function difference<First extends PlainObject, Second extends PlainObjec
51
51
  * ); // => [1, 3]
52
52
  * ```
53
53
  */
54
- declare function difference<First, Second>(first: First[], second: Second[]): First[];
55
- //#endregion
56
- export { difference };
54
+ export declare function difference<First, Second>(first: First[], second: Second[]): First[];
55
+ //#endregion
@@ -17,7 +17,7 @@ import { PlainObject } from "../models.mjs";
17
17
  * ); // => true
18
18
  * ```
19
19
  */
20
- declare function exists<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): boolean;
20
+ export declare function exists<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): boolean;
21
21
  /**
22
22
  * Does an item with a specific value exist in the array?
23
23
  *
@@ -35,7 +35,7 @@ declare function exists<Item, Callback extends (item: Item, index: number, array
35
35
  * ); // => true
36
36
  * ```
37
37
  */
38
- declare function exists<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): boolean;
38
+ export declare function exists<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): boolean;
39
39
  /**
40
40
  * Does an item in the array match the filter?
41
41
  *
@@ -51,7 +51,7 @@ declare function exists<Item extends PlainObject, ItemKey extends keyof Item>(ar
51
51
  * ); // => true
52
52
  * ```
53
53
  */
54
- declare function exists<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): boolean;
54
+ export declare function exists<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): boolean;
55
55
  /**
56
56
  * Does the item exist in the array?
57
57
  *
@@ -64,6 +64,5 @@ declare function exists<Item>(array: Item[], filter: (item: Item, index: number,
64
64
  * exists([1, 2, 3], 2); // => true
65
65
  * ```
66
66
  */
67
- declare function exists<Item>(array: Item[], item: Item): boolean;
68
- //#endregion
69
- export { exists };
67
+ export declare function exists<Item>(array: Item[], item: Item): boolean;
68
+ //#endregion
@@ -19,7 +19,7 @@ import { PlainObject } from "../models.mjs";
19
19
  * ); // => [{id: 1}, {id: 3}]
20
20
  * ```
21
21
  */
22
- declare function exclude<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): unknown[];
22
+ export declare function exclude<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): unknown[];
23
23
  /**
24
24
  * Get a filtered array of items that do not match the value
25
25
  *
@@ -39,7 +39,7 @@ declare function exclude<Item, Callback extends (item: Item, index: number, arra
39
39
  * ); // => [{id: 1}, {id: 3}]
40
40
  * ```
41
41
  */
42
- declare function exclude<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): unknown[];
42
+ export declare function exclude<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): unknown[];
43
43
  /**
44
44
  * Get a filtered array of items that do not match the filter
45
45
  *
@@ -57,7 +57,7 @@ declare function exclude<Item extends PlainObject, ItemKey extends keyof Item>(a
57
57
  * ); // => [{id: 1}, {id: 3}]
58
58
  * ```
59
59
  */
60
- declare function exclude<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): unknown[];
60
+ export declare function exclude<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): unknown[];
61
61
  /**
62
62
  * Get a filtered array of items that do not match the given item
63
63
  *
@@ -72,7 +72,7 @@ declare function exclude<Item>(array: Item[], filter: (item: Item, index: number
72
72
  * exclude([1, 2, 3], 2); // => [1, 3]
73
73
  * ```
74
74
  */
75
- declare function exclude<Item>(array: Item[], item: Item): unknown[];
75
+ export declare function exclude<Item>(array: Item[], item: Item): unknown[];
76
76
  /**
77
77
  * Get a filtered array of items
78
78
  *
@@ -90,7 +90,7 @@ declare function exclude<Item>(array: Item[], item: Item): unknown[];
90
90
  * ); // => [{id: 2}]
91
91
  * ```
92
92
  */
93
- declare function filter<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): Item[];
93
+ export declare function filter<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): Item[];
94
94
  /**
95
95
  * Get a filtered array of items
96
96
  *
@@ -108,7 +108,7 @@ declare function filter<Item, Callback extends (item: Item, index: number, array
108
108
  * ); // => [{id: 2}]
109
109
  * ```
110
110
  */
111
- declare function filter<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): Item[];
111
+ export declare function filter<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): Item[];
112
112
  /**
113
113
  * Get a filtered array of items matching the filter
114
114
  *
@@ -124,7 +124,7 @@ declare function filter<Item extends PlainObject, ItemKey extends keyof Item>(ar
124
124
  * ); // => [{id: 2}]
125
125
  * ```
126
126
  */
127
- declare function filter<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): Item[];
127
+ export declare function filter<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): Item[];
128
128
  /**
129
129
  * Get a filtered array of items matching the given item
130
130
  *
@@ -137,9 +137,8 @@ declare function filter<Item>(array: Item[], filter: (item: Item, index: number,
137
137
  * filter([1, 2, 3], 2); // => [2]
138
138
  * ```
139
139
  */
140
- declare function filter<Item>(array: Item[], item: Item): Item[];
141
- declare namespace filter {
140
+ export declare function filter<Item>(array: Item[], item: Item): Item[];
141
+ export declare namespace filter {
142
142
  var remove: typeof exclude;
143
143
  }
144
- //#endregion
145
- export { exclude, filter };
144
+ //#endregion
@@ -17,7 +17,7 @@ import { PlainObject } from "../models.mjs";
17
17
  * ); // => {id: 1, value: 10}
18
18
  * ```
19
19
  */
20
- declare function find<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): Item | undefined;
20
+ export declare function find<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): Item | undefined;
21
21
  /**
22
22
  * Get the first item matching the given value by key
23
23
  *
@@ -35,7 +35,7 @@ declare function find<Item, Callback extends (item: Item, index: number, array:
35
35
  * ); // => {id: 1, value: 10}
36
36
  * ```
37
37
  */
38
- declare function find<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): Item | undefined;
38
+ export declare function find<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): Item | undefined;
39
39
  /**
40
40
  * Get the first item matching the filter
41
41
  *
@@ -51,7 +51,7 @@ declare function find<Item extends PlainObject, ItemKey extends keyof Item>(arra
51
51
  * ); // => {id: 1, value: 10}
52
52
  * ```
53
53
  */
54
- declare function find<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): Item | undefined;
54
+ export declare function find<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): Item | undefined;
55
55
  /**
56
56
  * Get the first item matching the given value
57
57
  *
@@ -64,8 +64,8 @@ declare function find<Item>(array: Item[], filter: (item: Item, index: number, a
64
64
  * find([1, 2, 3, 2, 1], 1); // => 1
65
65
  * ```
66
66
  */
67
- declare function find<Item>(array: Item[], value: Item): Item | undefined;
68
- declare namespace find {
67
+ export declare function find<Item>(array: Item[], value: Item): Item | undefined;
68
+ export declare namespace find {
69
69
  var last: typeof findLast;
70
70
  }
71
71
  /**
@@ -87,7 +87,7 @@ declare namespace find {
87
87
  * ); // => {id: 3, value: 10}
88
88
  * ```
89
89
  */
90
- declare function findLast<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): Item | undefined;
90
+ export declare function findLast<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): Item | undefined;
91
91
  /**
92
92
  * Get the last item matching the given value by key
93
93
  *
@@ -107,7 +107,7 @@ declare function findLast<Item, Callback extends (item: Item, index: number, arr
107
107
  * ); // => {id: 3, value: 10}
108
108
  * ```
109
109
  */
110
- declare function findLast<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): Item | undefined;
110
+ export declare function findLast<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): Item | undefined;
111
111
  /**
112
112
  * Get the last item matching the filter
113
113
  *
@@ -125,7 +125,7 @@ declare function findLast<Item extends PlainObject, ItemKey extends keyof Item>(
125
125
  * ); // => {id: 3, value: 10}
126
126
  * ```
127
127
  */
128
- declare function findLast<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): Item | undefined;
128
+ export declare function findLast<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): Item | undefined;
129
129
  /**
130
130
  * Get the last item matching the given value
131
131
  *
@@ -140,6 +140,5 @@ declare function findLast<Item>(array: Item[], filter: (item: Item, index: numbe
140
140
  * findLast([1, 2, 3, 2, 1], 1); // => 1
141
141
  * ```
142
142
  */
143
- declare function findLast<Item>(array: Item[], value: Item): Item | undefined;
144
- //#endregion
145
- export { find, findLast };
143
+ export declare function findLast<Item>(array: Item[], value: Item): Item | undefined;
144
+ //#endregion
@@ -17,7 +17,7 @@ import { PlainObject } from "../models.mjs";
17
17
  * ); // => {id: 1, value: 10}
18
18
  * ```
19
19
  */
20
- declare function first<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): Item | undefined;
20
+ export declare function first<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): Item | undefined;
21
21
  /**
22
22
  * Get the first item matching the given value by key
23
23
  *
@@ -35,7 +35,7 @@ declare function first<Item, Callback extends (item: Item, index: number, array:
35
35
  * ); // => {id: 1, value: 10}
36
36
  * ```
37
37
  */
38
- declare function first<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): Item | undefined;
38
+ export declare function first<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): Item | undefined;
39
39
  /**
40
40
  * Get the first item matching the filter
41
41
  *
@@ -51,7 +51,7 @@ declare function first<Item extends PlainObject, ItemKey extends keyof Item>(arr
51
51
  * ); // => {id: 1, value: 10}
52
52
  * ```
53
53
  */
54
- declare function first<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): Item | undefined;
54
+ export declare function first<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): Item | undefined;
55
55
  /**
56
56
  * Get the first item from an array
57
57
  *
@@ -65,8 +65,8 @@ declare function first<Item>(array: Item[], filter: (item: Item, index: number,
65
65
  * ); // => {id: 1, value: 10}
66
66
  * ```
67
67
  */
68
- declare function first<Item>(array: Item[]): Item | undefined;
69
- declare namespace first {
68
+ export declare function first<Item>(array: Item[]): Item | undefined;
69
+ export declare namespace first {
70
70
  var _a: typeof firstOrDefault;
71
71
  export { _a as default };
72
72
  }
@@ -91,7 +91,7 @@ declare namespace first {
91
91
  * ); // => {id: -1, value: 30}
92
92
  * ```
93
93
  */
94
- declare function firstOrDefault<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], defaultValue: Item, callback: Callback, value: ReturnType<Callback>): Item;
94
+ export declare function firstOrDefault<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], defaultValue: Item, callback: Callback, value: ReturnType<Callback>): Item;
95
95
  /**
96
96
  * Get the first item matching the given value by key, or a default value if no match is found
97
97
  *
@@ -113,7 +113,7 @@ declare function firstOrDefault<Item, Callback extends (item: Item, index: numbe
113
113
  * ); // => {id: -1, value: 30}
114
114
  * ```
115
115
  */
116
- declare function firstOrDefault<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], defaultValue: Item, key: ItemKey, value: Item[ItemKey]): Item;
116
+ export declare function firstOrDefault<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], defaultValue: Item, key: ItemKey, value: Item[ItemKey]): Item;
117
117
  /**
118
118
  * Get the first item matching the filter, or a default value if no match is found
119
119
  *
@@ -133,7 +133,7 @@ declare function firstOrDefault<Item extends PlainObject, ItemKey extends keyof
133
133
  * ); // => {id: -1, value: 30}
134
134
  * ```
135
135
  */
136
- declare function firstOrDefault<Item>(array: Item[], defaultValue: Item, filter: (item: Item, index: number, array: Item[]) => boolean): Item;
136
+ export declare function firstOrDefault<Item>(array: Item[], defaultValue: Item, filter: (item: Item, index: number, array: Item[]) => boolean): Item;
137
137
  /**
138
138
  * Get the first item from an array, or a default value if the array is empty
139
139
  *
@@ -148,6 +148,5 @@ declare function firstOrDefault<Item>(array: Item[], defaultValue: Item, filter:
148
148
  * firstOrDefault([], {id: -1, value: 30}); // => {id: -1, value: 30}
149
149
  * ```
150
150
  */
151
- declare function firstOrDefault<Item>(array: Item[], defaultValue: Item): Item;
152
- //#endregion
153
- export { first, firstOrDefault };
151
+ export declare function firstOrDefault<Item>(array: Item[], defaultValue: Item): Item;
152
+ //#endregion
@@ -11,6 +11,5 @@ import { NestedArray } from "../models.mjs";
11
11
  * flatten([1, [2, [3, 4], 5], 6]); // => [1, 2, 3, 4, 5, 6]
12
12
  * ```
13
13
  */
14
- declare function flatten<Item>(array: Item[]): Array<NestedArray<Item>>;
15
- //#endregion
16
- export { flatten };
14
+ export declare function flatten<Item>(array: Item[]): Array<NestedArray<Item>>;
15
+ //#endregion
@@ -10,7 +10,7 @@
10
10
  * range(5); // => [0, 1, 2, 3, 4]
11
11
  * ```
12
12
  */
13
- declare function range(length: number): number[];
13
+ export declare function range(length: number): number[];
14
14
  /**
15
15
  * Get an array of numbers in a specified range
16
16
  *
@@ -23,7 +23,7 @@ declare function range(length: number): number[];
23
23
  * range(2, 5); // => [2, 3, 4]
24
24
  * ```
25
25
  */
26
- declare function range(start: number, end: number): number[];
26
+ export declare function range(start: number, end: number): number[];
27
27
  /**
28
28
  * Get an array of numbers in a specified range with a specified step
29
29
  *
@@ -37,7 +37,7 @@ declare function range(start: number, end: number): number[];
37
37
  * range(0, 10, 2); // => [0, 2, 4, 6, 8]
38
38
  * ```
39
39
  */
40
- declare function range(start: number, end: number, step: number): number[];
40
+ export declare function range(start: number, end: number, step: number): number[];
41
41
  /**
42
42
  * Get an array with a specified length, filled with indices
43
43
  *
@@ -49,7 +49,7 @@ declare function range(start: number, end: number, step: number): number[];
49
49
  * times(5); // => [0, 1, 2, 3, 4]
50
50
  * ```
51
51
  */
52
- declare function times(length: number): number[];
52
+ export declare function times(length: number): number[];
53
53
  /**
54
54
  * Get an array with a specified length, filled by values from a callback
55
55
  *
@@ -62,7 +62,7 @@ declare function times(length: number): number[];
62
62
  * times(5, index => index * 2); // => [0, 2, 4, 6, 8]
63
63
  * ```
64
64
  */
65
- declare function times<Callback extends (index: number) => unknown>(length: number, callback: Callback): Array<ReturnType<Callback>>;
65
+ export declare function times<Callback extends (index: number) => unknown>(length: number, callback: Callback): Array<ReturnType<Callback>>;
66
66
  /**
67
67
  * Get an array with a specified length, filled with a specified value
68
68
  *
@@ -75,6 +75,5 @@ declare function times<Callback extends (index: number) => unknown>(length: numb
75
75
  * times(5, 'a'); // => ['a', 'a', 'a', 'a', 'a']
76
76
  * ```
77
77
  */
78
- declare function times<Value>(length: number, value: Value): Value[];
79
- //#endregion
80
- export { range, times };
78
+ export declare function times<Value>(length: number, value: Value): Value[];
79
+ //#endregion
@@ -1,33 +1,13 @@
1
- import { Key, KeyedValue, PlainObject, Simplify } from "../models.mjs";
1
+ import { Key, KeyOrCallback, KeyOrCallbackKey, KeyOrCallbackValue, Simplify } from "../models.mjs";
2
2
  //#region src/array/group-by.d.ts
3
3
  /**
4
- * Create a record from an array of items using a specific key and value
5
- *
6
- * If multiple items have the same key, the latest item's value will be used
7
- *
8
- * @param array Array to group
9
- * @param key Callback to get an item's grouping key
10
- * @param value Callback to get an item's value
11
- * @returns Record of keyed values
12
- *
13
- * @example
14
- * ```typescript
15
- * groupBy(
16
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
17
- * item => item.value,
18
- * item => item,
19
- * ); // => {10: {id: 3, value: 10}, 20: {id: 2, value: 20}}
20
- * ```
21
- */
22
- declare function groupBy<Item, KeyCallback extends (item: Item, index: number, array: Item[]) => Key, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: KeyCallback, value: ValueCallback): Simplify<Record<ReturnType<KeyCallback>, ReturnType<ValueCallback>>>;
23
- /**
24
- * Create a record from an array of items using a specific key and value
4
+ * Create a record from an array of items using a specific key
25
5
  *
26
6
  * If multiple items have the same key, the latest item's value will be used
27
7
  *
28
8
  * @param array Array to group
29
- * @param key Callback to get an item's grouping key
30
- * @param value Key to use for value
9
+ * @param key Callback or key to use for grouping
10
+ * @param value Callback or key to use for value, defaulting to the item itself
31
11
  * @returns Record of keyed values
32
12
  *
33
13
  * @example
@@ -35,58 +15,18 @@ declare function groupBy<Item, KeyCallback extends (item: Item, index: number, a
35
15
  * groupBy(
36
16
  * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
37
17
  * item => item.value,
38
- * 'id'
39
- * ); // => {10: 3, 20: 2}
40
- * ```
41
- */
42
- declare function groupBy<Item extends PlainObject, KeyCallback extends (item: Item, index: number, array: Item[]) => Key, ItemValue extends keyof Item>(array: Item[], key: KeyCallback, value: ItemValue): Record<ReturnType<KeyCallback>, Item[ItemValue]>;
43
- /**
44
- * Create a record from an array of items using a specific key and value
45
- *
46
- * If multiple items have the same key, the latest item's value will be used
47
- *
48
- * @param array Array to group
49
- * @param key Key to use for grouping
50
- * @param value Callback to get an item's value
51
- * @returns Record of keyed values
52
- *
53
- * @example
54
- * ```typescript
55
- * groupBy(
56
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
57
- * 'value',
58
18
  * item => item,
59
19
  * ); // => {10: {id: 3, value: 10}, 20: {id: 2, value: 20}}
60
20
  * ```
61
21
  */
62
- declare function groupBy<Item extends PlainObject, ItemKey extends keyof Item, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: ItemKey, value: ValueCallback): Simplify<Record<KeyedValue<Item, ItemKey>, ReturnType<ValueCallback>>>;
63
- /**
64
- * Create a record from an array of items using a specific key and value
65
- *
66
- * If multiple items have the same key, the latest item's value will be used
67
- *
68
- * @param array Array to group
69
- * @param key Key to use for grouping
70
- * @param value Key to use for value
71
- * @returns Record of keyed values
72
- *
73
- * @example
74
- * ```typescript
75
- * groupBy(
76
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
77
- * 'value',
78
- * 'id'
79
- * ); // => {10: 3, 20: 2}
80
- * ```
81
- */
82
- declare function groupBy<Item extends PlainObject, ItemKey extends keyof Item, ItemValue extends keyof Item>(array: Item[], key: ItemKey, value: ItemValue): Simplify<Record<KeyedValue<Item, ItemKey>, Item[ItemValue]>>;
22
+ export declare function groupBy<Item, KeyArg extends KeyOrCallback<Item, Key>, ValueArg extends KeyOrCallback<Item>>(array: Item[], key: KeyArg, value: ValueArg): Simplify<Record<KeyOrCallbackKey<Item, KeyArg>, KeyOrCallbackValue<Item, ValueArg>>>;
83
23
  /**
84
24
  * Create a record from an array of items using a specific key
85
25
  *
86
26
  * If multiple items have the same key, the latest item will be used
87
27
  *
88
28
  * @param array Array to group
89
- * @param callback Callback to get an item's grouping key
29
+ * @param key Callback or key to use for grouping
90
30
  * @returns Record of keyed items
91
31
  *
92
32
  * @example
@@ -97,25 +37,7 @@ declare function groupBy<Item extends PlainObject, ItemKey extends keyof Item, I
97
37
  * ); // => {10: {id: 3, value: 10}, 20: {id: 2, value: 20}}
98
38
  * ```
99
39
  */
100
- declare function groupBy<Item, Callback extends (item: Item, index: number, array: Item[]) => Key>(array: Item[], callback: Callback): Record<ReturnType<Callback>, Item>;
101
- /**
102
- * Create a record from an array of items using a specific key
103
- *
104
- * If multiple items have the same key, the latest item will be used
105
- *
106
- * @param array Array to group
107
- * @param key Key to use for grouping
108
- * @returns Record of keyed items
109
- *
110
- * @example
111
- * ```typescript
112
- * groupBy(
113
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
114
- * 'value',
115
- * ); // => {10: {id: 3, value: 10}, 20: {id: 2, value: 20}}
116
- * ```
117
- */
118
- declare function groupBy<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey): Simplify<Record<KeyedValue<Item, ItemKey>, Item>>;
40
+ export declare function groupBy<Item, KeyArg extends KeyOrCallback<Item, Key>>(array: Item[], key: KeyArg): Simplify<Record<KeyOrCallbackKey<Item, KeyArg>, Item>>;
119
41
  /**
120
42
  * Create a record from an array of items _(using indices as keys)_
121
43
  *
@@ -129,18 +51,18 @@ declare function groupBy<Item extends PlainObject, ItemKey extends keyof Item>(a
129
51
  * ); // => {0: {id: 1, value: 10}, 1: {id: 2, value: 20}, 2: {id: 3, value: 10}}
130
52
  * ```
131
53
  */
132
- declare function groupBy<Item>(array: Item[]): Record<number, Item>;
133
- declare namespace groupBy {
54
+ export declare function groupBy<Item>(array: Item[]): Record<number, Item>;
55
+ export declare namespace groupBy {
134
56
  var arrays: typeof groupArraysBy;
135
57
  }
136
58
  /**
137
- * Create a record from an array of items using a specific key and value, grouping values into arrays
59
+ * Create a record from an array of items using a specific key, grouping values into arrays
138
60
  *
139
61
  * _Available as `groupArraysBy` and `groupBy.arrays`_
140
62
  *
141
63
  * @param array Array to group
142
- * @param key Callback to get an item's grouping key
143
- * @param value Callback to get an item's value
64
+ * @param key Callback or key to use for grouping
65
+ * @param value Callback or key to use for value, defaulting to the item itself
144
66
  * @returns Record of keyed values
145
67
  *
146
68
  * @example
@@ -155,83 +77,14 @@ declare namespace groupBy {
155
77
  * // }
156
78
  * ```
157
79
  */
158
- declare function groupArraysBy<Item, KeyCallback extends (item: Item, index: number, array: Item[]) => Key, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: KeyCallback, value: ValueCallback): Record<ReturnType<KeyCallback>, Array<ReturnType<ValueCallback>>>;
159
- /**
160
- * Create a record from an array of items using a specific key and value, grouping values into arrays
161
- *
162
- * _Available as `groupArraysBy` and `groupBy.arrays`_
163
- *
164
- * @param array Array to group
165
- * @param key Callback to get an item's grouping key
166
- * @param value Key to use for value
167
- * @returns Record of keyed values
168
- *
169
- * @example
170
- * ```typescript
171
- * groupArraysBy(
172
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
173
- * item => item.value,
174
- * 'id',
175
- * ); // => {
176
- * // 10: [1, 3],
177
- * // 20: [2],
178
- * // }
179
- * ```
180
- */
181
- declare function groupArraysBy<Item extends PlainObject, KeyCallback extends (item: Item, index: number, array: Item[]) => Key, ItemValue extends keyof Item>(array: Item[], key: KeyCallback, value: ItemValue): Record<ReturnType<KeyCallback>, Item[ItemValue][]>;
182
- /**
183
- * Create a record from an array of items using a specific key and value, grouping values into arrays
184
- *
185
- * _Available as `groupArraysBy` and `groupBy.arrays`_
186
- *
187
- * @param array Array to group
188
- * @param key Key to use for grouping
189
- * @param value Callback to get an item's value
190
- * @returns Record of keyed values
191
- *
192
- * @example
193
- * ```typescript
194
- * groupArraysBy(
195
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
196
- * 'value',
197
- * item => item,
198
- * ); // => {
199
- * // 10: [{id: 1, value: 10}, {id: 3, value: 10}],
200
- * // 20: [{id: 2, value: 20}],
201
- * // }
202
- * ```
203
- */
204
- declare function groupArraysBy<Item extends PlainObject, ItemKey extends keyof Item, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: ItemKey, value: ValueCallback): Simplify<Record<KeyedValue<Item, ItemKey>, Array<ReturnType<ValueCallback>>>>;
205
- /**
206
- * Create a record from an array of items using a specific key and value, grouping values into arrays
207
- *
208
- * _Available as `groupArraysBy` and `groupBy.arrays`_
209
- *
210
- * @param array Array to group
211
- * @param key Key to use for grouping
212
- * @param value Key to use for value
213
- * @returns Record of keyed values
214
- *
215
- * @example
216
- * ```typescript
217
- * groupArraysBy(
218
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
219
- * 'value',
220
- * 'id',
221
- * ); // => {
222
- * // 10: [1, 3],
223
- * // 20: [2],
224
- * // }
225
- * ```
226
- */
227
- declare function groupArraysBy<Item extends PlainObject, ItemKey extends keyof Item, ItemValue extends keyof Item>(array: Item[], key: ItemKey, value: ItemValue): Simplify<Record<KeyedValue<Item, ItemKey>, Item[ItemValue][]>>;
80
+ export declare function groupArraysBy<Item, KeyArg extends KeyOrCallback<Item, Key>, ValueArg extends KeyOrCallback<Item>>(array: Item[], key: KeyArg, value: ValueArg): Simplify<Record<KeyOrCallbackKey<Item, KeyArg>, Array<KeyOrCallbackValue<Item, ValueArg>>>>;
228
81
  /**
229
82
  * Create a record from an array of items using a specific key, grouping items into arrays
230
83
  *
231
84
  * _Available as `groupArraysBy` and `groupBy.arrays`_
232
85
  *
233
86
  * @param array Array to group
234
- * @param callback Callback to get an item's grouping key
87
+ * @param key Callback or key to use for grouping
235
88
  * @returns Record of keyed items
236
89
  *
237
90
  * @example
@@ -245,27 +98,5 @@ declare function groupArraysBy<Item extends PlainObject, ItemKey extends keyof I
245
98
  * // }
246
99
  * ```
247
100
  */
248
- declare function groupArraysBy<Item, Callback extends (item: Item, index: number, array: Item[]) => Key>(array: Item[], callback: Callback): Record<ReturnType<Callback>, Item[]>;
249
- /**
250
- * Create a record from an array of items using a specific key, grouping items into arrays
251
- *
252
- * _Available as `groupArraysBy` and `groupBy.arrays`_
253
- *
254
- * @param array Array to group
255
- * @param key Key to use for grouping
256
- * @returns Record of keyed items
257
- *
258
- * @example
259
- * ```typescript
260
- * groupArraysBy(
261
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
262
- * 'value',
263
- * ); // => {
264
- * // 10: [{id: 1, value: 10}, {id: 3, value: 10}],
265
- * // 20: [{id: 2, value: 20}],
266
- * // }
267
- * ```
268
- */
269
- declare function groupArraysBy<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey): Simplify<Record<KeyedValue<Item, ItemKey>, Item[]>>;
270
- //#endregion
271
- export { groupArraysBy, groupBy };
101
+ export declare function groupArraysBy<Item, KeyArg extends KeyOrCallback<Item, Key>>(array: Item[], key: KeyArg): Simplify<Record<KeyOrCallbackKey<Item, KeyArg>, Item[]>>;
102
+ //#endregion
@@ -14,7 +14,7 @@
14
14
  * insert([1, 2, 3], 1, [4, 5]); // => [1, 4, 5, 2, 3]
15
15
  * ```
16
16
  */
17
- declare function insert<Item>(array: Item[], index: number, items: Item[]): Item[];
17
+ export declare function insert<Item>(array: Item[], index: number, items: Item[]): Item[];
18
18
  /**
19
19
  * Insert items into an array _(at the end)_
20
20
  *
@@ -29,6 +29,5 @@ declare function insert<Item>(array: Item[], index: number, items: Item[]): Item
29
29
  * insert([1, 2, 3], [4, 5]); // => [1, 2, 3, 4, 5]
30
30
  * ```
31
31
  */
32
- declare function insert<Item>(array: Item[], items: Item[]): Item[];
33
- //#endregion
34
- export { insert };
32
+ export declare function insert<Item>(array: Item[], items: Item[]): Item[];
33
+ //#endregion
@@ -16,7 +16,7 @@
16
16
  * ); // => [{id: 2}, {id: 3}]
17
17
  * ```
18
18
  */
19
- declare function intersection<First, Second>(first: First[], second: Second[], callback: (item: First | Second) => unknown): First[];
19
+ export declare function intersection<First, Second>(first: First[], second: Second[], callback: (item: First | Second) => unknown): First[];
20
20
  /**
21
21
  * Get the common values between two arrays
22
22
  *
@@ -34,7 +34,7 @@ declare function intersection<First, Second>(first: First[], second: Second[], c
34
34
  * ); // => [{id: 2}, {id: 3}]
35
35
  * ```
36
36
  */
37
- declare function intersection<First extends Record<string, unknown>, Second extends Record<string, unknown>, SharedKey extends keyof First & keyof Second>(first: First[], second: Second[], key: SharedKey): First[];
37
+ export declare function intersection<First extends Record<string, unknown>, Second extends Record<string, unknown>, SharedKey extends keyof First & keyof Second>(first: First[], second: Second[], key: SharedKey): First[];
38
38
  /**
39
39
  * Get the common values between two arrays
40
40
  *
@@ -50,6 +50,5 @@ declare function intersection<First extends Record<string, unknown>, Second exte
50
50
  * ); // => [2, 3]
51
51
  * ```
52
52
  */
53
- declare function intersection<First, Second>(first: First[], second: Second[]): First[];
54
- //#endregion
55
- export { intersection };
53
+ export declare function intersection<First, Second>(first: First[], second: Second[]): First[];
54
+ //#endregion