@oscarpalmer/atoms 0.202.0 → 0.203.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/dist/array/difference.d.mts +4 -5
  2. package/dist/array/exists.d.mts +5 -6
  3. package/dist/array/filter.d.mts +10 -11
  4. package/dist/array/find.d.mts +10 -11
  5. package/dist/array/first.d.mts +10 -11
  6. package/dist/array/flatten.d.mts +2 -3
  7. package/dist/array/from.d.mts +7 -8
  8. package/dist/array/group-by.d.mts +7 -8
  9. package/dist/array/insert.d.mts +3 -4
  10. package/dist/array/intersection.d.mts +4 -5
  11. package/dist/array/last.d.mts +10 -11
  12. package/dist/array/move.d.mts +9 -10
  13. package/dist/array/partition.d.mts +5 -6
  14. package/dist/array/push.d.mts +2 -3
  15. package/dist/array/reverse.d.mts +2 -3
  16. package/dist/array/select.d.mts +11 -12
  17. package/dist/array/single.d.mts +4 -5
  18. package/dist/array/slice.d.mts +12 -13
  19. package/dist/array/sort.d.mts +31 -32
  20. package/dist/array/sort.mjs +41 -33
  21. package/dist/array/splice.d.mts +5 -6
  22. package/dist/array/swap.d.mts +8 -9
  23. package/dist/array/to-map.d.mts +7 -8
  24. package/dist/array/to-record.d.mts +7 -8
  25. package/dist/array/to-set.d.mts +4 -5
  26. package/dist/array/toggle.d.mts +4 -5
  27. package/dist/array/union.d.mts +4 -5
  28. package/dist/array/unique.d.mts +4 -5
  29. package/dist/array/update.d.mts +4 -5
  30. package/dist/beacon.d.mts +8 -9
  31. package/dist/beacon.mjs +90 -65
  32. package/dist/color/constants.d.mts +14 -13
  33. package/dist/color/constants.mjs +9 -2
  34. package/dist/color/index.d.mts +2 -2
  35. package/dist/color/instance.d.mts +3 -3
  36. package/dist/color/instance.mjs +125 -61
  37. package/dist/color/misc/alpha.d.mts +4 -5
  38. package/dist/color/misc/format.d.mts +6 -7
  39. package/dist/color/misc/format.mjs +15 -12
  40. package/dist/color/misc/get.d.mts +14 -15
  41. package/dist/color/misc/is.d.mts +16 -17
  42. package/dist/color/misc/is.mjs +3 -4
  43. package/dist/color/misc/state.d.mts +8 -10
  44. package/dist/color/misc/state.mjs +22 -20
  45. package/dist/color/models.d.mts +25 -19
  46. package/dist/color/space/hex.d.mts +9 -10
  47. package/dist/color/space/hsl.d.mts +8 -9
  48. package/dist/color/space/hwb.d.mts +9 -10
  49. package/dist/color/space/rgb.d.mts +11 -12
  50. package/dist/function/limit.d.mts +9 -8
  51. package/dist/function/limit.mjs +5 -5
  52. package/dist/function/once.d.mts +26 -6
  53. package/dist/function/once.mjs +135 -76
  54. package/dist/function/retry.d.mts +5 -6
  55. package/dist/function/retry.mjs +3 -3
  56. package/dist/index.d.mts +182 -58
  57. package/dist/index.mjs +1191 -810
  58. package/dist/internal/abort.d.mts +3 -4
  59. package/dist/internal/array/callbacks.d.mts +4 -5
  60. package/dist/internal/array/chunk.d.mts +2 -3
  61. package/dist/internal/array/compact.d.mts +3 -4
  62. package/dist/internal/array/find.d.mts +10 -11
  63. package/dist/internal/array/get.d.mts +7 -8
  64. package/dist/internal/array/group.d.mts +2 -3
  65. package/dist/internal/array/index-of.d.mts +10 -11
  66. package/dist/internal/array/insert.d.mts +5 -6
  67. package/dist/internal/array/match.d.mts +17 -18
  68. package/dist/internal/array/overlap.d.mts +2 -3
  69. package/dist/internal/array/sets.d.mts +5 -6
  70. package/dist/internal/array/shuffle.d.mts +2 -3
  71. package/dist/internal/array/update.d.mts +2 -3
  72. package/dist/internal/defaults.d.mts +3 -4
  73. package/dist/internal/function/assert.d.mts +10 -11
  74. package/dist/internal/function/limit.d.mts +41 -0
  75. package/dist/internal/function/limit.mjs +110 -0
  76. package/dist/internal/function/memoize.d.mts +4 -5
  77. package/dist/internal/function/memoize.mjs +53 -31
  78. package/dist/internal/function/misc.d.mts +2 -3
  79. package/dist/internal/function/work.d.mts +53 -54
  80. package/dist/internal/herald.d.mts +8 -9
  81. package/dist/internal/herald.mjs +38 -26
  82. package/dist/internal/is.d.mts +19 -20
  83. package/dist/internal/math/aggregate.d.mts +14 -15
  84. package/dist/internal/math/misc.d.mts +3 -4
  85. package/dist/internal/number.d.mts +4 -5
  86. package/dist/internal/random.d.mts +3 -4
  87. package/dist/internal/result/misc.d.mts +29 -14
  88. package/dist/internal/result/misc.mjs +4 -0
  89. package/dist/internal/result/models.d.mts +9 -10
  90. package/dist/internal/sized/map.d.mts +2 -3
  91. package/dist/internal/sized/misc.d.mts +2 -3
  92. package/dist/internal/string/case.d.mts +9 -10
  93. package/dist/internal/string/misc.d.mts +8 -9
  94. package/dist/internal/subscription.d.mts +10 -11
  95. package/dist/internal/subscription.mjs +69 -57
  96. package/dist/internal/value/compare.d.mts +17 -9
  97. package/dist/internal/value/compare.mjs +7 -7
  98. package/dist/internal/value/equal.d.mts +34 -15
  99. package/dist/internal/value/equal.mjs +28 -13
  100. package/dist/internal/value/get.d.mts +3 -4
  101. package/dist/internal/value/handlers.d.mts +19 -9
  102. package/dist/internal/value/handlers.mjs +50 -50
  103. package/dist/internal/value/has.d.mts +6 -7
  104. package/dist/internal/value/misc.d.mts +6 -7
  105. package/dist/internal/value/partial.d.mts +3 -4
  106. package/dist/internal/value/set.d.mts +4 -5
  107. package/dist/is.d.mts +13 -13
  108. package/dist/logger.d.mts +5 -4
  109. package/dist/logger.mjs +61 -54
  110. package/dist/math.d.mts +20 -20
  111. package/dist/models.d.mts +45 -49
  112. package/dist/promise/constants.d.mts +14 -15
  113. package/dist/promise/delay.d.mts +3 -4
  114. package/dist/promise/delay.mjs +4 -4
  115. package/dist/promise/helpers.d.mts +7 -8
  116. package/dist/promise/index.d.mts +13 -14
  117. package/dist/promise/misc.d.mts +6 -6
  118. package/dist/promise/models.d.mts +16 -17
  119. package/dist/promise/timed.d.mts +4 -5
  120. package/dist/promise/timed.mjs +5 -5
  121. package/dist/query.d.mts +3 -4
  122. package/dist/queue.d.mts +14 -15
  123. package/dist/queue.mjs +185 -129
  124. package/dist/random.d.mts +8 -8
  125. package/dist/result/index.d.mts +8 -9
  126. package/dist/result/match.d.mts +6 -7
  127. package/dist/result/misc.d.mts +3 -3
  128. package/dist/result/work/flow.d.mts +28 -29
  129. package/dist/result/work/pipe.d.mts +24 -25
  130. package/dist/sized/set.d.mts +2 -3
  131. package/dist/string/fuzzy.d.mts +21 -12
  132. package/dist/string/fuzzy.mjs +77 -49
  133. package/dist/string/index.d.mts +8 -8
  134. package/dist/string/match.d.mts +4 -5
  135. package/dist/string/normalize.d.mts +8 -9
  136. package/dist/string/normalize.mjs +9 -4
  137. package/dist/string/template.d.mts +9 -9
  138. package/dist/string/template.mjs +11 -4
  139. package/dist/value/clone.d.mts +21 -13
  140. package/dist/value/clone.mjs +22 -20
  141. package/dist/value/collection.d.mts +4 -5
  142. package/dist/value/diff.d.mts +5 -6
  143. package/dist/value/freeze.d.mts +18 -19
  144. package/dist/value/freeze.mjs +1 -1
  145. package/dist/value/merge.d.mts +13 -14
  146. package/dist/value/merge.mjs +21 -5
  147. package/dist/value/omit.d.mts +2 -3
  148. package/dist/value/pick.d.mts +2 -3
  149. package/dist/value/shake.d.mts +3 -4
  150. package/dist/value/smush.d.mts +3 -4
  151. package/dist/value/transform.d.mts +15 -10
  152. package/dist/value/transform.mjs +12 -7
  153. package/dist/value/unsmush.d.mts +3 -4
  154. package/package.json +1 -1
  155. package/dist/internal/function/timer.d.mts +0 -10
  156. package/dist/internal/function/timer.mjs +0 -87
@@ -22,7 +22,7 @@ type ObjectKeysOf<Item> = { [Key in keyof Item]: Item[Key] extends PlainObject ?
22
22
  * ); // => ['Bob']
23
23
  * ```
24
24
  */
25
- declare function reverseSelect<Item, Map extends MapKeyOrCallback<Item>, FilterCallback extends (item: Mapped<Item, Map>, index: number, array: Item[]) => unknown>(array: Item[], map: Map, filterCallback: FilterCallback, filterValue: ReturnType<FilterCallback>): Array<Mapped<Item, Map>>;
25
+ export declare function reverseSelect<Item, Map extends MapKeyOrCallback<Item>, FilterCallback extends (item: Mapped<Item, Map>, index: number, array: Item[]) => unknown>(array: Item[], map: Map, filterCallback: FilterCallback, filterValue: ReturnType<FilterCallback>): Array<Mapped<Item, Map>>;
26
26
  /**
27
27
  * Get a mapped and filtered array of items
28
28
  *
@@ -42,7 +42,7 @@ declare function reverseSelect<Item, Map extends MapKeyOrCallback<Item>, FilterC
42
42
  * ); // => [{label: 'Bob'}]
43
43
  * ```
44
44
  */
45
- declare function reverseSelect<Item, MapCallback extends (item: Item, index: number, array: Item[]) => PlainObject, ItemKey extends keyof ReturnType<MapCallback>>(array: Item[], map: MapCallback, filterKey: ItemKey, filterValue: ReturnType<MapCallback>[ItemKey]): Array<ReturnType<MapCallback>>;
45
+ export declare function reverseSelect<Item, MapCallback extends (item: Item, index: number, array: Item[]) => PlainObject, ItemKey extends keyof ReturnType<MapCallback>>(array: Item[], map: MapCallback, filterKey: ItemKey, filterValue: ReturnType<MapCallback>[ItemKey]): Array<ReturnType<MapCallback>>;
46
46
  /**
47
47
  * Get a mapped and filtered array of items
48
48
  *
@@ -62,7 +62,7 @@ declare function reverseSelect<Item, MapCallback extends (item: Item, index: num
62
62
  * ); // => [{tag: 'b'}]
63
63
  * ```
64
64
  */
65
- declare function reverseSelect<Item, MapKey extends ObjectKeysOf<Item>, ItemKey extends keyof Item[MapKey]>(array: Item[], map: MapKey, filterKey: ItemKey, filterValue: Item[MapKey][ItemKey]): Array<Item[MapKey]>;
65
+ export declare function reverseSelect<Item, MapKey extends ObjectKeysOf<Item>, ItemKey extends keyof Item[MapKey]>(array: Item[], map: MapKey, filterKey: ItemKey, filterValue: Item[MapKey][ItemKey]): Array<Item[MapKey]>;
66
66
  /**
67
67
  * Get a mapped and filtered array of items
68
68
  *
@@ -80,7 +80,7 @@ declare function reverseSelect<Item, MapKey extends ObjectKeysOf<Item>, ItemKey
80
80
  * ); // => ['Bob']
81
81
  * ```
82
82
  */
83
- declare function reverseSelect<Item, Map extends MapKeyOrCallback<Item>>(array: Item[], map: Map, filter: (item: Mapped<Item, Map>, index: number, array: Item[]) => boolean): Array<Mapped<Item, Map>>;
83
+ export declare function reverseSelect<Item, Map extends MapKeyOrCallback<Item>>(array: Item[], map: Map, filter: (item: Mapped<Item, Map>, index: number, array: Item[]) => boolean): Array<Mapped<Item, Map>>;
84
84
  /**
85
85
  * Get a mapped and filtered array of items
86
86
  *
@@ -98,7 +98,7 @@ declare function reverseSelect<Item, Map extends MapKeyOrCallback<Item>>(array:
98
98
  * ); // => [4, 4]
99
99
  * ```
100
100
  */
101
- declare function reverseSelect<Item, Map extends MapKeyOrCallback<Item>>(array: Item[], map: Map, value: Mapped<Item, Map>): Array<Mapped<Item, Map>>;
101
+ export declare function reverseSelect<Item, Map extends MapKeyOrCallback<Item>>(array: Item[], map: Map, value: Mapped<Item, Map>): Array<Mapped<Item, Map>>;
102
102
  /**
103
103
  * Get a filtered and mapped array of items
104
104
  *
@@ -118,7 +118,7 @@ declare function reverseSelect<Item, Map extends MapKeyOrCallback<Item>>(array:
118
118
  * ); // => ['Bob']
119
119
  * ```
120
120
  */
121
- declare function select<Item, FilterCallback extends (item: Item, index: number, array: Item[]) => unknown, Map extends MapKeyOrCallback<Item>>(array: Item[], filterCallback: FilterCallback, filterValue: ReturnType<FilterCallback>, map: Map): Array<Mapped<Item, Map>>;
121
+ export declare function select<Item, FilterCallback extends (item: Item, index: number, array: Item[]) => unknown, Map extends MapKeyOrCallback<Item>>(array: Item[], filterCallback: FilterCallback, filterValue: ReturnType<FilterCallback>, map: Map): Array<Mapped<Item, Map>>;
122
122
  /**
123
123
  * Get a filtered and mapped array of items
124
124
  *
@@ -138,7 +138,7 @@ declare function select<Item, FilterCallback extends (item: Item, index: number,
138
138
  * ); // => ['Bob']
139
139
  * ```
140
140
  */
141
- declare function select<Item extends PlainObject, ItemKey extends keyof Item, Map extends MapKeyOrCallback<Item>>(array: Item[], filterKey: ItemKey, filterValue: Item[ItemKey], map: Map): Array<Mapped<Item, Map>>;
141
+ export declare function select<Item extends PlainObject, ItemKey extends keyof Item, Map extends MapKeyOrCallback<Item>>(array: Item[], filterKey: ItemKey, filterValue: Item[ItemKey], map: Map): Array<Mapped<Item, Map>>;
142
142
  /**
143
143
  * Get a filtered and mapped array of items
144
144
  *
@@ -156,7 +156,7 @@ declare function select<Item extends PlainObject, ItemKey extends keyof Item, Ma
156
156
  * ); // => ['Bob']
157
157
  * ```
158
158
  */
159
- declare function select<Item, Map extends MapKeyOrCallback<Item>>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean, map: Map): Array<Mapped<Item, Map>>;
159
+ export declare function select<Item, Map extends MapKeyOrCallback<Item>>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean, map: Map): Array<Mapped<Item, Map>>;
160
160
  /**
161
161
  * Get a filtered and mapped array of items
162
162
  *
@@ -174,9 +174,8 @@ declare function select<Item, Map extends MapKeyOrCallback<Item>>(array: Item[],
174
174
  * ); // => [9]
175
175
  * ```
176
176
  */
177
- declare function select<Item, Map extends MapKeyOrCallback<Item>>(array: Item[], item: Item, map: Map): Array<Mapped<Item, Map>>;
178
- declare namespace select {
177
+ export declare function select<Item, Map extends MapKeyOrCallback<Item>>(array: Item[], item: Item, map: Map): Array<Mapped<Item, Map>>;
178
+ export declare namespace select {
179
179
  var reverse: typeof reverseSelect;
180
180
  }
181
- //#endregion
182
- export { reverseSelect, select };
181
+ //#endregion
@@ -19,7 +19,7 @@ import { PlainObject } from "../models.mjs";
19
19
  * ); // => {id: 2}
20
20
  * ```
21
21
  */
22
- declare function single<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): Item | undefined;
22
+ export declare function single<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): Item | undefined;
23
23
  /**
24
24
  * Get the _only_ item matching the given value by key
25
25
  *
@@ -39,7 +39,7 @@ declare function single<Item, Callback extends (item: Item, index: number, array
39
39
  * ); // => {id: 2}
40
40
  * ```
41
41
  */
42
- declare function single<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): Item | undefined;
42
+ export declare function single<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): Item | undefined;
43
43
  /**
44
44
  * Get the _only_ item matching the filter
45
45
  *
@@ -57,6 +57,5 @@ declare function single<Item extends PlainObject, ItemKey extends keyof Item>(ar
57
57
  * ); // => {id: 2}
58
58
  * ```
59
59
  */
60
- declare function single<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): Item | undefined;
61
- //#endregion
62
- export { single };
60
+ export declare function single<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): Item | undefined;
61
+ //#endregion
@@ -17,7 +17,7 @@ import { PlainObject } from "../models.mjs";
17
17
  * ); // => [{id: 2}, {id: 3}]
18
18
  * ```
19
19
  */
20
- declare function drop<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): Item[];
20
+ export declare function drop<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): Item[];
21
21
  /**
22
22
  * Drop items from the start of an array until they match a value
23
23
  *
@@ -35,7 +35,7 @@ declare function drop<Item, Callback extends (item: Item, index: number, array:
35
35
  * ); // => [{id: 2}, {id: 3}]
36
36
  * ```
37
37
  */
38
- declare function drop<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): Item[];
38
+ export declare function drop<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): Item[];
39
39
  /**
40
40
  * Drop items from the start of an array while they match a filter
41
41
  *
@@ -51,7 +51,7 @@ declare function drop<Item extends PlainObject, ItemKey extends keyof Item>(arra
51
51
  * ); // => [{id: 2}, {id: 3}]
52
52
  * ```
53
53
  */
54
- declare function drop<Item extends PlainObject>(array: Item[], callback: (item: Item, index: number, array: Item[]) => boolean): Item[];
54
+ export declare function drop<Item extends PlainObject>(array: Item[], callback: (item: Item, index: number, array: Item[]) => boolean): Item[];
55
55
  /**
56
56
  * Drop a specified number of items, from the start if `>= 0`, or from the end if `< 0`
57
57
  *
@@ -65,7 +65,7 @@ declare function drop<Item extends PlainObject>(array: Item[], callback: (item:
65
65
  * drop([1, 2, 3, 4, 5], -2); // => [1, 2, 3]
66
66
  * ```
67
67
  */
68
- declare function drop(array: unknown[], count: number): unknown[];
68
+ export declare function drop(array: unknown[], count: number): unknown[];
69
69
  /**
70
70
  * Slice an array _(returning a new array with a specified range of items)_
71
71
  *
@@ -79,7 +79,7 @@ declare function drop(array: unknown[], count: number): unknown[];
79
79
  * slice([1, 2, 3, 4, 5], 1, 4); // => [2, 3, 4]
80
80
  * ```
81
81
  */
82
- declare function slice<Item>(array: Item[], start: number, end: number): Item[];
82
+ export declare function slice<Item>(array: Item[], start: number, end: number): Item[];
83
83
  /**
84
84
  * Slice an array _(returning a new array with a specified number of items, from the start)_
85
85
  *
@@ -92,7 +92,7 @@ declare function slice<Item>(array: Item[], start: number, end: number): Item[];
92
92
  * slice([1, 2, 3, 4, 5], 3); // => [1, 2, 3]
93
93
  * ```
94
94
  */
95
- declare function slice<Item>(array: Item[], count: number): Item[];
95
+ export declare function slice<Item>(array: Item[], count: number): Item[];
96
96
  /**
97
97
  * Slice an array _(returning a new array with all items)_
98
98
  *
@@ -104,7 +104,7 @@ declare function slice<Item>(array: Item[], count: number): Item[];
104
104
  * slice([1, 2, 3]); // => [1, 2, 3]
105
105
  * ```
106
106
  */
107
- declare function slice<Item>(array: Item[]): Item[];
107
+ export declare function slice<Item>(array: Item[]): Item[];
108
108
  /**
109
109
  * Take items from the start of an array until they match a value
110
110
  *
@@ -122,7 +122,7 @@ declare function slice<Item>(array: Item[]): Item[];
122
122
  * ); // => [{id: 1}]
123
123
  * ```
124
124
  */
125
- declare function take<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): Item[];
125
+ export declare function take<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): Item[];
126
126
  /**
127
127
  * Take items from the start of an array until they match a value
128
128
  *
@@ -140,7 +140,7 @@ declare function take<Item, Callback extends (item: Item, index: number, array:
140
140
  * ); // => [{id: 1}]
141
141
  * ```
142
142
  */
143
- declare function take<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): Item[];
143
+ export declare function take<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): Item[];
144
144
  /**
145
145
  * Take items from the start of an array while they match a filter
146
146
  *
@@ -156,7 +156,7 @@ declare function take<Item extends PlainObject, ItemKey extends keyof Item>(arra
156
156
  * ); // => [{id: 1}]
157
157
  * ```
158
158
  */
159
- declare function take<Item extends PlainObject>(array: Item[], callback: (item: Item, index: number, array: Item[]) => boolean): Item[];
159
+ export declare function take<Item extends PlainObject>(array: Item[], callback: (item: Item, index: number, array: Item[]) => boolean): Item[];
160
160
  /**
161
161
  * Take a specified number of items, from the start if `>= 0`, or from the end if `< 0`
162
162
  *
@@ -170,6 +170,5 @@ declare function take<Item extends PlainObject>(array: Item[], callback: (item:
170
170
  * take([1, 2, 3, 4, 5], -2); // => [4, 5]
171
171
  * ```
172
172
  */
173
- declare function take(array: unknown[], count: number): unknown[];
174
- //#endregion
175
- export { drop, slice, take };
173
+ export declare function take(array: unknown[], count: number): unknown[];
174
+ //#endregion
@@ -3,7 +3,7 @@ import { PlainObject, Primitive } from "../models.mjs";
3
3
  /**
4
4
  * Sorting information for arrays _(using a comparison callback)_
5
5
  */
6
- type ArrayComparisonSorter<Item> = {
6
+ export type ArrayComparisonSorter<Item> = {
7
7
  /**
8
8
  * Callback to use when comparing items and values
9
9
  */
@@ -16,7 +16,7 @@ type ArrayComparisonSorter<Item> = {
16
16
  /**
17
17
  * Sorting information for arrays _(using a key)_
18
18
  */
19
- type ArrayKeySorter<Item extends PlainObject, ItemKey extends keyof Item> = {
19
+ export type ArrayKeySorter<Item extends PlainObject, ItemKey extends keyof Item> = {
20
20
  /**
21
21
  * Comparator to use when comparing items and values
22
22
  */
@@ -37,15 +37,15 @@ type ArrayKeySorters<Item extends PlainObject> = { [ItemKey in keyof Item]: Arra
37
37
  /**
38
38
  * Sorter to use for sorting
39
39
  */
40
- type ArraySorter<Item> = Item extends PlainObject ? keyof Item | ArrayComparisonSorter<Item> | ArrayKeySorters<Item> | ArrayValueSorter<Item> | ComparisonSorter<Item> : ArrayComparisonSorter<Item> | ArrayValueSorter<Item> | ComparisonSorter<Item>;
40
+ export type ArraySorter<Item> = Item extends PlainObject ? keyof Item | ArrayComparisonSorter<Item> | ArrayKeySorters<Item> | ArrayValueSorter<Item> | ComparisonSorter<Item> : ArrayComparisonSorter<Item> | ArrayValueSorter<Item> | ComparisonSorter<Item>;
41
41
  /**
42
42
  * Sorters to use for sorting
43
43
  */
44
- type ArraySorters<Item> = Array<ArraySorter<Item>>;
44
+ export type ArraySorters<Item> = Array<ArraySorter<Item>>;
45
45
  /**
46
46
  * Sorting information for arrays _(using a value callback and built-in comparison)_
47
47
  */
48
- type ArrayValueSorter<Item> = {
48
+ export type ArrayValueSorter<Item> = {
49
49
  /**
50
50
  * Direction to sort by
51
51
  */
@@ -67,20 +67,13 @@ type ComparisonSorter<Item> = (first: Item, second: Item) => number;
67
67
  /**
68
68
  * Direction to sort by
69
69
  */
70
- type SortDirection = 'ascending' | 'descending';
70
+ export type SortDirection = 'ascending' | 'descending';
71
71
  /**
72
72
  * Sorter for an array with predefined sorters
73
73
  *
74
74
  * Can be used to sort an array, get the predicted index for an item, and check if an array is sorted
75
75
  */
76
- type Sorter<Item> = {
77
- /**
78
- * Sort an array of items
79
- *
80
- * @param array Array to sort
81
- * @returns Sorted array
82
- */
83
- (array: Item[]): Item[];
76
+ export type Sorter<Item> = {
84
77
  /**
85
78
  * Get the index for an item _(to be inserted into an array of items)_
86
79
  *
@@ -98,6 +91,13 @@ type Sorter<Item> = {
98
91
  * @returns `true` if sorted, otherwise `false`
99
92
  */
100
93
  is(array: Item[]): boolean;
94
+ /**
95
+ * Sort an array of items
96
+ *
97
+ * @param array Array to sort
98
+ * @returns Sorted array
99
+ */
100
+ sort(array: Item[]): Item[];
101
101
  };
102
102
  /**
103
103
  * Get the index for an item _(to be inserted into an array of items)_ based on sorters _(and an optional default direction)_
@@ -112,7 +112,7 @@ type Sorter<Item> = {
112
112
  * @param descending Sorted in descending order? _(defaults to `false`; overridden by individual sorters)_
113
113
  * @returns Index for item
114
114
  */
115
- declare function getSortedIndex<Item>(array: Item[], item: Item, sorters: Array<ArraySorter<Item>>, descending?: boolean): number;
115
+ export declare function getSortedIndex<Item>(array: Item[], item: Item, sorters: Array<ArraySorter<Item>>, descending?: boolean): number;
116
116
  /**
117
117
  * Get the index for an item _(to be inserted into an array of items)_ based on a sorter _(and an optional default direction)_
118
118
  *
@@ -126,7 +126,7 @@ declare function getSortedIndex<Item>(array: Item[], item: Item, sorters: Array<
126
126
  * @param descending Sorted in descending order? _(defaults to `false`; overridden by individual sorters)_
127
127
  * @returns Index for item
128
128
  */
129
- declare function getSortedIndex<Item>(array: Item[], item: Item, sorter: ArraySorter<Item>, descending?: boolean): number;
129
+ export declare function getSortedIndex<Item>(array: Item[], item: Item, sorter: ArraySorter<Item>, descending?: boolean): number;
130
130
  /**
131
131
  * Get the index for an item _(to be inserted into an array of items)_ based on an optional default direction_
132
132
  *
@@ -139,7 +139,7 @@ declare function getSortedIndex<Item>(array: Item[], item: Item, sorter: ArraySo
139
139
  * @param descending Sorted in descending order? _(defaults to `false`)_
140
140
  * @returns Index for item
141
141
  */
142
- declare function getSortedIndex<Item>(array: Item[], item: Item, descending?: boolean): number;
142
+ export declare function getSortedIndex<Item>(array: Item[], item: Item, descending?: boolean): number;
143
143
  /**
144
144
  * Initialize a sort handler with sorters _(and an optional default direction)_
145
145
  *
@@ -149,7 +149,7 @@ declare function getSortedIndex<Item>(array: Item[], item: Item, descending?: bo
149
149
  * @param descending Sort in descending order? _(defaults to `false`; overridden by individual sorters)_
150
150
  * @returns Sort handler
151
151
  */
152
- declare function initializeSorter<Item>(sorters: Array<ArraySorter<Item>>, descending?: boolean): Sorter<Item>;
152
+ export declare function initializeSorter<Item>(sorters: Array<ArraySorter<Item>>, descending?: boolean): Sorter<Item>;
153
153
  /**
154
154
  * Initialize a sort handler with a sorter _(and an optional default direction)_
155
155
  *
@@ -159,7 +159,7 @@ declare function initializeSorter<Item>(sorters: Array<ArraySorter<Item>>, desce
159
159
  * @param descending Sort in descending order? _(defaults to `false`; overridden by individual sorters)_
160
160
  * @returns Sort handler
161
161
  */
162
- declare function initializeSorter<Item>(sorter: ArraySorter<Item>, descending?: boolean): Sorter<Item>;
162
+ export declare function initializeSorter<Item>(sorter: ArraySorter<Item>, descending?: boolean): Sorter<Item>;
163
163
  /**
164
164
  * Initialize a sort handler _(with an optional default direction)_
165
165
  *
@@ -168,7 +168,7 @@ declare function initializeSorter<Item>(sorter: ArraySorter<Item>, descending?:
168
168
  * @param descending Sort in descending order? _(defaults to `false`)_
169
169
  * @returns Sort handler
170
170
  */
171
- declare function initializeSorter<Item>(descending?: boolean): Sorter<Item>;
171
+ export declare function initializeSorter<Item>(descending?: boolean): Sorter<Item>;
172
172
  /**
173
173
  * Is the array sorted according to the sorters _(and the optional default direction)_?
174
174
  *
@@ -179,7 +179,7 @@ declare function initializeSorter<Item>(descending?: boolean): Sorter<Item>;
179
179
  * @param descending Sorted in descending order? _(defaults to `false`; overridden by individual sorters)_
180
180
  * @returns `true` if sorted, otherwise `false`
181
181
  */
182
- declare function isSorted<Item>(array: Item[], sorters: Array<ArraySorter<Item>>, descending?: boolean): boolean;
182
+ export declare function isSorted<Item>(array: Item[], sorters: Array<ArraySorter<Item>>, descending?: boolean): boolean;
183
183
  /**
184
184
  * Is the array sorted according to the sorter _(and the optional default direction)_?
185
185
  *
@@ -190,7 +190,7 @@ declare function isSorted<Item>(array: Item[], sorters: Array<ArraySorter<Item>>
190
190
  * @param descending Sorted in descending order? _(defaults to `false`; overridden by individual sorters)_
191
191
  * @returns `true` if sorted, otherwise `false`
192
192
  */
193
- declare function isSorted<Item>(array: Item[], sorter: ArraySorter<Item>, descending?: boolean): boolean;
193
+ export declare function isSorted<Item>(array: Item[], sorter: ArraySorter<Item>, descending?: boolean): boolean;
194
194
  /**
195
195
  * Is the array sorted?
196
196
  *
@@ -200,7 +200,7 @@ declare function isSorted<Item>(array: Item[], sorter: ArraySorter<Item>, descen
200
200
  * @param descending Sorted in descending order? _(defaults to `false`)_
201
201
  * @returns `true` if sorted, otherwise `false`
202
202
  */
203
- declare function isSorted<Item>(array: Item[], descending?: boolean): boolean;
203
+ export declare function isSorted<Item>(array: Item[], descending?: boolean): boolean;
204
204
  /**
205
205
  * Sort an array of items using a comparison callback
206
206
  *
@@ -217,7 +217,7 @@ declare function isSorted<Item>(array: Item[], descending?: boolean): boolean;
217
217
  * ); // => [{id: 1}, {id: 2}, {id: 3}]
218
218
  * ```
219
219
  */
220
- declare function sort<Item>(array: Item[], comparator: (first: Item, second: Item) => number, descending?: boolean): Item[];
220
+ export declare function sort<Item>(array: Item[], comparator: (first: Item, second: Item) => number, descending?: boolean): Item[];
221
221
  /**
222
222
  * Sort an array of items, using multiple sorters to sort by specific values
223
223
  *
@@ -226,7 +226,7 @@ declare function sort<Item>(array: Item[], comparator: (first: Item, second: Ite
226
226
  * @param descending Sort in descending order? _(defaults to `false`; overridden by individual sorters)_
227
227
  * @returns Sorted array
228
228
  */
229
- declare function sort<Item>(array: Item[], sorters: Array<ArraySorter<Item>>, descending?: boolean): Item[];
229
+ export declare function sort<Item>(array: Item[], sorters: Array<ArraySorter<Item>>, descending?: boolean): Item[];
230
230
  /**
231
231
  * Sort an array of items, using a single sorter to sort by a specific value
232
232
  *
@@ -235,7 +235,7 @@ declare function sort<Item>(array: Item[], sorters: Array<ArraySorter<Item>>, de
235
235
  * @param descending Sort in descending order? _(defaults to `false`; overridden by individual sorters)_
236
236
  * @returns Sorted array
237
237
  */
238
- declare function sort<Item>(array: Item[], sorter: ArraySorter<Item>, descending?: boolean): Item[];
238
+ export declare function sort<Item>(array: Item[], sorter: ArraySorter<Item>, descending?: boolean): Item[];
239
239
  /**
240
240
  * Sort an array of items
241
241
  *
@@ -243,13 +243,12 @@ declare function sort<Item>(array: Item[], sorter: ArraySorter<Item>, descending
243
243
  * @param descending Sort in descending order? _(defaults to `false`)_
244
244
  * @returns Sorted array
245
245
  */
246
- declare function sort<Item>(array: Item[], descending?: boolean): Item[];
247
- declare namespace sort {
246
+ export declare function sort<Item>(array: Item[], descending?: boolean): Item[];
247
+ export declare namespace sort {
248
248
  var getIndex: typeof getSortedIndex;
249
249
  var initialize: typeof initializeSorter;
250
250
  var is: typeof isSorted;
251
251
  }
252
- declare const SORT_DIRECTION_ASCENDING: SortDirection;
253
- declare const SORT_DIRECTION_DESCENDING: SortDirection;
254
- //#endregion
255
- export { ArrayComparisonSorter, ArrayKeySorter, ArraySorter, ArraySorters, ArrayValueSorter, SORT_DIRECTION_ASCENDING, SORT_DIRECTION_DESCENDING, SortDirection, Sorter, getSortedIndex, initializeSorter, isSorted, sort };
252
+ export declare const SORT_DIRECTION_ASCENDING: SortDirection;
253
+ export declare const SORT_DIRECTION_DESCENDING: SortDirection;
254
+ //#endregion
@@ -1,10 +1,20 @@
1
1
  import { isPlainObject } from "../internal/is.mjs";
2
2
  import { compare } from "../internal/value/compare.mjs";
3
3
  //#region src/array/sort.ts
4
+ const SORTER_PROPERTY = "$sorter";
5
+ function Sorter(sorters) {
6
+ Object.defineProperty(this, SORTER_SYMBOL, { value: sorters });
7
+ }
8
+ Object.defineProperties(Sorter.prototype, {
9
+ [SORTER_PROPERTY]: { value: true },
10
+ index: { value: getSortedArrayIndex },
11
+ is: { value: isSortedArray },
12
+ sort: { value: sortArray }
13
+ });
4
14
  function getComparisonSorter(callback, modifier) {
5
15
  return {
6
16
  modifier,
7
- compare: { simple: callback },
17
+ comparison: { simple: callback },
8
18
  get: false,
9
19
  identifier: callback.toString()
10
20
  };
@@ -13,15 +23,29 @@ function getComparisonValue(first, second, sorters, length) {
13
23
  for (let index = 0; index < length; index += 1) {
14
24
  const sorter = sorters[index];
15
25
  const values = [sorter.get ? sorter.value(first) : first, sorter.get ? sorter.value(second) : second];
16
- const comparison = (sorter.compare?.complex?.(first, values[0], second, values[1]) ?? sorter.compare?.simple?.(values[0], values[1]) ?? compare(values[0], values[1])) * sorter.modifier;
26
+ const comparison = (sorter.comparison?.complex?.(first, values[0], second, values[1]) ?? sorter.comparison?.simple?.(values[0], values[1]) ?? compare(values[0], values[1])) * sorter.modifier;
17
27
  if (comparison !== 0) return comparison;
18
28
  }
19
29
  return 0;
20
30
  }
21
- function getIndex(array, item, sorters) {
31
+ function getModifier(first, second) {
32
+ return modifiers[first === true || second === true ? SORT_DIRECTION_DESCENDING : SORT_DIRECTION_ASCENDING];
33
+ }
34
+ function getObjectSorter(obj, modifier) {
35
+ let sorter;
36
+ if (typeof obj.comparison === "function") sorter = getComparisonSorter(obj.comparison, modifier);
37
+ else if (typeof obj.key === "string") {
38
+ sorter = getValueSortHandlers(obj.key, modifier);
39
+ if (typeof obj.compare === "function") sorter.comparison = { complex: obj.compare };
40
+ } else if (typeof obj.value === "function") sorter = getValueSortHandlers(obj.value, modifier);
41
+ if (sorter != null && typeof obj.direction === "string") sorter.modifier = modifiers[obj.direction] ?? modifier;
42
+ return sorter;
43
+ }
44
+ function getSortedArrayIndex(array, item) {
22
45
  if (!Array.isArray(array)) return -1;
23
46
  const { length } = array;
24
47
  if (length === 0) return 0;
48
+ const sorters = Array.isArray(this) ? this : this[SORTER_SYMBOL];
25
49
  const sortersLength = sorters.length;
26
50
  if (getComparisonValue(item, array[0], sorters, sortersLength) < 0) return 0;
27
51
  if (getComparisonValue(item, array[length - 1], sorters, sortersLength) >= 0) return length;
@@ -34,36 +58,23 @@ function getIndex(array, item, sorters) {
34
58
  }
35
59
  return low;
36
60
  }
37
- function getModifier(first, second) {
38
- return modifiers[first === true || second === true ? SORT_DIRECTION_DESCENDING : SORT_DIRECTION_ASCENDING];
39
- }
40
- function getObjectSorter(obj, modifier) {
41
- let sorter;
42
- if (typeof obj.comparison === "function") sorter = getComparisonSorter(obj.comparison, modifier);
43
- else if (typeof obj.key === "string") {
44
- sorter = getValueSorter(obj.key, modifier);
45
- if (typeof obj.compare === "function") sorter.compare = { complex: obj.compare };
46
- } else if (typeof obj.value === "function") sorter = getValueSorter(obj.value, modifier);
47
- if (sorter != null && typeof obj.direction === "string") sorter.modifier = modifiers[obj.direction] ?? modifier;
48
- return sorter;
49
- }
50
61
  function getSortedIndex(array, item, first, second) {
51
- return getIndex(array, item, getSorters(first, getModifier(first, second)));
62
+ return getSortedArrayIndex.call(getSortHandlers(first, getModifier(first, second)), array, item);
52
63
  }
53
- function getSorter(value, modifier) {
64
+ function getSortHandler(value, modifier) {
54
65
  switch (true) {
55
66
  case typeof value === "function": return getComparisonSorter(value, modifier);
56
- case typeof value === "string": return getValueSorter(value, modifier);
67
+ case typeof value === "string": return getValueSortHandlers(value, modifier);
57
68
  case isPlainObject(value): return getObjectSorter(value, modifier);
58
69
  }
59
70
  }
60
- function getSorters(value, modifier) {
71
+ function getSortHandlers(value, modifier) {
61
72
  const array = Array.isArray(value) ? value : [value];
62
73
  const { length } = array;
63
74
  const sorters = [];
64
75
  for (let index = 0; index < length; index += 1) {
65
76
  const item = array[index];
66
- const sorter = getSorter(item, modifier);
77
+ const sorter = getSortHandler(item, modifier);
67
78
  if (sorter != null) sorters.push(sorter);
68
79
  }
69
80
  if (sorters.length === 0) return [{
@@ -73,7 +84,7 @@ function getSorters(value, modifier) {
73
84
  }];
74
85
  return sorters.filter((value, index, array) => array.findIndex((next) => next.identifier === value.identifier) === index);
75
86
  }
76
- function getValueSorter(value, modifier) {
87
+ function getValueSortHandlers(value, modifier) {
77
88
  const isFunction = typeof value === "function";
78
89
  return {
79
90
  modifier,
@@ -83,21 +94,16 @@ function getValueSorter(value, modifier) {
83
94
  };
84
95
  }
85
96
  function initializeSorter(first, second) {
86
- const sorters = getSorters(first, getModifier(first, second));
87
- const sorter = (array) => sortArray(array, sorters);
88
- Object.defineProperties(sorter, {
89
- index: { value: (array, item) => getIndex(array, item, sorters) },
90
- is: { value: (array) => isSortedArray(array, sorters) }
91
- });
92
- return sorter;
97
+ return new Sorter(getSortHandlers(first, getModifier(first, second)));
93
98
  }
94
99
  function isSorted(array, first, second) {
95
- return isSortedArray(array, getSorters(first, getModifier(first, second)));
100
+ return isSortedArray.call(getSortHandlers(first, getModifier(first, second)), array);
96
101
  }
97
- function isSortedArray(array, sorters) {
102
+ function isSortedArray(array) {
98
103
  if (!Array.isArray(array)) return false;
99
104
  const { length } = array;
100
105
  if (length < 2) return true;
106
+ const sorters = Array.isArray(this) ? this : this[SORTER_SYMBOL];
101
107
  const sortersLength = sorters.length;
102
108
  let offset = 0;
103
109
  if (length >= SORT_THRESHOLD) {
@@ -119,10 +125,11 @@ function isSortedArray(array, sorters) {
119
125
  return true;
120
126
  }
121
127
  function sort(array, first, second) {
122
- return sortArray(array, getSorters(first, getModifier(first, second)));
128
+ return sortArray.call(getSortHandlers(first, getModifier(first, second)), array);
123
129
  }
124
- function sortArray(array, sorters) {
130
+ function sortArray(array) {
125
131
  if (!Array.isArray(array)) return [];
132
+ const sorters = Array.isArray(this) ? this : this[SORTER_SYMBOL];
126
133
  const { length } = sorters;
127
134
  return array.length > 1 ? array.sort((first, second) => getComparisonValue(first, second, sorters, length)) : array;
128
135
  }
@@ -130,6 +137,7 @@ const SORT_PEEK_PERCENTAGE = 10;
130
137
  const SORT_THRESHOLD = 100;
131
138
  const SORT_DIRECTION_ASCENDING = "ascending";
132
139
  const SORT_DIRECTION_DESCENDING = "descending";
140
+ const SORTER_SYMBOL = Symbol(SORTER_PROPERTY);
133
141
  const modifiers = {
134
142
  [SORT_DIRECTION_ASCENDING]: 1,
135
143
  [SORT_DIRECTION_DESCENDING]: -1
@@ -20,7 +20,7 @@
20
20
  * ); // => [3, 4], array becomes [1, 2, 6, 7, 5]
21
21
  * ```
22
22
  */
23
- declare function splice<Item>(array: Item[], start: number, amount: number, added: Item[]): Item[];
23
+ export declare function splice<Item>(array: Item[], start: number, amount: number, added: Item[]): Item[];
24
24
  /**
25
25
  * Adds items into an array at a specific index
26
26
  *
@@ -40,7 +40,7 @@ declare function splice<Item>(array: Item[], start: number, amount: number, adde
40
40
  * ); // => [], array becomes [1, 2, 6, 7, 3, 4, 5]
41
41
  * ```
42
42
  */
43
- declare function splice<Item>(array: Item[], start: number, added: Item[]): Item[];
43
+ export declare function splice<Item>(array: Item[], start: number, added: Item[]): Item[];
44
44
  /**
45
45
  * Removes and returns _(up to)_ a specific amount of items from an array, starting from a specific index
46
46
  *
@@ -60,7 +60,7 @@ declare function splice<Item>(array: Item[], start: number, added: Item[]): Item
60
60
  * ); // => [3, 4], array becomes [1, 2, 5]
61
61
  * ```
62
62
  */
63
- declare function splice<Item>(array: Item[], start: number, amount: number): Item[];
63
+ export declare function splice<Item>(array: Item[], start: number, amount: number): Item[];
64
64
  /**
65
65
  * Removes and returns all items from an array starting from a specific index
66
66
  *
@@ -78,6 +78,5 @@ declare function splice<Item>(array: Item[], start: number, amount: number): Ite
78
78
  * ); // => [3, 4, 5], array becomes [1, 2]
79
79
  * ```
80
80
  */
81
- declare function splice<Item>(array: Item[], start: number): Item[];
82
- //#endregion
83
- export { splice };
81
+ export declare function splice<Item>(array: Item[], start: number): Item[];
82
+ //#endregion
@@ -33,7 +33,7 @@ import { PlainObject } from "../models.mjs";
33
33
  * // ]
34
34
  * ```
35
35
  */
36
- declare function swap<Item>(array: Item[], first: Item[], second: Item[], callback: (item: Item, index: number, array: Item[]) => unknown): Item[];
36
+ export declare function swap<Item>(array: Item[], first: Item[], second: Item[], callback: (item: Item, index: number, array: Item[]) => unknown): Item[];
37
37
  /**
38
38
  * Swap two smaller arrays within a larger array
39
39
  *
@@ -67,7 +67,7 @@ declare function swap<Item>(array: Item[], first: Item[], second: Item[], callba
67
67
  * // ]
68
68
  * ```
69
69
  */
70
- declare function swap<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], first: Item[], second: Item[], key: ItemKey): Item[];
70
+ export declare function swap<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], first: Item[], second: Item[], key: ItemKey): Item[];
71
71
  /**
72
72
  * Swap two smaller arrays within a larger array
73
73
  *
@@ -87,7 +87,7 @@ declare function swap<Item extends PlainObject, ItemKey extends keyof Item>(arra
87
87
  * ); // => [5, 6, 3, 4, 1, 2]
88
88
  * ```
89
89
  */
90
- declare function swap<Item>(array: Item[], first: Item[], second: Item[]): Item[];
90
+ export declare function swap<Item>(array: Item[], first: Item[], second: Item[]): Item[];
91
91
  /**
92
92
  * Swap two indiced items in an array
93
93
  *
@@ -117,7 +117,7 @@ declare function swap<Item>(array: Item[], first: Item[], second: Item[]): Item[
117
117
  * // ]
118
118
  * ```
119
119
  */
120
- declare function swap<Item>(array: Item[], first: Item, second: Item, callback: (item: Item, index: number, array: Item[]) => unknown): Item[];
120
+ export declare function swap<Item>(array: Item[], first: Item, second: Item, callback: (item: Item, index: number, array: Item[]) => unknown): Item[];
121
121
  /**
122
122
  * Swap two indiced items in an array
123
123
  *
@@ -147,7 +147,7 @@ declare function swap<Item>(array: Item[], first: Item, second: Item, callback:
147
147
  * // ]
148
148
  * ```
149
149
  */
150
- declare function swap<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], first: Item, second: Item, key: ItemKey): Item[];
150
+ export declare function swap<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], first: Item, second: Item, key: ItemKey): Item[];
151
151
  /**
152
152
  * Swap two indiced items in an array
153
153
  *
@@ -165,8 +165,8 @@ declare function swap<Item extends PlainObject, ItemKey extends keyof Item>(arra
165
165
  * ); // => [1, 5, 3, 4, 2, 6]
166
166
  * ```
167
167
  */
168
- declare function swap<Item>(array: Item[], first: Item, second: Item): Item[];
169
- declare namespace swap {
168
+ export declare function swap<Item>(array: Item[], first: Item, second: Item): Item[];
169
+ export declare namespace swap {
170
170
  var indices: typeof swapIndices;
171
171
  }
172
172
  /**
@@ -182,5 +182,4 @@ declare namespace swap {
182
182
  * @returns Original array with items swapped _(or unchanged if unable to swap)_
183
183
  */
184
184
  declare function swapIndices<Item>(array: Item[], first: number, second: number): Item[];
185
- //#endregion
186
- export { swap };
185
+ //#endregion