@oscarpalmer/atoms 0.186.2 → 0.187.1

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 (230) hide show
  1. package/dist/array/filter.d.mts +4 -4
  2. package/dist/array/find.d.mts +4 -4
  3. package/dist/array/first.d.mts +4 -4
  4. package/dist/array/get.d.mts +27 -1
  5. package/dist/array/get.mjs +5 -3
  6. package/dist/array/group-by.d.mts +6 -6
  7. package/dist/array/last.d.mts +4 -4
  8. package/dist/array/match.d.mts +7 -6
  9. package/dist/array/move.d.mts +7 -7
  10. package/dist/array/move.mjs +1 -1
  11. package/dist/array/select.d.mts +1 -0
  12. package/dist/array/slice.d.mts +3 -3
  13. package/dist/array/sort.d.mts +10 -7
  14. package/dist/array/sort.mjs +4 -3
  15. package/dist/array/swap.d.mts +1 -1
  16. package/dist/array/swap.mjs +1 -1
  17. package/dist/array/to-map.d.mts +32 -32
  18. package/dist/array/to-record.d.mts +6 -6
  19. package/dist/array/to-set.d.mts +6 -6
  20. package/dist/beacon.d.mts +6 -0
  21. package/dist/beacon.mjs +3 -0
  22. package/dist/color/index.d.mts +6 -2
  23. package/dist/color/index.mjs +6 -2
  24. package/dist/color/instance.d.mts +78 -14
  25. package/dist/color/instance.mjs +78 -14
  26. package/dist/color/misc/get.d.mts +39 -11
  27. package/dist/color/misc/get.mjs +39 -11
  28. package/dist/color/misc/is.d.mts +26 -11
  29. package/dist/color/misc/is.mjs +26 -11
  30. package/dist/color/misc/state.mjs +1 -1
  31. package/dist/color/models.d.mts +7 -4
  32. package/dist/color/space/hex.d.mts +15 -6
  33. package/dist/color/space/hex.mjs +15 -6
  34. package/dist/color/space/hsl.d.mts +10 -4
  35. package/dist/color/space/hsl.mjs +10 -4
  36. package/dist/color/space/rgb.d.mts +21 -12
  37. package/dist/color/space/rgb.mjs +21 -12
  38. package/dist/function/assert.d.mts +20 -14
  39. package/dist/function/assert.mjs +19 -13
  40. package/dist/function/limit.d.mts +8 -6
  41. package/dist/function/limit.mjs +8 -6
  42. package/dist/function/memoize.d.mts +15 -4
  43. package/dist/function/memoize.mjs +18 -4
  44. package/dist/function/once.d.mts +5 -3
  45. package/dist/function/once.mjs +5 -3
  46. package/dist/function/retry.d.mts +5 -2
  47. package/dist/function/retry.mjs +3 -1
  48. package/dist/function/work.d.mts +146 -98
  49. package/dist/{kalas.d.mts → herald.d.mts} +17 -8
  50. package/dist/{kalas.mjs → herald.mjs} +22 -13
  51. package/dist/index.d.mts +1464 -708
  52. package/dist/index.mjs +703 -342
  53. package/dist/internal/array/index-of.d.mts +4 -4
  54. package/dist/internal/array/insert.mjs +1 -1
  55. package/dist/internal/array/shuffle.d.mts +1 -0
  56. package/dist/internal/array/shuffle.mjs +2 -1
  57. package/dist/internal/is.d.mts +26 -8
  58. package/dist/internal/is.mjs +26 -8
  59. package/dist/internal/math/aggregate.d.mts +9 -9
  60. package/dist/internal/number.d.mts +13 -2
  61. package/dist/internal/number.mjs +13 -2
  62. package/dist/internal/random.d.mts +4 -2
  63. package/dist/internal/random.mjs +7 -5
  64. package/dist/internal/result.d.mts +17 -11
  65. package/dist/internal/result.mjs +10 -14
  66. package/dist/internal/string.d.mts +16 -1
  67. package/dist/internal/string.mjs +24 -1
  68. package/dist/internal/value/compare.d.mts +5 -2
  69. package/dist/internal/value/compare.mjs +5 -2
  70. package/dist/internal/value/equal.d.mts +12 -3
  71. package/dist/internal/value/equal.mjs +7 -4
  72. package/dist/internal/value/get.d.mts +17 -17
  73. package/dist/internal/value/has.d.mts +55 -11
  74. package/dist/internal/value/set.d.mts +24 -0
  75. package/dist/internal/value/set.mjs +1 -1
  76. package/dist/is.d.mts +12 -0
  77. package/dist/is.mjs +16 -1
  78. package/dist/logger.d.mts +7 -6
  79. package/dist/logger.mjs +6 -5
  80. package/dist/math.d.mts +36 -18
  81. package/dist/math.mjs +6 -3
  82. package/dist/models.d.mts +3 -3
  83. package/dist/promise/delay.d.mts +2 -0
  84. package/dist/promise/helpers.d.mts +6 -4
  85. package/dist/promise/helpers.mjs +6 -4
  86. package/dist/promise/index.d.mts +49 -38
  87. package/dist/promise/misc.d.mts +10 -7
  88. package/dist/promise/misc.mjs +4 -3
  89. package/dist/promise/models.d.mts +18 -19
  90. package/dist/promise/models.mjs +4 -3
  91. package/dist/promise/timed.d.mts +8 -6
  92. package/dist/query.d.mts +2 -0
  93. package/dist/query.mjs +27 -17
  94. package/dist/queue.d.mts +15 -4
  95. package/dist/queue.mjs +10 -3
  96. package/dist/random.d.mts +9 -2
  97. package/dist/random.mjs +7 -2
  98. package/dist/result/index.d.mts +14 -8
  99. package/dist/result/match.d.mts +18 -10
  100. package/dist/result/misc.d.mts +14 -7
  101. package/dist/result/misc.mjs +4 -2
  102. package/dist/result/models.d.mts +2 -0
  103. package/dist/result/work/flow.d.mts +86 -62
  104. package/dist/result/work/pipe.d.mts +55 -33
  105. package/dist/sized/map.d.mts +19 -16
  106. package/dist/sized/map.mjs +4 -4
  107. package/dist/sized/set.d.mts +20 -16
  108. package/dist/sized/set.mjs +8 -7
  109. package/dist/string/case.d.mts +8 -0
  110. package/dist/string/case.mjs +8 -0
  111. package/dist/string/fuzzy.d.mts +19 -5
  112. package/dist/string/fuzzy.mjs +7 -0
  113. package/dist/string/index.d.mts +17 -2
  114. package/dist/string/index.mjs +7 -9
  115. package/dist/string/match.d.mts +3 -0
  116. package/dist/string/match.mjs +3 -0
  117. package/dist/string/normalize.d.mts +6 -2
  118. package/dist/string/normalize.mjs +5 -2
  119. package/dist/string/template.d.mts +38 -9
  120. package/dist/string/template.mjs +19 -19
  121. package/dist/value/clone.d.mts +25 -4
  122. package/dist/value/clone.mjs +36 -22
  123. package/dist/value/collection.d.mts +9 -6
  124. package/dist/value/collection.mjs +3 -2
  125. package/dist/value/diff.d.mts +3 -1
  126. package/dist/value/diff.mjs +1 -0
  127. package/dist/value/freeze.d.mts +118 -9
  128. package/dist/value/freeze.mjs +56 -14
  129. package/dist/value/index.d.mts +1 -2
  130. package/dist/value/index.mjs +1 -2
  131. package/dist/value/merge.d.mts +11 -5
  132. package/dist/value/merge.mjs +2 -2
  133. package/dist/value/omit.d.mts +1 -0
  134. package/dist/value/omit.mjs +1 -0
  135. package/dist/value/pick.d.mts +1 -0
  136. package/dist/value/pick.mjs +1 -0
  137. package/dist/value/shake.d.mts +1 -0
  138. package/dist/value/shake.mjs +1 -0
  139. package/dist/value/smush.d.mts +1 -0
  140. package/dist/value/smush.mjs +1 -0
  141. package/dist/value/transform.d.mts +7 -3
  142. package/dist/value/unsmush.d.mts +1 -0
  143. package/dist/value/unsmush.mjs +1 -0
  144. package/package.json +12 -8
  145. package/src/array/filter.ts +4 -4
  146. package/src/array/find.ts +4 -4
  147. package/src/array/first.ts +4 -4
  148. package/src/array/get.ts +40 -5
  149. package/src/array/group-by.ts +6 -6
  150. package/src/array/last.ts +4 -4
  151. package/src/array/match.ts +7 -6
  152. package/src/array/move.ts +7 -7
  153. package/src/array/select.ts +1 -0
  154. package/src/array/slice.ts +3 -3
  155. package/src/array/sort.ts +15 -10
  156. package/src/array/swap.ts +1 -1
  157. package/src/array/to-map.ts +32 -32
  158. package/src/array/to-record.ts +6 -6
  159. package/src/array/to-set.ts +6 -6
  160. package/src/beacon.ts +6 -0
  161. package/src/color/index.ts +6 -2
  162. package/src/color/instance.ts +78 -14
  163. package/src/color/misc/get.ts +39 -11
  164. package/src/color/misc/is.ts +26 -11
  165. package/src/color/misc/state.ts +1 -1
  166. package/src/color/models.ts +7 -4
  167. package/src/color/space/hex.ts +15 -6
  168. package/src/color/space/hsl.ts +10 -4
  169. package/src/color/space/rgb.ts +21 -12
  170. package/src/function/assert.ts +20 -14
  171. package/src/function/limit.ts +8 -6
  172. package/src/function/memoize.ts +24 -5
  173. package/src/function/once.ts +5 -3
  174. package/src/function/retry.ts +7 -3
  175. package/src/function/work.ts +146 -98
  176. package/src/{kalas.ts → herald.ts} +23 -14
  177. package/src/index.ts +3 -2
  178. package/src/internal/array/index-of.ts +4 -4
  179. package/src/internal/array/insert.ts +1 -1
  180. package/src/internal/array/shuffle.ts +2 -1
  181. package/src/internal/is.ts +26 -8
  182. package/src/internal/math/aggregate.ts +9 -9
  183. package/src/internal/number.ts +13 -2
  184. package/src/internal/random.ts +10 -4
  185. package/src/internal/result.ts +30 -29
  186. package/src/internal/string.ts +28 -0
  187. package/src/internal/value/compare.ts +5 -2
  188. package/src/internal/value/equal.ts +13 -4
  189. package/src/internal/value/get.ts +17 -17
  190. package/src/internal/value/has.ts +54 -11
  191. package/src/internal/value/set.ts +25 -1
  192. package/src/is.ts +15 -1
  193. package/src/logger.ts +8 -7
  194. package/src/math.ts +36 -18
  195. package/src/models.ts +3 -3
  196. package/src/promise/delay.ts +2 -0
  197. package/src/promise/helpers.ts +6 -4
  198. package/src/promise/index.ts +49 -38
  199. package/src/promise/misc.ts +10 -7
  200. package/src/promise/models.ts +18 -19
  201. package/src/promise/timed.ts +8 -6
  202. package/src/query.ts +39 -28
  203. package/src/queue.ts +15 -4
  204. package/src/random.ts +8 -1
  205. package/src/result/index.ts +14 -8
  206. package/src/result/match.ts +18 -10
  207. package/src/result/misc.ts +17 -9
  208. package/src/result/models.ts +2 -0
  209. package/src/result/work/flow.ts +86 -62
  210. package/src/result/work/pipe.ts +55 -33
  211. package/src/sized/map.ts +20 -17
  212. package/src/sized/set.ts +21 -17
  213. package/src/string/case.ts +8 -0
  214. package/src/string/fuzzy.ts +19 -5
  215. package/src/string/index.ts +18 -15
  216. package/src/string/match.ts +3 -0
  217. package/src/string/normalize.ts +6 -2
  218. package/src/string/template.ts +69 -18
  219. package/src/value/clone.ts +51 -26
  220. package/src/value/collection.ts +9 -6
  221. package/src/value/diff.ts +3 -1
  222. package/src/value/freeze.ts +239 -25
  223. package/src/value/index.ts +0 -1
  224. package/src/value/merge.ts +11 -5
  225. package/src/value/omit.ts +1 -0
  226. package/src/value/pick.ts +1 -0
  227. package/src/value/shake.ts +1 -0
  228. package/src/value/smush.ts +1 -0
  229. package/src/value/transform.ts +7 -3
  230. package/src/value/unsmush.ts +1 -0
@@ -4,7 +4,7 @@ import { PlainObject } from "../models.mjs";
4
4
  /**
5
5
  * Get a filtered array of items that do not match the value
6
6
  *
7
- * Available as `exclude` and `filter.remove`
7
+ * _Available as `exclude` and `filter.remove`_
8
8
  *
9
9
  * @param array Array to search in
10
10
  * @param callback Callback to get an item's value for matching
@@ -24,7 +24,7 @@ declare function exclude<Item, Callback extends (item: Item, index: number, arra
24
24
  /**
25
25
  * Get a filtered array of items that do not match the value
26
26
  *
27
- * Available as `exclude` and `filter.remove`
27
+ * _Available as `exclude` and `filter.remove`_
28
28
  *
29
29
  * @param array Array to search in
30
30
  * @param key Key to get an item's value for matching
@@ -44,7 +44,7 @@ declare function exclude<Item extends PlainObject, ItemKey extends keyof Item>(a
44
44
  /**
45
45
  * Get a filtered array of items that do not match the filter
46
46
  *
47
- * Available as `exclude` and `filter.remove`
47
+ * _Available as `exclude` and `filter.remove`_
48
48
  *
49
49
  * @param array Array to search in
50
50
  * @param filter Filter callback to match items
@@ -62,7 +62,7 @@ declare function exclude<Item>(array: Item[], filter: (item: Item, index: number
62
62
  /**
63
63
  * Get a filtered array of items that do not match the given item
64
64
  *
65
- * Available as `exclude` and `filter.remove`
65
+ * _Available as `exclude` and `filter.remove`_
66
66
  *
67
67
  * @param array Array to search in
68
68
  * @param item Item to match against
@@ -72,7 +72,7 @@ declare namespace find {
72
72
  /**
73
73
  * Get the last item matching the given value
74
74
  *
75
- * Available as `findLast` and `find.last`
75
+ * _Available as `findLast` and `find.last`_
76
76
  *
77
77
  * @param array Array to search in
78
78
  * @param callback Callback to get an item's value for matching
@@ -92,7 +92,7 @@ declare function findLast<Item, Callback extends (item: Item, index: number, arr
92
92
  /**
93
93
  * Get the last item matching the given value by key
94
94
  *
95
- * Available as `findLast` and `find.last`
95
+ * _Available as `findLast` and `find.last`_
96
96
  *
97
97
  * @param array Array to search in
98
98
  * @param key Key to get an item's value for matching
@@ -112,7 +112,7 @@ declare function findLast<Item extends PlainObject, ItemKey extends keyof Item>(
112
112
  /**
113
113
  * Get the last item matching the filter
114
114
  *
115
- * Available as `findLast` and `find.last`
115
+ * _Available as `findLast` and `find.last`_
116
116
  *
117
117
  * @param array Array to search in
118
118
  * @param filter Filter callback to match items
@@ -130,7 +130,7 @@ declare function findLast<Item>(array: Item[], filter: (item: Item, index: numbe
130
130
  /**
131
131
  * Get the last item matching the given value
132
132
  *
133
- * Available as `findLast` and `find.last`
133
+ * _Available as `findLast` and `find.last`_
134
134
  *
135
135
  * @param array Array to search in
136
136
  * @param value Value to match against
@@ -74,7 +74,7 @@ declare namespace first {
74
74
  /**
75
75
  * Get the first item matching the given value, or a default value if no match is found
76
76
  *
77
- * Available as `firstOrDefault` and `first.default`
77
+ * _Available as `firstOrDefault` and `first.default`_
78
78
  *
79
79
  * @param array Array to search in
80
80
  * @param defaultValue Default value to return if no match is found
@@ -96,7 +96,7 @@ declare function firstOrDefault<Item, Callback extends (item: Item, index: numbe
96
96
  /**
97
97
  * Get the first item matching the given value by key, or a default value if no match is found
98
98
  *
99
- * Available as `firstOrDefault` and `first.default`
99
+ * _Available as `firstOrDefault` and `first.default`_
100
100
  *
101
101
  * @param array Array to search in
102
102
  * @param defaultValue Default value to return if no match is found
@@ -118,7 +118,7 @@ declare function firstOrDefault<Item extends PlainObject, ItemKey extends keyof
118
118
  /**
119
119
  * Get the first item matching the filter, or a default value if no match is found
120
120
  *
121
- * Available as `firstOrDefault` and `first.default`
121
+ * _Available as `firstOrDefault` and `first.default`_
122
122
  *
123
123
  * @param array Array to search in
124
124
  * @param defaultValue Default value to return if no match is found
@@ -138,7 +138,7 @@ declare function firstOrDefault<Item>(array: Item[], defaultValue: Item, filter:
138
138
  /**
139
139
  * Get the first item from an array, or a default value if the array is empty
140
140
  *
141
- * Available as `firstOrDefault` and `first.default`
141
+ * _Available as `firstOrDefault` and `first.default`_
142
142
  *
143
143
  * @param array Array to get from
144
144
  * @param defaultValue Default value to return if the array is empty
@@ -14,6 +14,20 @@ import { NumericalKeys, PlainObject } from "../models.mjs";
14
14
  * ```
15
15
  */
16
16
  declare function getArray<Value extends PlainObject>(value: Value, indiced: true): Value[NumericalKeys<Value>][];
17
+ /**
18
+ * Get an array from a map
19
+ *
20
+ * @param value Map to convert to an array
21
+ * @returns Array holding the entries of the map
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * getArray(
26
+ * new Map([['a', 1], ['b', 2], ['c', 3]]),
27
+ * ); // => [['a', 1], ['b', 2], ['c', 3]]
28
+ * ```
29
+ */
30
+ declare function getArray<Key, Value>(map: Map<Key, Value>): [Key, Value][];
17
31
  /**
18
32
  * Get an array from an object
19
33
  *
@@ -26,7 +40,19 @@ declare function getArray<Value extends PlainObject>(value: Value, indiced: true
26
40
  * getArray({a: 'a', b: 'b', c: 'c', d: 'd'}); // => ['a', 'b', 'c', 'd']
27
41
  * ```
28
42
  */
29
- declare function getArray<Value extends PlainObject>(value: Value): Value[keyof Value][];
43
+ declare function getArray<Value extends PlainObject>(value: Value): [keyof Value, Value[keyof Value]][];
44
+ /**
45
+ * Get an array from a set
46
+ *
47
+ * @param value Set to convert to an array
48
+ * @returns Array holding the values of the set
49
+ *
50
+ * @example
51
+ * ```typescript
52
+ * getArray(new Set([123, 456, 789])); // => [123, 456, 789]
53
+ * ```
54
+ */
55
+ declare function getArray<Value>(set: Set<Value>): Value[];
30
56
  /**
31
57
  * Get an array from a value
32
58
  *
@@ -2,15 +2,17 @@ import { isNonPlainObject } from "../internal/is.mjs";
2
2
  //#region src/array/get.ts
3
3
  function getArray(value, indiced) {
4
4
  if (Array.isArray(value)) return value;
5
- if (value instanceof Map || value instanceof Set) return [...value.values()];
5
+ if (value instanceof Map) return [...value.entries()];
6
+ if (value instanceof Set) return [...value.values()];
6
7
  if (isNonPlainObject(value)) return [value];
7
- if (indiced !== true) return Object.values(value);
8
+ if (indiced !== true) return Object.entries(value);
8
9
  const keys = Object.keys(value);
9
10
  const { length } = keys;
10
11
  const array = [];
11
12
  for (let index = 0; index < length; index += 1) {
12
13
  const key = keys[index];
13
- if (!Number.isNaN(Number(key))) array.push(value[key]);
14
+ const asNumber = Number.parseInt(key, 10);
15
+ if (!Number.isNaN(asNumber)) array[asNumber] = value[key];
14
16
  }
15
17
  return array;
16
18
  }
@@ -137,7 +137,7 @@ declare namespace groupBy {
137
137
  /**
138
138
  * Create a record from an array of items using a specific key and value, grouping values into arrays
139
139
  *
140
- * Available as `groupArraysBy` and `groupBy.arrays`
140
+ * _Available as `groupArraysBy` and `groupBy.arrays`_
141
141
  *
142
142
  * @param array Array to group
143
143
  * @param key Callback to get an item's grouping key
@@ -160,7 +160,7 @@ declare function groupArraysBy<Item, KeyCallback extends (item: Item, index: num
160
160
  /**
161
161
  * Create a record from an array of items using a specific key and value, grouping values into arrays
162
162
  *
163
- * Available as `groupArraysBy` and `groupBy.arrays`
163
+ * _Available as `groupArraysBy` and `groupBy.arrays`_
164
164
  *
165
165
  * @param array Array to group
166
166
  * @param key Callback to get an item's grouping key
@@ -183,7 +183,7 @@ declare function groupArraysBy<Item extends PlainObject, KeyCallback extends (it
183
183
  /**
184
184
  * Create a record from an array of items using a specific key and value, grouping values into arrays
185
185
  *
186
- * Available as `groupArraysBy` and `groupBy.arrays`
186
+ * _Available as `groupArraysBy` and `groupBy.arrays`_
187
187
  *
188
188
  * @param array Array to group
189
189
  * @param key Key to use for grouping
@@ -206,7 +206,7 @@ declare function groupArraysBy<Item extends PlainObject, ItemKey extends keyof I
206
206
  /**
207
207
  * Create a record from an array of items using a specific key and value, grouping values into arrays
208
208
  *
209
- * Available as `groupArraysBy` and `groupBy.arrays`
209
+ * _Available as `groupArraysBy` and `groupBy.arrays`_
210
210
  *
211
211
  * @param array Array to group
212
212
  * @param key Key to use for grouping
@@ -229,7 +229,7 @@ declare function groupArraysBy<Item extends PlainObject, ItemKey extends keyof I
229
229
  /**
230
230
  * Create a record from an array of items using a specific key, grouping items into arrays
231
231
  *
232
- * Available as `groupArraysBy` and `groupBy.arrays`
232
+ * _Available as `groupArraysBy` and `groupBy.arrays`_
233
233
  *
234
234
  * @param array Array to group
235
235
  * @param callback Callback to get an item's grouping key
@@ -250,7 +250,7 @@ declare function groupArraysBy<Item, Callback extends (item: Item, index: number
250
250
  /**
251
251
  * Create a record from an array of items using a specific key, grouping items into arrays
252
252
  *
253
- * Available as `groupArraysBy` and `groupBy.arrays`
253
+ * _Available as `groupArraysBy` and `groupBy.arrays`_
254
254
  *
255
255
  * @param array Array to group
256
256
  * @param key Key to use for grouping
@@ -72,7 +72,7 @@ declare namespace last {
72
72
  /**
73
73
  * Get the last item matching the given value
74
74
  *
75
- * Available as `lastOrDefault` and `last.default`
75
+ * _Available as `lastOrDefault` and `last.default`_
76
76
  *
77
77
  * @param array Array to search in
78
78
  * @param defaultValue Default value to return if no match is found
@@ -94,7 +94,7 @@ declare function lastOrDefault<Item, Callback extends (item: Item, index: number
94
94
  /**
95
95
  * Get the last item matching the given value by key
96
96
  *
97
- * Available as `lastOrDefault` and `last.default`
97
+ * _Available as `lastOrDefault` and `last.default`_
98
98
  *
99
99
  * @param array Array to search in
100
100
  * @param defaultValue Default value to return if no match is found
@@ -116,7 +116,7 @@ declare function lastOrDefault<Item extends PlainObject, ItemKey extends keyof I
116
116
  /**
117
117
  * Get the last item matching the filter
118
118
  *
119
- * Available as `lastOrDefault` and `last.default`
119
+ * _Available as `lastOrDefault` and `last.default`_
120
120
  *
121
121
  * @param array Array to search in
122
122
  * @param defaultValue Default value to return if no match is found
@@ -136,7 +136,7 @@ declare function lastOrDefault<Item>(array: Item[], defaultValue: Item, filter:
136
136
  /**
137
137
  * Get the last item from an array
138
138
  *
139
- * Available as `lastOrDefault` and `last.default`
139
+ * _Available as `lastOrDefault` and `last.default`_
140
140
  *
141
141
  * @param array Array to get from
142
142
  * @param defaultValue Default value to return if the array is empty
@@ -6,7 +6,8 @@ import { PlainObject } from "../models.mjs";
6
6
  */
7
7
  type ArrayComparison = 'end' | 'inside' | 'invalid' | 'outside' | 'same' | 'start';
8
8
  /**
9
- * Does the needle array end the haystack array?
9
+ * Is the needle array at the end of the haystack array?
10
+ *
10
11
  * @param haystack Haystack array
11
12
  * @param needle Needle array
12
13
  * @param callback Callback to get an item's value for matching
@@ -23,7 +24,7 @@ type ArrayComparison = 'end' | 'inside' | 'invalid' | 'outside' | 'same' | 'star
23
24
  */
24
25
  declare function endsWithArray<Item>(haystack: Item[], needle: Item[], callback: (item: Item, index: number, array: Item[]) => unknown): boolean;
25
26
  /**
26
- * Does the needle array end the haystack array?
27
+ * Is the needle array at the end of the haystack array?
27
28
  *
28
29
  * @param haystack Haystack array
29
30
  * @param needle Needle array
@@ -41,7 +42,7 @@ declare function endsWithArray<Item>(haystack: Item[], needle: Item[], callback:
41
42
  */
42
43
  declare function endsWithArray<Item extends PlainObject>(haystack: Item[], needle: Item[], key: keyof Item): boolean;
43
44
  /**
44
- * Does the needle array end the haystack array?
45
+ * Is the needle array at the end of the haystack array?
45
46
  *
46
47
  * @param haystack Haystack array
47
48
  * @param needle Needle array
@@ -201,7 +202,7 @@ declare function indexOfArray<Item extends PlainObject>(haystack: Item[], needle
201
202
  */
202
203
  declare function indexOfArray<Item>(haystack: Item[], needle: Item[]): number;
203
204
  /**
204
- * Does the needle array start the haystack array?
205
+ * Is the needle array at the start of the haystack array?
205
206
  *
206
207
  * @param haystack Haystack array
207
208
  * @param needle Needle array
@@ -219,7 +220,7 @@ declare function indexOfArray<Item>(haystack: Item[], needle: Item[]): number;
219
220
  */
220
221
  declare function startsWithArray<Item>(haystack: Item[], needle: Item[], callback: (item: Item, index: number, array: Item[]) => unknown): boolean;
221
222
  /**
222
- * Does the needle array start the haystack array?
223
+ * Is the needle array at the start of the haystack array?
223
224
  *
224
225
  * @param haystack Haystack array
225
226
  * @param needle Needle array
@@ -237,7 +238,7 @@ declare function startsWithArray<Item>(haystack: Item[], needle: Item[], callbac
237
238
  */
238
239
  declare function startsWithArray<Item extends PlainObject>(haystack: Item[], needle: Item[], key: keyof Item): boolean;
239
240
  /**
240
- * Does the needle array start the haystack array?
241
+ * Is the needle array at the start of the haystack array?
241
242
  *
242
243
  * @param haystack Haystack array
243
244
  * @param needle Needle array
@@ -4,7 +4,7 @@ import { PlainObject } from "../models.mjs";
4
4
  /**
5
5
  * Move an item _(or array of items)_ to the position of another item _(or array of items)_ within an array
6
6
  *
7
- * When moving to the front of the array, the moved items will be placed __before__ the target item. When moving to the back of the array, the moved items will be placed __after__ the target item.
7
+ * When moving to the front of the array, the moved items will be placed __before__ the target item. When moving to the back of the array, the moved items will be placed __after__ the target item
8
8
  *
9
9
  * If either of values are not present in the array, or if they overlap, the array will be returned unchanged
10
10
  *
@@ -27,7 +27,7 @@ declare function move<Item>(array: Item[], from: Item | Item[], to: Item | Item[
27
27
  /**
28
28
  * Move an item _(or array of items)_ to the position of another item _(or array of items)_ within an array
29
29
  *
30
- * When moving to the front of the array, the moved items will be placed __before__ the target item. When moving to the back of the array, the moved items will be placed __after__ the target item.
30
+ * When moving to the front of the array, the moved items will be placed __before__ the target item. When moving to the back of the array, the moved items will be placed __after__ the target item
31
31
  *
32
32
  * If either of values are not present in the array, or if they overlap, the array will be returned unchanged
33
33
  *
@@ -50,7 +50,7 @@ declare function move<Item extends PlainObject, ItemKey extends keyof Item>(arra
50
50
  /**
51
51
  * Move an item _(or array of items)_ to the position of another item _(or array of items)_ within an array
52
52
  *
53
- * When moving to the front of the array, the moved items will be placed __before__ the target item. When moving to the back of the array, the moved items will be placed __after__ the target item.
53
+ * When moving to the front of the array, the moved items will be placed __before__ the target item. When moving to the back of the array, the moved items will be placed __after__ the target item
54
54
  *
55
55
  * If either of values are not present in the array, or if they overlap, the array will be returned unchanged
56
56
  *
@@ -78,7 +78,7 @@ declare namespace move {
78
78
  *
79
79
  * If the from index is out of bounds, the array will be returned unchanged
80
80
  *
81
- * Available as `moveIndices` and `move.indices`
81
+ * _Available as `moveIndices` and `move.indices`_
82
82
  *
83
83
  * @param array Array to move within
84
84
  * @param from Index to move from
@@ -100,7 +100,7 @@ declare function moveIndices<Item>(array: Item[], from: number, to: number): Ite
100
100
  *
101
101
  * If the value is not present in the array, or if the index is out of bounds, the array will be returned unchanged
102
102
  *
103
- * Available as `moveToIndex` and `move.toIndex`
103
+ * _Available as `moveToIndex` and `move.toIndex`_
104
104
  *
105
105
  * @example
106
106
  * ```typescript
@@ -123,7 +123,7 @@ declare function moveToIndex<Item>(array: Item[], value: Item | Item[], index: n
123
123
  *
124
124
  * If the value is not present in the array, or if the index is out of bounds, the array will be returned unchanged
125
125
  *
126
- * Available as `moveToIndex` and `move.toIndex`
126
+ * _Available as `moveToIndex` and `move.toIndex`_
127
127
  *
128
128
  * @param array Array to move within
129
129
  * @param value Item or items to move
@@ -146,7 +146,7 @@ declare function moveToIndex<Item extends PlainObject, ItemKey extends keyof Ite
146
146
  *
147
147
  * If the value is not present in the array, or if the index is out of bounds, the array will be returned unchanged
148
148
  *
149
- * Available as `moveToIndex` and `move.toIndex`
149
+ * _Available as `moveToIndex` and `move.toIndex`_
150
150
  *
151
151
  * @param array Array to move within
152
152
  * @param value Item or items to move
@@ -30,7 +30,7 @@ move.toIndex = moveToIndex;
30
30
  *
31
31
  * If the from index is out of bounds, the array will be returned unchanged
32
32
  *
33
- * Available as `moveIndices` and `move.indices`
33
+ * _Available as `moveIndices` and `move.indices`_
34
34
  *
35
35
  * @param array Array to move within
36
36
  * @param from Index to move from
@@ -101,6 +101,7 @@ declare function select<Item extends PlainObject, ItemKey extends keyof Item, Ma
101
101
  declare function select<Item, FilterCallback extends (item: Item, index: number, array: Item[]) => unknown, MapCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], filterCallback: FilterCallback, filterValue: ReturnType<FilterCallback>, mapCallback: MapCallback): Array<ReturnType<MapCallback>>;
102
102
  /**
103
103
  * Get a filtered and mapped array of items
104
+ *
104
105
  * @param array Array to search in
105
106
  * @param filterCallback Filter callback to match items
106
107
  * @param mapKey Key to get an item's value for mapping
@@ -68,7 +68,7 @@ declare function drop<Item extends PlainObject>(array: Item[], callback: (item:
68
68
  */
69
69
  declare function drop(array: unknown[], count: number): unknown[];
70
70
  /**
71
- * Slice an array, returning a new array with a specified range of items
71
+ * Slice an array _(returning a new array with a specified range of items)_
72
72
  *
73
73
  * @param array Original array
74
74
  * @param start Start index _(inclusive)_
@@ -82,7 +82,7 @@ declare function drop(array: unknown[], count: number): unknown[];
82
82
  */
83
83
  declare function slice<Item>(array: Item[], start: number, end: number): Item[];
84
84
  /**
85
- * Slice an array, returning a new array with a specified number of items _(from the start)_
85
+ * Slice an array _(returning a new array with a specified number of items, from the start)_
86
86
  *
87
87
  * @param array Original array
88
88
  * @param count Maximum size of the new array
@@ -95,7 +95,7 @@ declare function slice<Item>(array: Item[], start: number, end: number): Item[];
95
95
  */
96
96
  declare function slice<Item>(array: Item[], count: number): Item[];
97
97
  /**
98
- * Slice an array
98
+ * Slice an array _(returning a new array with all items)_
99
99
  *
100
100
  * @param array Array to slice
101
101
  * @returns Sliced array
@@ -101,7 +101,7 @@ type Sorter<Item> = {
101
101
  *
102
102
  * _(If the array is not sorted, it will be treated as sorted, and the result may be inaccurate)_
103
103
  *
104
- * Available as `getSortedIndex` and `sort.getIndex`
104
+ * _Available as `getSortedIndex` and `sort.getIndex`_
105
105
  *
106
106
  * @param array Array to get the index from
107
107
  * @param item Item to get the index for
@@ -115,7 +115,7 @@ declare function getSortedIndex<Item>(array: Item[], item: Item, sorters: Array<
115
115
  *
116
116
  * _(If the array is not sorted, it will be treated as sorted, and the result may be inaccurate)_
117
117
  *
118
- * Available as `getSortedIndex` and `sort.getIndex`
118
+ * _Available as `getSortedIndex` and `sort.getIndex`_
119
119
  *
120
120
  * @param array Array to get the index from
121
121
  * @param item Item to get the index for
@@ -129,7 +129,7 @@ declare function getSortedIndex<Item>(array: Item[], item: Item, sorter: ArraySo
129
129
  *
130
130
  * _(If the array is not sorted, it will be treated as sorted, and the result may be inaccurate)_
131
131
  *
132
- * Available as `getSortedIndex` and `sort.getIndex`
132
+ * _Available as `getSortedIndex` and `sort.getIndex`_
133
133
  *
134
134
  * @param array Array to get the index from
135
135
  * @param item Item to get the index for
@@ -140,7 +140,7 @@ declare function getSortedIndex<Item>(array: Item[], item: Item, descending?: bo
140
140
  /**
141
141
  * Initialize a sort handler with sorters _(and an optional default direction)_
142
142
  *
143
- * Available as `initializeSorter` and `sort.initialize`
143
+ * _Available as `initializeSorter` and `sort.initialize`_
144
144
  *
145
145
  * @param sorters Sorters to use for sorting
146
146
  * @param descending Sort in descending order? _(defaults to `false`; overridden by individual sorters)_
@@ -150,7 +150,7 @@ declare function initializeSorter<Item>(sorters: Array<ArraySorter<Item>>, desce
150
150
  /**
151
151
  * Initialize a sort handler with a sorter _(and an optional default direction)_
152
152
  *
153
- * Available as `initializeSorter` and `sort.initialize`
153
+ * _Available as `initializeSorter` and `sort.initialize`_
154
154
  *
155
155
  * @param sorter Sorter to use for sorting
156
156
  * @param descending Sort in descending order? _(defaults to `false`; overridden by individual sorters)_
@@ -160,7 +160,7 @@ declare function initializeSorter<Item>(sorter: ArraySorter<Item>, descending?:
160
160
  /**
161
161
  * Initialize a sort handler _(with an optional default direction)_
162
162
  *
163
- * Available as `initializeSorter` and `sort.initialize`
163
+ * _Available as `initializeSorter` and `sort.initialize`_
164
164
  *
165
165
  * @param descending Sort in descending order? _(defaults to `false`)_
166
166
  * @returns Sort handler
@@ -187,7 +187,7 @@ declare function isSorted<Item>(array: Item[], sorter: ArraySorter<Item>, descen
187
187
  /**
188
188
  * Is the array sorted?
189
189
  *
190
- * Available as `isSorted` and `sort.is`
190
+ * _Available as `isSorted` and `sort.is`_
191
191
  *
192
192
  * @param array Array to check
193
193
  * @param descending Sorted in descending order? _(defaults to `false`)_
@@ -213,6 +213,7 @@ declare function isSorted<Item>(array: Item[], descending?: boolean): boolean;
213
213
  declare function sort<Item>(array: Item[], comparator: (first: Item, second: Item) => number, descending?: boolean): Item[];
214
214
  /**
215
215
  * Sort an array of items, using multiple sorters to sort by specific values
216
+ *
216
217
  * @param array Array to sort
217
218
  * @param sorters Sorters to use for sorting
218
219
  * @param descending Sort in descending order? _(defaults to `false`; overridden by individual sorters)_
@@ -221,6 +222,7 @@ declare function sort<Item>(array: Item[], comparator: (first: Item, second: Ite
221
222
  declare function sort<Item>(array: Item[], sorters: Array<ArraySorter<Item>>, descending?: boolean): Item[];
222
223
  /**
223
224
  * Sort an array of items, using a single sorter to sort by a specific value
225
+ *
224
226
  * @param array Array to sort
225
227
  * @param sorter Sorter to use for sorting
226
228
  * @param descending Sort in descending order? _(defaults to `false`; overridden by individual sorters)_
@@ -229,6 +231,7 @@ declare function sort<Item>(array: Item[], sorters: Array<ArraySorter<Item>>, de
229
231
  declare function sort<Item>(array: Item[], sorter: ArraySorter<Item>, descending?: boolean): Item[];
230
232
  /**
231
233
  * Sort an array of items
234
+ *
232
235
  * @param array Array to sort
233
236
  * @param descending Sort in descending order? _(defaults to `false`)_
234
237
  * @returns Sorted array
@@ -6,7 +6,7 @@ function getComparisonSorter(callback, modifier) {
6
6
  modifier,
7
7
  compare: { simple: callback },
8
8
  get: false,
9
- identifier: String(callback)
9
+ identifier: callback.toString()
10
10
  };
11
11
  }
12
12
  function getComparisonValue(first, second, sorters, length) {
@@ -75,11 +75,12 @@ function getSorters(value, modifier) {
75
75
  return sorters.filter((value, index, array) => array.findIndex((next) => next.identifier === value.identifier) === index);
76
76
  }
77
77
  function getValueSorter(value, modifier) {
78
+ const isFunction = typeof value === "function";
78
79
  return {
79
80
  modifier,
80
81
  get: true,
81
- identifier: String(value),
82
- value: typeof value === "function" ? value : (item) => item[value]
82
+ identifier: isFunction ? value.toString() : value,
83
+ value: isFunction ? value : (item) => item[value]
83
84
  };
84
85
  }
85
86
  function initializeSorter(first, second) {
@@ -175,7 +175,7 @@ declare namespace swap {
175
175
  *
176
176
  * If either index is out of bounds, the array will be returned unchanged
177
177
  *
178
- * Available as `swapIndices` and `swap.indices`
178
+ * _Available as `swapIndices` and `swap.indices`_
179
179
  *
180
180
  * @param array Array of items to swap
181
181
  * @param first First index _(can be negative to count from the end)_
@@ -33,7 +33,7 @@ function swapArrays(array, from, to, key) {
33
33
  *
34
34
  * If either index is out of bounds, the array will be returned unchanged
35
35
  *
36
- * Available as `swapIndices` and `swap.indices`
36
+ * _Available as `swapIndices` and `swap.indices`_
37
37
  *
38
38
  * @param array Array of items to swap
39
39
  * @param first First index _(can be negative to count from the end)_