@oscarpalmer/atoms 0.193.0 → 0.193.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 (126) hide show
  1. package/package.json +3 -4
  2. package/src/array/difference.ts +0 -73
  3. package/src/array/exists.ts +0 -93
  4. package/src/array/filter.ts +0 -182
  5. package/src/array/find.ts +0 -183
  6. package/src/array/first.ts +0 -196
  7. package/src/array/flatten.ts +0 -20
  8. package/src/array/from.ts +0 -129
  9. package/src/array/get.ts +0 -131
  10. package/src/array/group-by.ts +0 -369
  11. package/src/array/index.ts +0 -26
  12. package/src/array/insert.ts +0 -52
  13. package/src/array/intersection.ts +0 -72
  14. package/src/array/last.ts +0 -194
  15. package/src/array/match.ts +0 -436
  16. package/src/array/move.ts +0 -315
  17. package/src/array/partition.ts +0 -91
  18. package/src/array/push.ts +0 -23
  19. package/src/array/reverse.ts +0 -33
  20. package/src/array/select.ts +0 -260
  21. package/src/array/single.ts +0 -93
  22. package/src/array/slice.ts +0 -335
  23. package/src/array/sort.ts +0 -607
  24. package/src/array/splice.ts +0 -106
  25. package/src/array/swap.ts +0 -322
  26. package/src/array/to-map.ts +0 -371
  27. package/src/array/to-record.ts +0 -351
  28. package/src/array/to-set.ts +0 -80
  29. package/src/array/toggle.ts +0 -79
  30. package/src/array/union.ts +0 -72
  31. package/src/array/unique.ts +0 -67
  32. package/src/array/update.ts +0 -75
  33. package/src/beacon.ts +0 -378
  34. package/src/color/constants.ts +0 -137
  35. package/src/color/index.ts +0 -83
  36. package/src/color/instance.ts +0 -162
  37. package/src/color/misc/alpha.ts +0 -56
  38. package/src/color/misc/format.ts +0 -29
  39. package/src/color/misc/get.ts +0 -210
  40. package/src/color/misc/is.ts +0 -221
  41. package/src/color/misc/state.ts +0 -243
  42. package/src/color/models.ts +0 -389
  43. package/src/color/space/hex.ts +0 -184
  44. package/src/color/space/hsl.ts +0 -174
  45. package/src/color/space/hwb.ts +0 -153
  46. package/src/color/space/rgb.ts +0 -240
  47. package/src/function/assert.ts +0 -174
  48. package/src/function/index.ts +0 -2
  49. package/src/function/limit.ts +0 -83
  50. package/src/function/memoize.ts +0 -202
  51. package/src/function/once.ts +0 -200
  52. package/src/function/retry.ts +0 -175
  53. package/src/function/work.ts +0 -1007
  54. package/src/herald.ts +0 -216
  55. package/src/index.ts +0 -68
  56. package/src/internal/array/callbacks.ts +0 -46
  57. package/src/internal/array/chunk.ts +0 -51
  58. package/src/internal/array/compact.ts +0 -56
  59. package/src/internal/array/find.ts +0 -200
  60. package/src/internal/array/group.ts +0 -42
  61. package/src/internal/array/index-of.ts +0 -182
  62. package/src/internal/array/insert.ts +0 -80
  63. package/src/internal/array/overlap.ts +0 -35
  64. package/src/internal/array/sets.ts +0 -74
  65. package/src/internal/array/shuffle.ts +0 -33
  66. package/src/internal/array/update.ts +0 -52
  67. package/src/internal/function/misc.ts +0 -8
  68. package/src/internal/function/timer.ts +0 -168
  69. package/src/internal/is.ts +0 -244
  70. package/src/internal/math/aggregate.ts +0 -164
  71. package/src/internal/math/misc.ts +0 -28
  72. package/src/internal/number.ts +0 -129
  73. package/src/internal/random.ts +0 -49
  74. package/src/internal/result.ts +0 -92
  75. package/src/internal/sized.ts +0 -25
  76. package/src/internal/string.ts +0 -128
  77. package/src/internal/subscription.ts +0 -264
  78. package/src/internal/value/compare.ts +0 -170
  79. package/src/internal/value/equal.ts +0 -465
  80. package/src/internal/value/get.ts +0 -57
  81. package/src/internal/value/handlers.ts +0 -95
  82. package/src/internal/value/has.ts +0 -118
  83. package/src/internal/value/misc.ts +0 -125
  84. package/src/internal/value/partial.ts +0 -46
  85. package/src/internal/value/set.ts +0 -132
  86. package/src/is.ts +0 -182
  87. package/src/logger.ts +0 -230
  88. package/src/math.ts +0 -281
  89. package/src/models.ts +0 -286
  90. package/src/number.ts +0 -1
  91. package/src/promise/delay.ts +0 -62
  92. package/src/promise/helpers.ts +0 -96
  93. package/src/promise/index.ts +0 -300
  94. package/src/promise/misc.ts +0 -96
  95. package/src/promise/models.ts +0 -195
  96. package/src/promise/timed.ts +0 -91
  97. package/src/query.ts +0 -147
  98. package/src/queue.ts +0 -814
  99. package/src/random.ts +0 -125
  100. package/src/result/index.ts +0 -105
  101. package/src/result/match.ts +0 -124
  102. package/src/result/misc.ts +0 -129
  103. package/src/result/models.ts +0 -83
  104. package/src/result/work/flow.ts +0 -488
  105. package/src/result/work/pipe.ts +0 -496
  106. package/src/sized/map.ts +0 -110
  107. package/src/sized/set.ts +0 -107
  108. package/src/string/case.ts +0 -236
  109. package/src/string/fuzzy.ts +0 -444
  110. package/src/string/index.ts +0 -199
  111. package/src/string/match.ts +0 -80
  112. package/src/string/normalize.ts +0 -205
  113. package/src/string/template.ts +0 -161
  114. package/src/value/clone.ts +0 -319
  115. package/src/value/collection.ts +0 -63
  116. package/src/value/diff.ts +0 -232
  117. package/src/value/freeze.ts +0 -322
  118. package/src/value/handle.ts +0 -3
  119. package/src/value/index.ts +0 -5
  120. package/src/value/merge.ts +0 -278
  121. package/src/value/omit.ts +0 -20
  122. package/src/value/pick.ts +0 -20
  123. package/src/value/shake.ts +0 -45
  124. package/src/value/smush.ts +0 -89
  125. package/src/value/transform.ts +0 -153
  126. package/src/value/unsmush.ts +0 -84
package/src/array/move.ts DELETED
@@ -1,315 +0,0 @@
1
- import {arraysOverlap} from '../internal/array/overlap';
2
- import type {PlainObject} from '../models';
3
- import {indexOfArray} from './match';
4
-
5
- // #region Functions
6
-
7
- /**
8
- * Move an item _(or array of items)_ to the position of another item _(or array of items)_ within an array
9
- *
10
- * 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
11
- *
12
- * If either of values are not present in the array, or if they overlap, the array will be returned unchanged
13
- *
14
- * @param array Array to move within
15
- * @param from Item or items to move
16
- * @param to Item or items to move to
17
- * @param callback Callback to get an item's value for matching
18
- * @returns Original array with items moved _(or unchanged if unable to move)_
19
- *
20
- * @example
21
- * ```typescript
22
- * const array = [{id: 1}, {id: 2}, {id: 3}, {id: 4}];
23
- *
24
- * move(array, {id: 1}, {id: 3}, item => item.id); // => [{id: 2}, {id: 3}, {id: 1}, {id: 4}]
25
- * move(array, [{id: 2}, {id: 3}], {id: 4}, item => item.id); // => [{id: 1}, {id: 4}, {id: 2}, {id: 3}]
26
- * move(array, {id: 5}, {id: 1}, item => item.id); // => [{id: 1}, {id: 2}, {id: 3}, {id: 4}] (unchanged)
27
- * ```
28
- */
29
- export function move<Item>(
30
- array: Item[],
31
- from: Item | Item[],
32
- to: Item | Item[],
33
- callback: (item: Item, index: number, array: Item[]) => unknown,
34
- ): Item[];
35
-
36
- /**
37
- * Move an item _(or array of items)_ to the position of another item _(or array of items)_ within an array
38
- *
39
- * 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
40
- *
41
- * If either of values are not present in the array, or if they overlap, the array will be returned unchanged
42
- *
43
- * @param array Array to move within
44
- * @param from Item or items to move
45
- * @param to Item or items to move to
46
- * @param key Key to get an item's value for matching
47
- * @returns Original array with items moved _(or unchanged if unable to move)_
48
- *
49
- * @example
50
- * ```typescript
51
- * const array = [{id: 1}, {id: 2}, {id: 3}, {id: 4}];
52
- *
53
- * move(array, {id: 1}, {id: 3}, 'id'); // => [{id: 2}, {id: 3}, {id: 1}, {id: 4}]
54
- * move(array, [{id: 2}, {id: 3}], {id: 4}, 'id'); // => [{id: 1}, {id: 4}, {id: 2}, {id: 3}]
55
- * move(array, {id: 5}, {id: 1}, 'id'); // => [{id: 1}, {id: 2}, {id: 3}, {id: 4}] (unchanged)
56
- * ```
57
- */
58
- export function move<Item extends PlainObject, ItemKey extends keyof Item>(
59
- array: Item[],
60
- from: Item | Item[],
61
- to: Item | Item[],
62
- key: ItemKey,
63
- ): Item[];
64
-
65
- /**
66
- * Move an item _(or array of items)_ to the position of another item _(or array of items)_ within an array
67
- *
68
- * 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
69
- *
70
- * If either of values are not present in the array, or if they overlap, the array will be returned unchanged
71
- *
72
- * @param array Array to move within
73
- * @param from Item or items to move
74
- * @param to Item or items to move to
75
- * @returns Original array with items moved _(or unchanged if unable to move)_
76
- *
77
- * @example
78
- * ```typescript
79
- * const array = [1, 2, 3, 4];
80
- *
81
- * move(array, 1, 3); // => [2, 3, 1, 4]
82
- * move(array, [2, 3], 4); // => [1, 4, 2, 3]
83
- * move(array, 5, 1); // => [1, 2, 3, 4] (unchanged)
84
- * ```
85
- */
86
- export function move<Item>(array: Item[], from: Item | Item[], to: Item | Item[]): Item[];
87
-
88
- export function move(array: unknown[], from: unknown, to: unknown, key?: unknown): unknown[] {
89
- if (!Array.isArray(array)) {
90
- return [];
91
- }
92
-
93
- const firstArray = Array.isArray(from) ? from : [from];
94
- const secondArray = Array.isArray(to) ? to : [to];
95
-
96
- if (firstArray.length === 0 || secondArray.length === 0) {
97
- return array;
98
- }
99
-
100
- const firstPosition = indexOfArray(array, firstArray, key as never);
101
- const secondPosition = indexOfArray(array, secondArray, key as never);
102
-
103
- if (firstPosition === -1 || secondPosition === -1 || firstPosition === secondPosition) {
104
- return array;
105
- }
106
-
107
- const {overlap} = arraysOverlap(
108
- {
109
- array: firstArray,
110
- index: firstPosition,
111
- },
112
- {
113
- array: secondArray,
114
- index: secondPosition,
115
- },
116
- );
117
-
118
- if (overlap) {
119
- // The arrays overlap, so we can't swap them without losing data
120
-
121
- return array;
122
- }
123
-
124
- array.splice(firstPosition, firstArray.length);
125
-
126
- const next =
127
- secondPosition < firstPosition
128
- ? secondPosition
129
- : secondPosition + secondArray.length - firstArray.length;
130
-
131
- if (next >= array.length) {
132
- array.push(...firstArray);
133
- } else {
134
- array.splice(next, 0, ...firstArray);
135
- }
136
-
137
- return array;
138
- }
139
-
140
- move.indices = moveIndices;
141
- move.toIndex = moveToIndex;
142
-
143
- /**
144
- * Move an item from one index to another within an array
145
- *
146
- * If the from index is out of bounds, the array will be returned unchanged
147
- *
148
- * _Available as `moveIndices` and `move.indices`_
149
- *
150
- * @param array Array to move within
151
- * @param from Index to move from
152
- * @param to Index to move to
153
- * @returns Original array with item moved _(or unchanged if unable to move)_
154
- *
155
- * @example
156
- * ```typescript
157
- * const array = [1, 2, 3, 4];
158
- *
159
- * moveIndices(array, 0, 2); // => [2, 3, 1, 4]
160
- * moveIndices(array, -1, 0); // => [4, 2, 3, 1]
161
- * moveIndices(array, 5, 1); // => [4, 2, 3, 1] (unchanged)
162
- * ```
163
- */
164
- export function moveIndices<Item>(array: Item[], from: number, to: number): Item[] {
165
- if (!Array.isArray(array)) {
166
- return [];
167
- }
168
-
169
- const {length} = array;
170
-
171
- if (length === 0 || typeof from !== 'number' || typeof to !== 'number') {
172
- return array;
173
- }
174
-
175
- const fromIndex = from < 0 ? length + from : from;
176
- const toIndex = to < 0 ? length + to : to;
177
-
178
- if (fromIndex === toIndex || fromIndex >= length || toIndex >= length) {
179
- return array;
180
- }
181
-
182
- const spliced = array.splice(fromIndex, 1);
183
-
184
- if (toIndex >= array.length) {
185
- array.push(...spliced);
186
- } else {
187
- array.splice(toIndex, 0, ...spliced);
188
- }
189
-
190
- return array;
191
- }
192
-
193
- /**
194
- * Move an item _(or array of items)_ to an index within an array
195
- *
196
- * If the value is not present in the array, or if the index is out of bounds, the array will be returned unchanged
197
- *
198
- * _Available as `moveToIndex` and `move.toIndex`_
199
- *
200
- * @example
201
- * ```typescript
202
- * const array = [{id: 1}, {id: 2}, {id: 3}, {id: 4}];
203
- *
204
- * moveToIndex(array, {id: 1}, 2, item => item.id); // => [{id: 2}, {id: 3}, {id: 1}, {id: 4}]
205
- * moveToIndex(array, [{id: 2}, {id: 3}], 3, item => item.id); // => [{id: 1}, {id: 4}, {id: 2}, {id: 3}]
206
- * moveToIndex(array, {id: 5}, 1, item => item.id); // => [{id: 1}, {id: 2}, {id: 3}, {id: 4}] (unchanged)
207
- * ```
208
- *
209
- * @param array Array to move within
210
- * @param value Item or items to move
211
- * @param index Index to move to
212
- * @param callback Callback to get an item's value for matching
213
- * @returns Original array with items moved _(or unchanged if unable to move)_
214
- */
215
- export function moveToIndex<Item>(
216
- array: Item[],
217
- value: Item | Item[],
218
- index: number,
219
- callback: (item: Item, index: number, array: Item[]) => unknown,
220
- ): Item[];
221
-
222
- /**
223
- * Move an item _(or array of items)_ to an index within an array
224
- *
225
- * If the value is not present in the array, or if the index is out of bounds, the array will be returned unchanged
226
- *
227
- * _Available as `moveToIndex` and `move.toIndex`_
228
- *
229
- * @param array Array to move within
230
- * @param value Item or items to move
231
- * @param index Index to move to
232
- * @param key Key to get an item's value for matching
233
- * @returns Original array with items moved _(or unchanged if unable to move)_
234
- *
235
- * @example
236
- * ```typescript
237
- * const array = [{id: 1}, {id: 2}, {id: 3}, {id: 4}];
238
- *
239
- * moveToIndex(array, {id: 1}, 2, 'id'); // => [{id: 2}, {id: 3}, {id: 1}, {id: 4}]
240
- * moveToIndex(array, [{id: 2}, {id: 3}], 3, 'id'); // => [{id: 1}, {id: 4}, {id: 2}, {id: 3}]
241
- * moveToIndex(array, {id: 5}, 1, 'id'); // => [{id: 1}, {id: 2}, {id: 3}, {id: 4}] (unchanged)
242
- * ```
243
- */
244
- export function moveToIndex<Item extends PlainObject, ItemKey extends keyof Item>(
245
- array: Item[],
246
- value: Item | Item[],
247
- index: number,
248
- key: ItemKey,
249
- ): Item[];
250
-
251
- /**
252
- * Move an item _(or array of items)_ to an index within an array
253
- *
254
- * If the value is not present in the array, or if the index is out of bounds, the array will be returned unchanged
255
- *
256
- * _Available as `moveToIndex` and `move.toIndex`_
257
- *
258
- * @param array Array to move within
259
- * @param value Item or items to move
260
- * @param index Index to move to
261
- * @returns Original array with items moved _(or unchanged if unable to move)_
262
- *
263
- * @example
264
- * ```typescript
265
- * const array = [1, 2, 3, 4];
266
- *
267
- * moveToIndex(array, 1, 2); // => [2, 3, 1, 4]
268
- * moveToIndex(array, [2, 3], 3); // => [1, 4, 2, 3]
269
- * moveToIndex(array, 5, 1); // => [1, 2, 3, 4] (unchanged)
270
- * ```
271
- */
272
- export function moveToIndex<Item>(array: Item[], value: Item | Item[], index: number): Item[];
273
-
274
- export function moveToIndex(
275
- array: unknown[],
276
- value: unknown,
277
- index: number,
278
- key?: unknown,
279
- ): unknown[] {
280
- if (!Array.isArray(array)) {
281
- return [];
282
- }
283
-
284
- const {length} = array;
285
-
286
- if (length === 0 || typeof index !== 'number') {
287
- return array;
288
- }
289
-
290
- const next = index < 0 ? length + index : index;
291
-
292
- if (next >= length) {
293
- return array;
294
- }
295
-
296
- const values = Array.isArray(value) ? value : [value];
297
-
298
- const position = indexOfArray(array, values, key as never);
299
-
300
- if (position === -1 || position === next) {
301
- return array;
302
- }
303
-
304
- array.splice(position, values.length);
305
-
306
- if (next >= array.length) {
307
- array.push(...values);
308
- } else {
309
- array.splice(next, 0, ...values);
310
- }
311
-
312
- return array;
313
- }
314
-
315
- // #endregion
@@ -1,91 +0,0 @@
1
- import {FIND_VALUES_ALL, findValues} from '../internal/array/find';
2
- import type {PlainObject} from '../models';
3
-
4
- // #region Functions
5
-
6
- /**
7
- * Get a partitioned array of items
8
- *
9
- * @param array Array to search in
10
- * @param callback Callback to get an item's value for matching
11
- * @param value Value to match against
12
- * @returns Partitioned array of items
13
- *
14
- * @example
15
- * ```typescript
16
- * partition(
17
- * [{id: 1}, {id: 2}, {id: 3}],
18
- * item => item.id,
19
- * 2,
20
- * ); // => [[{id: 2}], [{id: 1}, {id: 3}]]
21
- * ```
22
- */
23
- export function partition<
24
- Item,
25
- Callback extends (item: Item, index: number, array: Item[]) => unknown,
26
- >(array: Item[], callback: Callback, value: ReturnType<Callback>): Item[][];
27
-
28
- /**
29
- * Get a partitioned array of items
30
- *
31
- * @param array Array to search in
32
- * @param key Key to get an item's value for matching
33
- * @param value Value to match against
34
- * @returns Partitioned array of items
35
- *
36
- * @example
37
- * ```typescript
38
- * partition(
39
- * [{id: 1}, {id: 2}, {id: 3}],
40
- * 'id',
41
- * 2,
42
- * ); // => [[{id: 2}], [{id: 1}, {id: 3}]]
43
- * ```
44
- */
45
- export function partition<Item extends PlainObject, ItemKey extends keyof Item>(
46
- array: Item[],
47
- key: ItemKey,
48
- value: Item[ItemKey],
49
- ): Item[][];
50
-
51
- /**
52
- * Get a partitioned array of items
53
- *
54
- * @param array Array to search in
55
- * @param filter Filter callback to match items
56
- * @returns Partitioned array of items
57
- *
58
- * @example
59
- * ```typescript
60
- * partition(
61
- * [{id: 1}, {id: 2}, {id: 3}],
62
- * item => item.id === 2,
63
- * ); // => [[{id: 2}], [{id: 1}, {id: 3}]]
64
- * ```
65
- */
66
- export function partition<Item>(
67
- array: Item[],
68
- filter: (item: Item, index: number, array: Item[]) => boolean,
69
- ): Item[][];
70
-
71
- /**
72
- * Get a partitioned array of items matching the given item
73
- *
74
- * @param array Array to search in
75
- * @param item Item to match against
76
- * @returns Partitioned array of items
77
- *
78
- * @example
79
- * ```typescript
80
- * partition([1, 2, 3, 4, 5], 3); // => [[3], [1, 2, 4, 5]]
81
- * ```
82
- */
83
- export function partition<Item>(array: Item[], item: Item): Item[][];
84
-
85
- export function partition(array: unknown[], ...parameters: unknown[]): unknown[][] {
86
- const {matched, notMatched} = findValues(FIND_VALUES_ALL, array, parameters);
87
-
88
- return [matched, notMatched];
89
- }
90
-
91
- // #endregion
package/src/array/push.ts DELETED
@@ -1,23 +0,0 @@
1
- import {INSERT_TYPE_PUSH, insertValues} from '../internal/array/insert';
2
-
3
- // #region Functions
4
-
5
- /**
6
- * Push items into an array _(at the end)_
7
- *
8
- * _(Uses chunking to avoid call stack size being exceeded)_
9
- *
10
- * @param array Original array
11
- * @param pushed Pushed items
12
- * @returns New length of the array
13
- *
14
- * @example
15
- * ```typescript
16
- * push([1, 2, 3], [4, 5]); // => 5 (new length); array becomes [1, 2, 3, 4, 5]
17
- * ```
18
- */
19
- export function push<Item>(array: Item[], pushed: Item[]): number {
20
- return insertValues(INSERT_TYPE_PUSH, array, pushed, array.length, 0) as number;
21
- }
22
-
23
- // #endregion
@@ -1,33 +0,0 @@
1
- // #region Functions
2
-
3
- /**
4
- * Reverse the order of items in an array
5
- *
6
- * @param array Array to reverse
7
- * @returns Reversed array
8
- */
9
- export function reverse<Item>(array: Item[]): Item[] {
10
- if (!Array.isArray(array)) {
11
- return [];
12
- }
13
-
14
- const {length} = array;
15
-
16
- if (length < 2) {
17
- return array;
18
- }
19
-
20
- const half = Math.floor(length / 2);
21
-
22
- for (let firstIndex = 0; firstIndex < half; firstIndex += 1) {
23
- const temporaryItem = array[firstIndex];
24
- const secondIndex = length - 1 - firstIndex;
25
-
26
- array[firstIndex] = array[secondIndex];
27
- array[secondIndex] = temporaryItem;
28
- }
29
-
30
- return array;
31
- }
32
-
33
- // #endregion Functions