@oscarpalmer/atoms 0.164.0 → 0.165.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.
@@ -1,6 +1,5 @@
1
1
  import { difference } from "./difference.mjs";
2
2
  import { exists } from "./exists.mjs";
3
- import { filter } from "./filter.mjs";
4
3
  import { find } from "./find.mjs";
5
4
  import { flatten } from "./flatten.mjs";
6
5
  import { range, times } from "./from.mjs";
@@ -11,7 +10,6 @@ import { indexOf } from "../internal/array/index-of.mjs";
11
10
  import { shuffle } from "../internal/array/shuffle.mjs";
12
11
  import { insert } from "./insert.mjs";
13
12
  import { intersection } from "./intersection.mjs";
14
- import { move } from "./move.mjs";
15
13
  import { partition } from "./partition.mjs";
16
14
  import { ArrayPosition, endsWithArray, getArrayPosition, includesArray, indexOfArray, startsWithArray } from "./position.mjs";
17
15
  import { push } from "./push.mjs";
@@ -19,9 +17,8 @@ import { select } from "./select.mjs";
19
17
  import { drop, slice, take } from "./slice.mjs";
20
18
  import { sort } from "./sort.mjs";
21
19
  import { splice } from "./splice.mjs";
22
- import { swap } from "./swap.mjs";
23
20
  import { toSet } from "./to-set.mjs";
24
21
  import { toggle } from "./toggle.mjs";
25
22
  import { union } from "./union.mjs";
26
23
  import { update } from "./update.mjs";
27
- export { ArrayPosition, chunk, compact, difference, drop, endsWithArray, exists, filter, find, flatten, getArray, getArrayPosition, includesArray, indexOf, indexOfArray, insert, intersection, move, partition, push, range, select, shuffle, slice, sort, splice, startsWithArray, swap, take, times, toSet, toggle, union, update };
24
+ export { ArrayPosition, chunk, compact, difference, drop, endsWithArray, exists, find, flatten, getArray, getArrayPosition, includesArray, indexOf, indexOfArray, insert, intersection, partition, push, range, select, shuffle, slice, sort, splice, startsWithArray, take, times, toSet, toggle, union, update };
@@ -4,24 +4,21 @@ import { indexOf } from "../internal/array/index-of.mjs";
4
4
  import { shuffle } from "../internal/array/shuffle.mjs";
5
5
  import { difference } from "./difference.mjs";
6
6
  import { exists } from "./exists.mjs";
7
- import { filter } from "./filter.mjs";
8
7
  import { find } from "./find.mjs";
9
8
  import { flatten } from "./flatten.mjs";
10
9
  import { range, times } from "./from.mjs";
11
10
  import { getArray } from "./get.mjs";
12
11
  import { insert } from "./insert.mjs";
13
12
  import { intersection } from "./intersection.mjs";
14
- import { endsWithArray, getArrayPosition, includesArray, indexOfArray, startsWithArray } from "./position.mjs";
15
- import { move } from "./move.mjs";
16
13
  import { partition } from "./partition.mjs";
14
+ import { endsWithArray, getArrayPosition, includesArray, indexOfArray, startsWithArray } from "./position.mjs";
17
15
  import { push } from "./push.mjs";
18
16
  import { select } from "./select.mjs";
19
17
  import { drop, slice, take } from "./slice.mjs";
20
18
  import { sort } from "./sort.mjs";
21
19
  import { splice } from "./splice.mjs";
22
- import { swap } from "./swap.mjs";
23
20
  import { toSet } from "./to-set.mjs";
24
21
  import { toggle } from "./toggle.mjs";
25
22
  import { union } from "./union.mjs";
26
23
  import { update } from "./update.mjs";
27
- export { chunk, compact, difference, drop, endsWithArray, exists, filter, find, flatten, getArray, getArrayPosition, includesArray, indexOf, indexOfArray, insert, intersection, move, partition, push, range, select, shuffle, slice, sort, splice, startsWithArray, swap, take, times, toSet, toggle, union, update };
24
+ export { chunk, compact, difference, drop, endsWithArray, exists, find, flatten, getArray, getArrayPosition, includesArray, indexOf, indexOfArray, insert, intersection, partition, push, range, select, shuffle, slice, sort, splice, startsWithArray, take, times, toSet, toggle, union, update };
@@ -1,5 +1,5 @@
1
- import { arraysOverlap } from "../internal/array/overlap.mjs";
2
1
  import { indexOfArray } from "./position.mjs";
2
+ import { arraysOverlap } from "../internal/array/overlap.mjs";
3
3
  //#region src/array/move.ts
4
4
  function move(array, from, to, key) {
5
5
  if (!Array.isArray(array)) return [];
@@ -1,7 +1,7 @@
1
1
  import { getArrayCallback } from "../internal/array/callbacks.mjs";
2
2
  import { indexOf } from "../internal/array/index-of.mjs";
3
- import { arraysOverlap } from "../internal/array/overlap.mjs";
4
3
  import { indexOfArray } from "./position.mjs";
4
+ import { arraysOverlap } from "../internal/array/overlap.mjs";
5
5
  //#region src/array/swap.ts
6
6
  function swap(array, first, second, third) {
7
7
  if (!Array.isArray(array)) return [];
@@ -1,7 +1,6 @@
1
1
  import { CancelableCallback, GenericCallback } from "../models.mjs";
2
2
  import { noop } from "../internal/function/misc.mjs";
3
3
  import { Memoized, MemoizedOptions, memoize } from "./memoize.mjs";
4
- import { once } from "./once.mjs";
5
4
 
6
5
  //#region src/function/index.d.ts
7
6
  /**
@@ -21,4 +20,4 @@ declare function debounce<Callback extends GenericCallback>(callback: Callback,
21
20
  */
22
21
  declare function throttle<Callback extends GenericCallback>(callback: Callback, time?: number): CancelableCallback<Callback>;
23
22
  //#endregion
24
- export { type Memoized, type MemoizedOptions, debounce, memoize, noop, once, throttle };
23
+ export { type Memoized, type MemoizedOptions, debounce, memoize, noop, throttle };
@@ -1,7 +1,6 @@
1
1
  import { noop } from "../internal/function/misc.mjs";
2
2
  import { TIMER_DEBOUNCE, TIMER_THROTTLE, getTimer } from "../internal/function/timer.mjs";
3
3
  import { memoize } from "./memoize.mjs";
4
- import { once } from "./once.mjs";
5
4
  //#region src/function/index.ts
6
5
  /**
7
6
  * Debounce a function, ensuring it is only called after `time` milliseconds have passed
@@ -24,4 +23,4 @@ function throttle(callback, time) {
24
23
  return getTimer(TIMER_THROTTLE, callback, time);
25
24
  }
26
25
  //#endregion
27
- export { debounce, memoize, noop, once, throttle };
26
+ export { debounce, memoize, noop, throttle };
package/dist/index.d.mts CHANGED
@@ -135,6 +135,45 @@ type ToString<Value> = Value extends string | number ? `${Value}` : never;
135
135
  */
136
136
  type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array;
137
137
  //#endregion
138
+ //#region src/array/filter.d.ts
139
+ /**
140
+ * Get a filtered array of items
141
+ * @param array Array to search in
142
+ * @param callback Callback to get an item's value for matching
143
+ * @param value Value to match against
144
+ * @returns Filtered array of items
145
+ */
146
+ declare function filter<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): Item[];
147
+ /**
148
+ * Get a filtered array of items
149
+ * @param array Array to search in
150
+ * @param key Key to get an item's value for matching
151
+ * @param value Value to match against
152
+ * @returns Filtered array of items
153
+ */
154
+ declare function filter<Item extends PlainObject, Key extends keyof Item>(array: Item[], key: Key, value: Item[Key]): Item[];
155
+ /**
156
+ * Get a filtered array of items matching the filter
157
+ * @param array Array to search in
158
+ * @param filter Filter callback to match items
159
+ * @returns Filtered array of items
160
+ */
161
+ declare function filter<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): Item[];
162
+ /**
163
+ * Get a filtered array of items matching the given item
164
+ * @param array Array to search in
165
+ * @param item Item to match against
166
+ * @returns Filtered array of items
167
+ */
168
+ declare function filter<Item>(array: Item[], item: Item): Item[];
169
+ declare namespace filter {
170
+ var remove: typeof removeFiltered;
171
+ }
172
+ declare function removeFiltered<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): unknown[];
173
+ declare function removeFiltered<Item extends PlainObject, Key extends keyof Item>(array: Item[], key: Key, value: Item[Key]): unknown[];
174
+ declare function removeFiltered<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): unknown[];
175
+ declare function removeFiltered<Item>(array: Item[], item: Item): unknown[];
176
+ //#endregion
138
177
  //#region src/array/group-by.d.ts
139
178
  /**
140
179
  * Create a record from an array of items using a specific key and value
@@ -371,45 +410,6 @@ declare function exists<Item>(array: Item[], filter: (item: Item, index: number,
371
410
  */
372
411
  declare function exists<Item>(array: Item[], item: Item): boolean;
373
412
  //#endregion
374
- //#region src/array/filter.d.ts
375
- /**
376
- * Get a filtered array of items
377
- * @param array Array to search in
378
- * @param callback Callback to get an item's value for matching
379
- * @param value Value to match against
380
- * @returns Filtered array of items
381
- */
382
- declare function filter<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): Item[];
383
- /**
384
- * Get a filtered array of items
385
- * @param array Array to search in
386
- * @param key Key to get an item's value for matching
387
- * @param value Value to match against
388
- * @returns Filtered array of items
389
- */
390
- declare function filter<Item extends PlainObject, Key extends keyof Item>(array: Item[], key: Key, value: Item[Key]): Item[];
391
- /**
392
- * Get a filtered array of items matching the filter
393
- * @param array Array to search in
394
- * @param filter Filter callback to match items
395
- * @returns Filtered array of items
396
- */
397
- declare function filter<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): Item[];
398
- /**
399
- * Get a filtered array of items matching the given item
400
- * @param array Array to search in
401
- * @param item Item to match against
402
- * @returns Filtered array of items
403
- */
404
- declare function filter<Item>(array: Item[], item: Item): Item[];
405
- declare namespace filter {
406
- var remove: typeof removeFiltered;
407
- }
408
- declare function removeFiltered<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): unknown[];
409
- declare function removeFiltered<Item extends PlainObject, Key extends keyof Item>(array: Item[], key: Key, value: Item[Key]): unknown[];
410
- declare function removeFiltered<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): unknown[];
411
- declare function removeFiltered<Item>(array: Item[], item: Item): unknown[];
412
- //#endregion
413
413
  //#region src/array/find.d.ts
414
414
  /**
415
415
  * Get the first items matching the given value
@@ -567,92 +567,6 @@ declare function intersection<First extends Record<string, unknown>, Second exte
567
567
  */
568
568
  declare function intersection<First, Second>(first: First[], second: Second[]): First[];
569
569
  //#endregion
570
- //#region src/array/move.d.ts
571
- /**
572
- * Move an item _(or array of items)_ to the position of another item _(or array of items)_ within an array
573
- *
574
- * 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.
575
- *
576
- * If either of values are not present in the array, or if they overlap, the array will be returned unchanged
577
- * @param array Array to move within
578
- * @param from Item or items to move
579
- * @param to Item or items to move to
580
- * @param key Key to get an item's value for matching
581
- * @returns Original array with items moved _(or unchanged if unable to move)_
582
- */
583
- declare function move<Item extends PlainObject, Key extends keyof Item>(array: Item[], from: Item | Item[], to: Item | Item[], key: Key): Item[];
584
- /**
585
- * Move an item _(or array of items)_ to the position of another item _(or array of items)_ within an array
586
- *
587
- * 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.
588
- *
589
- * If either of values are not present in the array, or if they overlap, the array will be returned unchanged
590
- * @param array Array to move within
591
- * @param from Item or items to move
592
- * @param to Item or items to move to
593
- * @param callback Callback to get an item's value for matching
594
- * @returns Original array with items moved _(or unchanged if unable to move)_
595
- */
596
- declare function move<Item>(array: Item[], from: Item | Item[], to: Item | Item[], callback: (item: Item, index: number, array: Item[]) => unknown): Item[];
597
- /**
598
- * Move an item _(or array of items)_ to the position of another item _(or array of items)_ within an array
599
- *
600
- * 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.
601
- *
602
- * If either of values are not present in the array, or if they overlap, the array will be returned unchanged
603
- * @param array Array to move within
604
- * @param from Item or items to move
605
- * @param to Item or items to move to
606
- * @returns Original array with items moved _(or unchanged if unable to move)_
607
- */
608
- declare function move<Item>(array: Item[], from: Item | Item[], to: Item | Item[]): Item[];
609
- declare namespace move {
610
- var indices: typeof moveIndices;
611
- var toIndex: typeof moveToIndex;
612
- }
613
- /**
614
- * Move an item from one index to another within an array
615
- *
616
- * If the from index is out of bounds, the array will be returned unchanged
617
- * @param array Array to move within
618
- * @param from Index to move from
619
- * @param to Index to move to
620
- * @returns Original array with item moved _(or unchanged if unable to move)_
621
- */
622
- declare function moveIndices<Item>(array: Item[], from: number, to: number): Item[];
623
- /**
624
- * Move an item _(or array of items)_ to an index within an array
625
- *
626
- * If the value is not present in the array, or if the index is out of bounds, the array will be returned unchanged
627
- * @param array Array to move within
628
- * @param value Item or items to move
629
- * @param index Index to move to
630
- * @param key Key to get an item's value for matching
631
- * @returns Original array with items moved _(or unchanged if unable to move)_
632
- */
633
- declare function moveToIndex<Item extends PlainObject, Key extends keyof Item>(array: Item[], value: Item | Item[], index: number, key: Key): Item[];
634
- /**
635
- * Move an item _(or array of items)_ to an index within an array
636
- *
637
- * If the value is not present in the array, or if the index is out of bounds, the array will be returned unchanged
638
- * @param array Array to move within
639
- * @param value Item or items to move
640
- * @param index Index to move to
641
- * @param callback Callback to get an item's value for matching
642
- * @returns Original array with items moved _(or unchanged if unable to move)_
643
- */
644
- declare function moveToIndex<Item>(array: Item[], value: Item | Item[], index: number, callback: (item: Item, index: number, array: Item[]) => unknown): Item[];
645
- /**
646
- * Move an item _(or array of items)_ to an index within an array
647
- *
648
- * If the value is not present in the array, or if the index is out of bounds, the array will be returned unchanged
649
- * @param array Array to move within
650
- * @param value Item or items to move
651
- * @param index Index to move to
652
- * @returns Original array with items moved _(or unchanged if unable to move)_
653
- */
654
- declare function moveToIndex<Item>(array: Item[], value: Item | Item[], index: number): Item[];
655
- //#endregion
656
570
  //#region src/array/partition.d.ts
657
571
  /**
658
572
  * Get a partitioned array of items
@@ -1065,83 +979,6 @@ declare function splice<Item>(array: Item[], start: number, amount: number): Ite
1065
979
  */
1066
980
  declare function splice<Item>(array: Item[], start: number): Item[];
1067
981
  //#endregion
1068
- //#region src/array/swap.d.ts
1069
- /**
1070
- * Swap two smaller arrays within a larger array
1071
- *
1072
- * If either of the smaller arrays are not present in the larger array, or if they overlap, the larger array will be returned unchanged
1073
- * @param array Array of items to swap
1074
- * @param first First array
1075
- * @param second Second array
1076
- * @param key Key to get an item's value for matching
1077
- * @returns Original array with items swapped _(or unchanged if unable to swap)_
1078
- */
1079
- declare function swap<Item extends PlainObject, Key extends keyof Item>(array: Item[], first: Item[], second: Item[], key: Key): Item[];
1080
- /**
1081
- * Swap two smaller arrays within a larger array
1082
- *
1083
- * If either of the smaller arrays are not present in the larger array, or if they overlap, the larger array will be returned unchanged
1084
- * @param array Array of items to swap
1085
- * @param first First array
1086
- * @param second Second array
1087
- * @param callback Callback to get an item's value for matching
1088
- * @returns Original array with items swapped _(or unchanged if unable to swap)_
1089
- */
1090
- declare function swap<Item>(array: Item[], first: Item[], second: Item[], callback: (item: Item, index: number, array: Item[]) => unknown): Item[];
1091
- /**
1092
- * Swap two smaller arrays within a larger array
1093
- *
1094
- * If either of the smaller arrays are not present in the larger array, or if they overlap, the larger array will be returned unchanged
1095
- * @param array Array of items to swap
1096
- * @param first First array
1097
- * @param second Second array
1098
- * @returns Original array with items swapped _(or unchanged if unable to swap)_
1099
- */
1100
- declare function swap<Item>(array: Item[], first: Item[], second: Item[]): Item[];
1101
- /**
1102
- * Swap two indiced items in an array
1103
- *
1104
- * If either of the items are not present in the array, the array will be returned unchanged
1105
- * @param array Array of items to swap
1106
- * @param first First item
1107
- * @param second Second item
1108
- * @param key Key to get an item's value for matching
1109
- * @returns Original array with items swapped _(or unchanged if unable to swap)_
1110
- */
1111
- declare function swap<Item extends PlainObject, Key extends keyof Item>(array: Item[], first: Item, second: Item, key: Key): Item[];
1112
- /**
1113
- * Swap two indiced items in an array
1114
- *
1115
- * If either of the items are not present in the array, the array will be returned unchanged
1116
- * @param array Array of items to swap
1117
- * @param first First item
1118
- * @param second Second item
1119
- * @param callback Callback to get an item's value for matching
1120
- * @returns Original array with items swapped _(or unchanged if unable to swap)_
1121
- */
1122
- declare function swap<Item>(array: Item[], first: Item, second: Item, callback: (item: Item, index: number, array: Item[]) => unknown): Item[];
1123
- /**
1124
- * Swap two indiced items in an array
1125
- * @param array Array of items to swap
1126
- * @param first First item
1127
- * @param second Second item
1128
- * @returns Original array with items swapped _(or unchanged if unable to swap)_
1129
- */
1130
- declare function swap<Item>(array: Item[], first: Item, second: Item): Item[];
1131
- declare namespace swap {
1132
- var indices: typeof swapIndices;
1133
- }
1134
- /**
1135
- * Swap two indiced items in an array
1136
- *
1137
- * If either index is out of bounds, the array will be returned unchanged
1138
- * @param array Array of items to swap
1139
- * @param first First index _(can be negative to count from the end)_
1140
- * @param second Second index _(can be negative to count from the end)_
1141
- * @returns Original array with items swapped _(or unchanged if unable to swap)_
1142
- */
1143
- declare function swapIndices<Item>(array: Item[], first: number, second: number): Item[];
1144
- //#endregion
1145
982
  //#region src/array/to-set.d.ts
1146
983
  /**
1147
984
  * Create a Set from an array of items using a callback
@@ -1239,6 +1076,169 @@ declare function update<Item extends PlainObject, Key extends keyof Item>(destin
1239
1076
  */
1240
1077
  declare function update<Item>(destination: Item[], updated: Item[]): Item[];
1241
1078
  //#endregion
1079
+ //#region src/array/move.d.ts
1080
+ /**
1081
+ * Move an item _(or array of items)_ to the position of another item _(or array of items)_ within an array
1082
+ *
1083
+ * 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.
1084
+ *
1085
+ * If either of values are not present in the array, or if they overlap, the array will be returned unchanged
1086
+ * @param array Array to move within
1087
+ * @param from Item or items to move
1088
+ * @param to Item or items to move to
1089
+ * @param key Key to get an item's value for matching
1090
+ * @returns Original array with items moved _(or unchanged if unable to move)_
1091
+ */
1092
+ declare function move<Item extends PlainObject, Key extends keyof Item>(array: Item[], from: Item | Item[], to: Item | Item[], key: Key): Item[];
1093
+ /**
1094
+ * Move an item _(or array of items)_ to the position of another item _(or array of items)_ within an array
1095
+ *
1096
+ * 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.
1097
+ *
1098
+ * If either of values are not present in the array, or if they overlap, the array will be returned unchanged
1099
+ * @param array Array to move within
1100
+ * @param from Item or items to move
1101
+ * @param to Item or items to move to
1102
+ * @param callback Callback to get an item's value for matching
1103
+ * @returns Original array with items moved _(or unchanged if unable to move)_
1104
+ */
1105
+ declare function move<Item>(array: Item[], from: Item | Item[], to: Item | Item[], callback: (item: Item, index: number, array: Item[]) => unknown): Item[];
1106
+ /**
1107
+ * Move an item _(or array of items)_ to the position of another item _(or array of items)_ within an array
1108
+ *
1109
+ * 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.
1110
+ *
1111
+ * If either of values are not present in the array, or if they overlap, the array will be returned unchanged
1112
+ * @param array Array to move within
1113
+ * @param from Item or items to move
1114
+ * @param to Item or items to move to
1115
+ * @returns Original array with items moved _(or unchanged if unable to move)_
1116
+ */
1117
+ declare function move<Item>(array: Item[], from: Item | Item[], to: Item | Item[]): Item[];
1118
+ declare namespace move {
1119
+ var indices: typeof moveIndices;
1120
+ var toIndex: typeof moveToIndex;
1121
+ }
1122
+ /**
1123
+ * Move an item from one index to another within an array
1124
+ *
1125
+ * If the from index is out of bounds, the array will be returned unchanged
1126
+ * @param array Array to move within
1127
+ * @param from Index to move from
1128
+ * @param to Index to move to
1129
+ * @returns Original array with item moved _(or unchanged if unable to move)_
1130
+ */
1131
+ declare function moveIndices<Item>(array: Item[], from: number, to: number): Item[];
1132
+ /**
1133
+ * Move an item _(or array of items)_ to an index within an array
1134
+ *
1135
+ * If the value is not present in the array, or if the index is out of bounds, the array will be returned unchanged
1136
+ * @param array Array to move within
1137
+ * @param value Item or items to move
1138
+ * @param index Index to move to
1139
+ * @param key Key to get an item's value for matching
1140
+ * @returns Original array with items moved _(or unchanged if unable to move)_
1141
+ */
1142
+ declare function moveToIndex<Item extends PlainObject, Key extends keyof Item>(array: Item[], value: Item | Item[], index: number, key: Key): Item[];
1143
+ /**
1144
+ * Move an item _(or array of items)_ to an index within an array
1145
+ *
1146
+ * If the value is not present in the array, or if the index is out of bounds, the array will be returned unchanged
1147
+ * @param array Array to move within
1148
+ * @param value Item or items to move
1149
+ * @param index Index to move to
1150
+ * @param callback Callback to get an item's value for matching
1151
+ * @returns Original array with items moved _(or unchanged if unable to move)_
1152
+ */
1153
+ declare function moveToIndex<Item>(array: Item[], value: Item | Item[], index: number, callback: (item: Item, index: number, array: Item[]) => unknown): Item[];
1154
+ /**
1155
+ * Move an item _(or array of items)_ to an index within an array
1156
+ *
1157
+ * If the value is not present in the array, or if the index is out of bounds, the array will be returned unchanged
1158
+ * @param array Array to move within
1159
+ * @param value Item or items to move
1160
+ * @param index Index to move to
1161
+ * @returns Original array with items moved _(or unchanged if unable to move)_
1162
+ */
1163
+ declare function moveToIndex<Item>(array: Item[], value: Item | Item[], index: number): Item[];
1164
+ //#endregion
1165
+ //#region src/array/swap.d.ts
1166
+ /**
1167
+ * Swap two smaller arrays within a larger array
1168
+ *
1169
+ * If either of the smaller arrays are not present in the larger array, or if they overlap, the larger array will be returned unchanged
1170
+ * @param array Array of items to swap
1171
+ * @param first First array
1172
+ * @param second Second array
1173
+ * @param key Key to get an item's value for matching
1174
+ * @returns Original array with items swapped _(or unchanged if unable to swap)_
1175
+ */
1176
+ declare function swap<Item extends PlainObject, Key extends keyof Item>(array: Item[], first: Item[], second: Item[], key: Key): Item[];
1177
+ /**
1178
+ * Swap two smaller arrays within a larger array
1179
+ *
1180
+ * If either of the smaller arrays are not present in the larger array, or if they overlap, the larger array will be returned unchanged
1181
+ * @param array Array of items to swap
1182
+ * @param first First array
1183
+ * @param second Second array
1184
+ * @param callback Callback to get an item's value for matching
1185
+ * @returns Original array with items swapped _(or unchanged if unable to swap)_
1186
+ */
1187
+ declare function swap<Item>(array: Item[], first: Item[], second: Item[], callback: (item: Item, index: number, array: Item[]) => unknown): Item[];
1188
+ /**
1189
+ * Swap two smaller arrays within a larger array
1190
+ *
1191
+ * If either of the smaller arrays are not present in the larger array, or if they overlap, the larger array will be returned unchanged
1192
+ * @param array Array of items to swap
1193
+ * @param first First array
1194
+ * @param second Second array
1195
+ * @returns Original array with items swapped _(or unchanged if unable to swap)_
1196
+ */
1197
+ declare function swap<Item>(array: Item[], first: Item[], second: Item[]): Item[];
1198
+ /**
1199
+ * Swap two indiced items in an array
1200
+ *
1201
+ * If either of the items are not present in the array, the array will be returned unchanged
1202
+ * @param array Array of items to swap
1203
+ * @param first First item
1204
+ * @param second Second item
1205
+ * @param key Key to get an item's value for matching
1206
+ * @returns Original array with items swapped _(or unchanged if unable to swap)_
1207
+ */
1208
+ declare function swap<Item extends PlainObject, Key extends keyof Item>(array: Item[], first: Item, second: Item, key: Key): Item[];
1209
+ /**
1210
+ * Swap two indiced items in an array
1211
+ *
1212
+ * If either of the items are not present in the array, the array will be returned unchanged
1213
+ * @param array Array of items to swap
1214
+ * @param first First item
1215
+ * @param second Second item
1216
+ * @param callback Callback to get an item's value for matching
1217
+ * @returns Original array with items swapped _(or unchanged if unable to swap)_
1218
+ */
1219
+ declare function swap<Item>(array: Item[], first: Item, second: Item, callback: (item: Item, index: number, array: Item[]) => unknown): Item[];
1220
+ /**
1221
+ * Swap two indiced items in an array
1222
+ * @param array Array of items to swap
1223
+ * @param first First item
1224
+ * @param second Second item
1225
+ * @returns Original array with items swapped _(or unchanged if unable to swap)_
1226
+ */
1227
+ declare function swap<Item>(array: Item[], first: Item, second: Item): Item[];
1228
+ declare namespace swap {
1229
+ var indices: typeof swapIndices;
1230
+ }
1231
+ /**
1232
+ * Swap two indiced items in an array
1233
+ *
1234
+ * If either index is out of bounds, the array will be returned unchanged
1235
+ * @param array Array of items to swap
1236
+ * @param first First index _(can be negative to count from the end)_
1237
+ * @param second Second index _(can be negative to count from the end)_
1238
+ * @returns Original array with items swapped _(or unchanged if unable to swap)_
1239
+ */
1240
+ declare function swapIndices<Item>(array: Item[], first: number, second: number): Item[];
1241
+ //#endregion
1242
1242
  //#region src/array/to-map.d.ts
1243
1243
  /**
1244
1244
  * Create a Map from an array of items using callbacks
@@ -1491,6 +1491,52 @@ declare function unique<Item extends PlainObject, ItemKey extends keyof Item>(ar
1491
1491
  */
1492
1492
  declare function unique<Item>(array: Item[]): Item[];
1493
1493
  //#endregion
1494
+ //#region src/function/assert.d.ts
1495
+ type Asserter<Value> = (value: unknown) => asserts value is Value;
1496
+ /**
1497
+ * Asserts that a condition is true, throwing an error if it is not
1498
+ * @param condition Condition to assert
1499
+ * @param message Error message
1500
+ * @param error Error constructor
1501
+ */
1502
+ declare function assert<Condition extends () => boolean>(condition: Condition, message: string, error?: ErrorConstructor): asserts condition;
1503
+ declare namespace assert {
1504
+ var condition: typeof assertCondition;
1505
+ var defined: typeof assertDefined;
1506
+ var instanceOf: typeof assertInstanceOf;
1507
+ var is: typeof assertIs;
1508
+ }
1509
+ /**
1510
+ * Creates an asserter that asserts a condition is true, throwing an error if it is not
1511
+ * @param condition Condition to assert
1512
+ * @param message Error message
1513
+ * @param error Error constructor
1514
+ * @returns Asserter
1515
+ */
1516
+ declare function assertCondition<Value>(condition: (value: unknown) => boolean, message: string, error?: ErrorConstructor): Asserter<Value>;
1517
+ /**
1518
+ * Asserts that a value is defined throwing an error if it is not
1519
+ * @param value Value to assert
1520
+ * @param message Error message
1521
+ */
1522
+ declare function assertDefined<Value>(value: unknown, message?: string): asserts value is Exclude<Value, null | undefined>;
1523
+ /**
1524
+ * Creates an asserter that asserts a value is an instance of a constructor, throwing an error if it is not
1525
+ * @param constructor Constructor to check against
1526
+ * @param message Error message
1527
+ * @param error Error constructor
1528
+ * @returns Asserter
1529
+ */
1530
+ declare function assertInstanceOf<Value>(constructor: Constructor<Value>, message: string, error?: ErrorConstructor): Asserter<Value>;
1531
+ /**
1532
+ * Creates an asserter that asserts a value is of a specific type, throwing an error if it is not
1533
+ * @param condition Type guard function to check the value
1534
+ * @param message Error message
1535
+ * @param error Error constructor
1536
+ * @returns Asserter
1537
+ */
1538
+ declare function assertIs<Value>(condition: (value: unknown) => value is Value, message: string, error?: ErrorConstructor): Asserter<Value>;
1539
+ //#endregion
1494
1540
  //#region src/internal/function/misc.d.ts
1495
1541
  /**
1496
1542
  * A function that does nothing, which can be useful, I guess…
@@ -1567,23 +1613,6 @@ type Options = {
1567
1613
  */
1568
1614
  declare function memoize<Callback extends GenericCallback>(callback: Callback, options?: MemoizedOptions<Callback>): Memoized<Callback>;
1569
1615
  //#endregion
1570
- //#region src/function/once.d.ts
1571
- /**
1572
- * Create an asynchronous function that can only be called once, rejecting or resolving the same result on subsequent calls
1573
- * @param callback Callback to use once
1574
- * @returns Once callback
1575
- */
1576
- declare function asyncOnce<Callback extends GenericAsyncCallback>(callback: Callback): OnceAsyncCallback<Callback>;
1577
- /**
1578
- * Create a function that can only be called once, returning the same value on subsequent calls
1579
- * @param callback Callback to use once
1580
- * @returns Once callback
1581
- */
1582
- declare function once<Callback extends GenericCallback>(callback: Callback): OnceCallback<Callback>;
1583
- declare namespace once {
1584
- var async: typeof asyncOnce;
1585
- }
1586
- //#endregion
1587
1616
  //#region src/function/index.d.ts
1588
1617
  /**
1589
1618
  * Debounce a function, ensuring it is only called after `time` milliseconds have passed
@@ -1602,6 +1631,23 @@ declare function debounce<Callback extends GenericCallback>(callback: Callback,
1602
1631
  */
1603
1632
  declare function throttle<Callback extends GenericCallback>(callback: Callback, time?: number): CancelableCallback<Callback>;
1604
1633
  //#endregion
1634
+ //#region src/function/once.d.ts
1635
+ /**
1636
+ * Create an asynchronous function that can only be called once, rejecting or resolving the same result on subsequent calls
1637
+ * @param callback Callback to use once
1638
+ * @returns Once callback
1639
+ */
1640
+ declare function asyncOnce<Callback extends GenericAsyncCallback>(callback: Callback): OnceAsyncCallback<Callback>;
1641
+ /**
1642
+ * Create a function that can only be called once, returning the same value on subsequent calls
1643
+ * @param callback Callback to use once
1644
+ * @returns Once callback
1645
+ */
1646
+ declare function once<Callback extends GenericCallback>(callback: Callback): OnceCallback<Callback>;
1647
+ declare namespace once {
1648
+ var async: typeof asyncOnce;
1649
+ }
1650
+ //#endregion
1605
1651
  //#region src/function/retry.d.ts
1606
1652
  declare class RetryError extends Error {
1607
1653
  readonly original: unknown;
@@ -4250,4 +4296,4 @@ declare class SizedSet<Value = unknown> extends Set<Value> {
4250
4296
  get(value: Value, update?: boolean): Value | undefined;
4251
4297
  }
4252
4298
  //#endregion
4253
- export { ArrayOrPlainObject, ArrayPosition, type Beacon, type BeaconOptions, BuiltIns, CancelableCallback, CancelablePromise, type Color, Constructor, DiffOptions, DiffResult, DiffValue, EqualOptions, type Err, EventPosition, type ExtendedErr, type ExtendedResult, Flow, FlowPromise, type FulfilledPromise, GenericAsyncCallback, GenericCallback, type HSLAColor, type HSLColor, HasValue, Key$1 as Key, KeyedValue, type Logger, type Memoized, type MemoizedOptions, MergeOptions, Merger, NestedArray, NestedKeys, NestedPartial, NestedValue, NestedValues, NumericalKeys, NumericalValues, type Observable, type Observer, type Ok, OnceAsyncCallback, OnceCallback, PlainObject, Primitive, type PromiseOptions, type PromiseStrategy, PromiseTimeoutError, type PromisesOptions, type PromisesResult, type PromisesValues as PromisesValue, type PromisesValue as PromisesValueItem, type Queue, QueueError, type QueueOptions, type Queued, type RGBAColor, type RGBColor, type RejectedPromise, RequiredKeys, type Result, RetryError, RetryOptions, Simplify, SizedMap, SizedSet, Smushed, type Subscription, TemplateOptions, type Time, ToString, TypedArray, Unsmushed, attempt, attemptPromise, average, beacon, between, camelCase, cancelable, capitalize, ceil, chunk, clamp, clone, compact, compare, count, debounce, delay, diff, difference, drop, endsWith, endsWithArray, equal, error, exists, filter, find, flatten, floor, flow, toResult as fromPromise, toResult, fromQuery, toPromise as fromResult, toPromise, getArray, getArrayPosition, getColor, getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getNormalizedHex, getNumber, getRandomBoolean, getRandomCharacters, getRandomColor, getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems, getRgbColor, getRgbaColor, getString, getUuid, getValue, groupBy, hasValue, hexToHsl, hexToHsla, hexToRgb, hexToRgba, hslToHex, hslToRgb, hslToRgba, ignoreKey, includes, includesArray, indexOf, indexOfArray, insert, intersection, isArrayOrPlainObject, isColor, isConstructor, isEmpty, isError, isFulfilled, isHexColor, isHslColor, isHslLike, isHslaColor, isInstanceOf, isKey, isNonNullable, isNullable, isNullableOrEmpty, isNullableOrWhitespace, isNumber, isNumerical, isObject, isOk, isPlainObject, isPrimitive, isRejected, isResult, isRgbColor, isRgbLike, isRgbaColor, isTypedArray, join, kebabCase, logger, lowerCase, max, median, memoize, merge, min, move, noop, ok, omit, once, parse, partition, pascalCase, pick, pipe, promises, push, queue, range, retry, rgbToHex, rgbToHsl, rgbToHsla, round, select, setValue, shuffle, slice, smush, snakeCase, sort, splice, startsWith, startsWithArray, sum, swap, take, template, throttle, timed, times, titleCase, toMap, toQuery, toRecord, toSet, toggle, trim, truncate, tryDecode, tryEncode, union, unique, unsmush, unwrap, update, upperCase, words };
4299
+ export { ArrayOrPlainObject, ArrayPosition, Asserter, type Beacon, type BeaconOptions, BuiltIns, CancelableCallback, CancelablePromise, type Color, Constructor, DiffOptions, DiffResult, DiffValue, EqualOptions, type Err, EventPosition, type ExtendedErr, type ExtendedResult, Flow, FlowPromise, type FulfilledPromise, GenericAsyncCallback, GenericCallback, type HSLAColor, type HSLColor, HasValue, Key$1 as Key, KeyedValue, type Logger, type Memoized, type MemoizedOptions, MergeOptions, Merger, NestedArray, NestedKeys, NestedPartial, NestedValue, NestedValues, NumericalKeys, NumericalValues, type Observable, type Observer, type Ok, OnceAsyncCallback, OnceCallback, PlainObject, Primitive, type PromiseOptions, type PromiseStrategy, PromiseTimeoutError, type PromisesOptions, type PromisesResult, type PromisesValues as PromisesValue, type PromisesValue as PromisesValueItem, type Queue, QueueError, type QueueOptions, type Queued, type RGBAColor, type RGBColor, type RejectedPromise, RequiredKeys, type Result, RetryError, RetryOptions, Simplify, SizedMap, SizedSet, Smushed, type Subscription, TemplateOptions, type Time, ToString, TypedArray, Unsmushed, assert, attempt, attemptPromise, average, beacon, between, camelCase, cancelable, capitalize, ceil, chunk, clamp, clone, compact, compare, count, debounce, delay, diff, difference, drop, endsWith, endsWithArray, equal, error, exists, filter, find, flatten, floor, flow, toResult as fromPromise, toResult, fromQuery, toPromise as fromResult, toPromise, getArray, getArrayPosition, getColor, getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getNormalizedHex, getNumber, getRandomBoolean, getRandomCharacters, getRandomColor, getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems, getRgbColor, getRgbaColor, getString, getUuid, getValue, groupBy, hasValue, hexToHsl, hexToHsla, hexToRgb, hexToRgba, hslToHex, hslToRgb, hslToRgba, ignoreKey, includes, includesArray, indexOf, indexOfArray, insert, intersection, isArrayOrPlainObject, isColor, isConstructor, isEmpty, isError, isFulfilled, isHexColor, isHslColor, isHslLike, isHslaColor, isInstanceOf, isKey, isNonNullable, isNullable, isNullableOrEmpty, isNullableOrWhitespace, isNumber, isNumerical, isObject, isOk, isPlainObject, isPrimitive, isRejected, isResult, isRgbColor, isRgbLike, isRgbaColor, isTypedArray, join, kebabCase, logger, lowerCase, max, median, memoize, merge, min, move, noop, ok, omit, once, parse, partition, pascalCase, pick, pipe, promises, push, queue, range, retry, rgbToHex, rgbToHsl, rgbToHsla, round, select, setValue, shuffle, slice, smush, snakeCase, sort, splice, startsWith, startsWithArray, sum, swap, take, template, throttle, timed, times, titleCase, toMap, toQuery, toRecord, toSet, toggle, trim, truncate, tryDecode, tryEncode, union, unique, unsmush, unwrap, update, upperCase, words };