@oscarpalmer/atoms 0.162.0 → 0.164.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.
- package/{types/array/difference.d.ts → dist/array/difference.d.mts} +8 -4
- package/dist/array/{difference.js → difference.mjs} +1 -1
- package/{types/array/exists.d.ts → dist/array/exists.d.mts} +9 -5
- package/dist/array/{exists.js → exists.mjs} +1 -1
- package/{types/array/filter.d.ts → dist/array/filter.d.mts} +11 -8
- package/dist/array/{filter.js → filter.mjs} +1 -1
- package/{types/array/find.d.ts → dist/array/find.d.mts} +9 -5
- package/dist/array/{find.js → find.mjs} +1 -1
- package/dist/array/flatten.d.mts +11 -0
- package/{types/array/from.d.ts → dist/array/from.d.mts} +9 -6
- package/{types/array/get.d.ts → dist/array/get.d.mts} +10 -6
- package/dist/array/{get.js → get.mjs} +1 -1
- package/{types/array/group-by.d.ts → dist/array/group-by.d.mts} +14 -11
- package/dist/array/{group-by.js → group-by.mjs} +1 -1
- package/dist/array/index.d.mts +27 -0
- package/dist/array/index.mjs +27 -0
- package/{types/array/insert.d.ts → dist/array/insert.d.mts} +5 -2
- package/dist/array/{insert.js → insert.mjs} +1 -1
- package/{types/array/intersection.d.ts → dist/array/intersection.d.mts} +6 -3
- package/dist/array/{intersection.js → intersection.mjs} +1 -1
- package/{types/array/move.d.ts → dist/array/move.d.mts} +11 -8
- package/dist/array/{move.js → move.mjs} +2 -2
- package/{types/array/partition.d.ts → dist/array/partition.d.mts} +9 -5
- package/dist/array/{partition.js → partition.mjs} +1 -1
- package/{types/array/position.d.ts → dist/array/position.d.mts} +21 -17
- package/dist/array/{position.js → position.mjs} +12 -12
- package/{types/array/push.d.ts → dist/array/push.d.mts} +4 -1
- package/dist/array/{push.js → push.mjs} +1 -1
- package/dist/array/select.d.mts +47 -0
- package/dist/array/{select.js → select.mjs} +1 -1
- package/{types/array/slice.d.ts → dist/array/slice.d.mts} +16 -12
- package/dist/array/{slice.js → slice.mjs} +3 -3
- package/{types/array/sort.d.ts → dist/array/sort.d.mts} +41 -37
- package/dist/array/{sort.js → sort.mjs} +4 -4
- package/{types/array/splice.d.ts → dist/array/splice.d.mts} +7 -4
- package/dist/array/{splice.js → splice.mjs} +1 -1
- package/{types/array/swap.d.ts → dist/array/swap.d.mts} +13 -10
- package/dist/array/{swap.js → swap.mjs} +4 -4
- package/{types/array/to-map.d.ts → dist/array/to-map.d.mts} +14 -11
- package/dist/array/{to-map.js → to-map.mjs} +1 -1
- package/{types/array/to-record.d.ts → dist/array/to-record.d.mts} +14 -11
- package/dist/array/{to-record.js → to-record.mjs} +1 -1
- package/dist/array/to-set.d.mts +25 -0
- package/dist/array/{to-set.js → to-set.mjs} +1 -1
- package/{types/array/toggle.d.ts → dist/array/toggle.d.mts} +8 -4
- package/dist/array/{toggle.js → toggle.mjs} +1 -1
- package/{types/array/union.d.ts → dist/array/union.d.mts} +6 -3
- package/dist/array/{union.js → union.mjs} +1 -1
- package/{types/array/unique.d.ts → dist/array/unique.d.mts} +8 -4
- package/dist/array/{unique.js → unique.mjs} +1 -1
- package/{types/array/update.d.ts → dist/array/update.d.mts} +8 -4
- package/dist/array/{update.js → update.mjs} +1 -1
- package/dist/beacon.d.mts +116 -0
- package/dist/{beacon.js → beacon.mjs} +6 -6
- package/dist/color/constants.d.mts +38 -0
- package/dist/color/constants.mjs +55 -0
- package/dist/color/index.d.mts +17 -0
- package/dist/color/{index.js → index.mjs} +6 -6
- package/dist/color/instance.d.mts +70 -0
- package/dist/color/{instance.js → instance.mjs} +4 -4
- package/dist/color/misc/alpha.d.mts +8 -0
- package/dist/color/misc/{alpha.js → alpha.mjs} +1 -1
- package/dist/color/misc/get.d.mts +51 -0
- package/dist/color/misc/{get.js → get.mjs} +4 -4
- package/dist/color/misc/index.d.mts +7 -0
- package/dist/color/misc/{index.js → index.mjs} +4 -4
- package/{types/color/misc/is.d.ts → dist/color/misc/is.d.mts} +14 -10
- package/dist/color/misc/{is.js → is.mjs} +3 -3
- package/dist/color/misc/state.d.mts +9 -0
- package/dist/color/misc/{state.js → state.mjs} +7 -7
- package/dist/color/models.d.mts +30 -0
- package/dist/color/models.mjs +1 -0
- package/dist/color/space/hex.d.mts +26 -0
- package/dist/color/space/{hex.js → hex.mjs} +4 -4
- package/dist/color/space/hsl.d.mts +23 -0
- package/dist/color/space/{hsl.js → hsl.mjs} +5 -5
- package/dist/color/space/rgb.d.mts +31 -0
- package/dist/color/space/{rgb.js → rgb.mjs} +5 -5
- package/{types/function/assert.d.ts → dist/function/assert.d.mts} +12 -9
- package/dist/function/{assert.js → assert.mjs} +1 -1
- package/{types/function/index.d.ts → dist/function/index.d.mts} +10 -6
- package/dist/function/{index.js → index.mjs} +4 -4
- package/dist/function/memoize.d.mts +73 -0
- package/dist/function/{memoize.js → memoize.mjs} +5 -5
- package/{types/function/once.d.ts → dist/function/once.d.mts} +8 -5
- package/dist/function/{once.js → once.mjs} +3 -3
- package/{types/function/retry.d.ts → dist/function/retry.d.mts} +15 -12
- package/dist/function/{retry.js → retry.mjs} +5 -5
- package/{types/function/work.d.ts → dist/function/work.d.mts} +36 -33
- package/dist/function/{work.js → work.mjs} +9 -9
- package/dist/index.d.mts +4253 -0
- package/dist/{atoms.full.js → index.mjs} +223 -20
- package/dist/internal/array/callbacks.d.mts +12 -0
- package/{types/internal/array/chunk.d.ts → dist/internal/array/chunk.d.mts} +4 -1
- package/dist/internal/array/{chunk.js → chunk.mjs} +1 -1
- package/{types/internal/array/compact.d.ts → dist/internal/array/compact.d.mts} +5 -2
- package/dist/internal/array/find.d.mts +15 -0
- package/dist/internal/array/{find.js → find.mjs} +6 -6
- package/dist/internal/array/group.d.mts +6 -0
- package/dist/internal/array/{group.js → group.mjs} +1 -1
- package/{types/internal/array/index-of.d.ts → dist/internal/array/index-of.d.mts} +9 -5
- package/dist/internal/array/{index-of.js → index-of.mjs} +1 -1
- package/dist/internal/array/insert.d.mts +8 -0
- package/dist/internal/array/{insert.js → insert.mjs} +4 -4
- package/dist/internal/array/overlap.d.mts +13 -0
- package/dist/internal/array/sets.d.mts +8 -0
- package/dist/internal/array/{sets.js → sets.mjs} +4 -4
- package/dist/internal/array/shuffle.d.mts +9 -0
- package/dist/internal/array/{shuffle.js → shuffle.mjs} +1 -1
- package/dist/internal/array/update.d.mts +4 -0
- package/dist/internal/array/{update.js → update.mjs} +1 -1
- package/dist/internal/function/misc.d.mts +7 -0
- package/dist/internal/function/timer.d.mts +10 -0
- package/dist/internal/function/{timer.js → timer.mjs} +4 -4
- package/{types/internal/is.d.ts → dist/internal/is.d.mts} +12 -8
- package/dist/internal/{is.js → is.mjs} +1 -1
- package/dist/internal/math/aggregate.d.mts +38 -0
- package/dist/internal/math/{aggregate.js → aggregate.mjs} +6 -6
- package/{types/internal/number.d.ts → dist/internal/number.d.mts} +6 -3
- package/dist/internal/{number.js → number.mjs} +7 -7
- package/{types/internal/random.d.ts → dist/internal/random.d.mts} +5 -2
- package/dist/internal/{random.js → random.mjs} +1 -1
- package/{types/internal/result.d.ts → dist/internal/result.d.mts} +11 -7
- package/dist/internal/{result.js → result.mjs} +3 -3
- package/dist/internal/sized.d.mts +4 -0
- package/dist/internal/{sized.js → sized.mjs} +3 -3
- package/dist/internal/string.d.mts +25 -0
- package/dist/internal/{string.js → string.mjs} +3 -3
- package/{types/internal/value/compare.d.ts → dist/internal/value/compare.d.mts} +14 -11
- package/dist/internal/value/{compare.js → compare.mjs} +5 -5
- package/dist/internal/value/equal.d.mts +85 -0
- package/dist/internal/value/{equal.js → equal.mjs} +7 -7
- package/{types/internal/value/get.d.ts → dist/internal/value/get.d.mts} +7 -3
- package/dist/internal/value/{get.js → get.mjs} +1 -1
- package/dist/internal/value/handlers.d.mts +19 -0
- package/dist/internal/value/{handlers.js → handlers.mjs} +1 -1
- package/{types/internal/value/has.d.ts → dist/internal/value/has.d.mts} +12 -9
- package/dist/internal/value/{has.js → has.mjs} +1 -1
- package/dist/internal/value/misc.d.mts +14 -0
- package/dist/internal/value/{misc.js → misc.mjs} +4 -4
- package/dist/internal/value/partial.d.mts +5 -0
- package/{types/internal/value/set.d.ts → dist/internal/value/set.d.mts} +8 -4
- package/dist/internal/value/{set.js → set.mjs} +2 -2
- package/{types/is.d.ts → dist/is.d.mts} +14 -10
- package/dist/{is.js → is.mjs} +5 -5
- package/dist/logger.d.mts +67 -0
- package/dist/{logger.js → logger.mjs} +3 -3
- package/{types/math.d.ts → dist/math.d.mts} +24 -20
- package/dist/{math.js → math.mjs} +2 -2
- package/dist/models.d.mts +138 -0
- package/dist/models.mjs +1 -0
- package/dist/number.d.mts +2 -0
- package/dist/number.mjs +2 -0
- package/{types/promise/delay.d.ts → dist/promise/delay.d.mts} +7 -3
- package/dist/promise/{delay.js → delay.mjs} +4 -4
- package/dist/promise/helpers.d.mts +23 -0
- package/dist/promise/{helpers.js → helpers.mjs} +3 -3
- package/{types/promise/index.d.ts → dist/promise/index.d.mts} +22 -19
- package/dist/promise/{index.js → index.mjs} +9 -9
- package/dist/promise/misc.d.mts +26 -0
- package/dist/promise/{misc.js → misc.mjs} +2 -2
- package/dist/promise/models.d.mts +84 -0
- package/dist/promise/models.mjs +38 -0
- package/dist/promise/timed.d.mts +21 -0
- package/dist/promise/{timed.js → timed.mjs} +5 -4
- package/{types/query.d.ts → dist/query.d.mts} +7 -3
- package/dist/{query.js → query.mjs} +8 -8
- package/dist/queue.d.mts +103 -0
- package/dist/{queue.js → queue.mjs} +18 -17
- package/{types/random.d.ts → dist/random.d.mts} +12 -8
- package/dist/{random.js → random.mjs} +7 -7
- package/{types/result/index.d.ts → dist/result/index.d.mts} +20 -17
- package/dist/result/{index.js → index.mjs} +7 -7
- package/{types/result/match.d.ts → dist/result/match.d.mts} +9 -6
- package/dist/result/{match.js → match.mjs} +2 -2
- package/{types/result/misc.d.ts → dist/result/misc.d.mts} +13 -9
- package/dist/result/{misc.js → misc.mjs} +2 -2
- package/dist/result/models.d.mts +63 -0
- package/dist/result/models.mjs +1 -0
- package/{types/result/work/flow.d.ts → dist/result/work/flow.d.mts} +22 -19
- package/dist/result/work/{flow.js → flow.mjs} +3 -3
- package/{types/result/work/pipe.d.ts → dist/result/work/pipe.d.mts} +30 -27
- package/dist/result/work/{pipe.js → pipe.mjs} +3 -3
- package/dist/sized/map.d.mts +46 -0
- package/dist/sized/{map.js → map.mjs} +1 -1
- package/dist/sized/set.d.mts +45 -0
- package/dist/sized/{set.js → set.mjs} +1 -1
- package/{types/string/case.d.ts → dist/string/case.d.mts} +11 -8
- package/dist/string/{case.js → case.mjs} +17 -17
- package/{types/string/index.d.ts → dist/string/index.d.mts} +9 -5
- package/dist/string/{index.js → index.mjs} +2 -2
- package/{types/string/match.d.ts → dist/string/match.d.mts} +6 -3
- package/dist/string/{match.js → match.mjs} +5 -5
- package/{types/string/template.d.ts → dist/string/template.d.mts} +17 -14
- package/dist/string/{template.js → template.mjs} +4 -4
- package/{types/value/clone.d.ts → dist/value/clone.d.mts} +14 -11
- package/dist/value/{clone.js → clone.mjs} +4 -4
- package/dist/value/diff.d.mts +53 -0
- package/dist/value/{diff.js → diff.mjs} +6 -6
- package/dist/value/handle.d.mts +4 -0
- package/dist/value/handle.mjs +4 -0
- package/dist/value/index.d.mts +5 -0
- package/dist/value/index.mjs +5 -0
- package/dist/value/merge.d.mts +54 -0
- package/dist/value/{merge.js → merge.mjs} +2 -2
- package/dist/value/omit.d.mts +12 -0
- package/dist/value/{omit.js → omit.mjs} +1 -1
- package/dist/value/pick.d.mts +12 -0
- package/dist/value/{pick.js → pick.mjs} +1 -1
- package/dist/value/smush.d.mts +12 -0
- package/dist/value/{smush.js → smush.mjs} +3 -3
- package/dist/value/unsmush.d.mts +20 -0
- package/dist/value/{unsmush.js → unsmush.mjs} +2 -2
- package/package.json +103 -105
- package/src/models.ts +2 -2
- package/src/promise/index.ts +14 -7
- package/src/promise/models.ts +26 -5
- package/src/promise/timed.ts +2 -0
- package/src/queue.ts +23 -13
- package/dist/array/index.js +0 -27
- package/dist/color/constants.js +0 -55
- package/dist/color/models.js +0 -0
- package/dist/index.js +0 -83
- package/dist/models.js +0 -0
- package/dist/number.js +0 -2
- package/dist/promise/models.js +0 -39
- package/dist/result/models.js +0 -0
- package/dist/value/handle.js +0 -4
- package/dist/value/index.js +0 -5
- package/types/array/flatten.d.ts +0 -7
- package/types/array/index.d.ts +0 -26
- package/types/array/select.d.ts +0 -43
- package/types/array/to-set.d.ts +0 -21
- package/types/beacon.d.ts +0 -114
- package/types/color/constants.d.ts +0 -34
- package/types/color/index.d.ts +0 -14
- package/types/color/instance.d.ts +0 -66
- package/types/color/misc/alpha.d.ts +0 -4
- package/types/color/misc/get.d.ts +0 -47
- package/types/color/misc/index.d.ts +0 -3
- package/types/color/misc/state.d.ts +0 -5
- package/types/color/models.d.ts +0 -28
- package/types/color/space/hex.d.ts +0 -22
- package/types/color/space/hsl.d.ts +0 -19
- package/types/color/space/rgb.d.ts +0 -27
- package/types/function/memoize.d.ts +0 -70
- package/types/index.d.ts +0 -37
- package/types/internal/array/callbacks.d.ts +0 -8
- package/types/internal/array/find.d.ts +0 -13
- package/types/internal/array/group.d.ts +0 -2
- package/types/internal/array/insert.d.ts +0 -6
- package/types/internal/array/overlap.d.ts +0 -11
- package/types/internal/array/sets.d.ts +0 -6
- package/types/internal/array/shuffle.d.ts +0 -6
- package/types/internal/array/update.d.ts +0 -1
- package/types/internal/function/misc.d.ts +0 -4
- package/types/internal/function/timer.d.ts +0 -7
- package/types/internal/math/aggregate.d.ts +0 -35
- package/types/internal/sized.d.ts +0 -1
- package/types/internal/string.d.ts +0 -22
- package/types/internal/value/equal.d.ts +0 -82
- package/types/internal/value/handlers.d.ts +0 -16
- package/types/internal/value/misc.d.ts +0 -11
- package/types/internal/value/partial.d.ts +0 -2
- package/types/logger.d.ts +0 -65
- package/types/models.d.ts +0 -150
- package/types/number.d.ts +0 -1
- package/types/promise/helpers.d.ts +0 -19
- package/types/promise/misc.d.ts +0 -22
- package/types/promise/models.d.ts +0 -85
- package/types/promise/timed.d.ts +0 -17
- package/types/queue.d.ts +0 -100
- package/types/result/models.d.ts +0 -60
- package/types/sized/map.d.ts +0 -43
- package/types/sized/set.d.ts +0 -42
- package/types/value/diff.d.ts +0 -51
- package/types/value/handle.d.ts +0 -3
- package/types/value/index.d.ts +0 -4
- package/types/value/merge.d.ts +0 -51
- package/types/value/omit.d.ts +0 -8
- package/types/value/pick.d.ts +0 -8
- package/types/value/smush.d.ts +0 -10
- package/types/value/unsmush.d.ts +0 -19
- /package/dist/array/{flatten.js → flatten.mjs} +0 -0
- /package/dist/array/{from.js → from.mjs} +0 -0
- /package/dist/internal/array/{callbacks.js → callbacks.mjs} +0 -0
- /package/dist/internal/array/{compact.js → compact.mjs} +0 -0
- /package/dist/internal/array/{overlap.js → overlap.mjs} +0 -0
- /package/dist/internal/function/{misc.js → misc.mjs} +0 -0
- /package/dist/internal/value/{partial.js → partial.mjs} +0 -0
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { PlainObject } from "../models.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/array/difference.d.ts
|
|
2
4
|
/**
|
|
3
5
|
* Get the items from the first array that are not in the second array
|
|
4
6
|
* @param first First array
|
|
@@ -6,7 +8,7 @@ import type { PlainObject } from '../models';
|
|
|
6
8
|
* @param callback Callback to get an item's value for comparison
|
|
7
9
|
* @returns Unique values from the first array
|
|
8
10
|
*/
|
|
9
|
-
|
|
11
|
+
declare function difference<First, Second>(first: First[], second: Second[], callback: (item: First | Second) => unknown): First[];
|
|
10
12
|
/**
|
|
11
13
|
* Get the items from the first array that are not in the second array
|
|
12
14
|
* @param first First array
|
|
@@ -14,11 +16,13 @@ export declare function difference<First, Second>(first: First[], second: Second
|
|
|
14
16
|
* @param key Key to get an item's value for comparison
|
|
15
17
|
* @returns Unique values from the first array
|
|
16
18
|
*/
|
|
17
|
-
|
|
19
|
+
declare function difference<First extends PlainObject, Second extends PlainObject, Key extends keyof First & keyof Second>(first: First[], second: Second[], key: Key): First[];
|
|
18
20
|
/**
|
|
19
21
|
* Get the items from the first array that are not in the second array
|
|
20
22
|
* @param first First array
|
|
21
23
|
* @param second Second array
|
|
22
24
|
* @returns Unique values from the first array
|
|
23
25
|
*/
|
|
24
|
-
|
|
26
|
+
declare function difference<First, Second>(first: First[], second: Second[]): First[];
|
|
27
|
+
//#endregion
|
|
28
|
+
export { difference };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { COMPARE_SETS_DIFFERENCE, compareSets } from "../internal/array/sets.
|
|
1
|
+
import { COMPARE_SETS_DIFFERENCE, compareSets } from "../internal/array/sets.mjs";
|
|
2
2
|
//#region src/array/difference.ts
|
|
3
3
|
function difference(first, second, key) {
|
|
4
4
|
return compareSets(COMPARE_SETS_DIFFERENCE, first, second, key);
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { PlainObject } from "../models.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/array/exists.d.ts
|
|
2
4
|
/**
|
|
3
5
|
* Does an item with a specific value exist in the array?
|
|
4
6
|
* @param array Array to search in
|
|
@@ -6,7 +8,7 @@ import type { PlainObject } from '../models';
|
|
|
6
8
|
* @param value Value to match against
|
|
7
9
|
* @returns `true` if the item exists in the array, otherwise `false`
|
|
8
10
|
*/
|
|
9
|
-
|
|
11
|
+
declare function exists<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): boolean;
|
|
10
12
|
/**
|
|
11
13
|
* Does an item with a specific value exist in the array?
|
|
12
14
|
* @param array Array to search in
|
|
@@ -14,18 +16,20 @@ export declare function exists<Item, Callback extends (item: Item, index: number
|
|
|
14
16
|
* @param value Value to match against
|
|
15
17
|
* @returns `true` if the item exists in the array, otherwise `false`
|
|
16
18
|
*/
|
|
17
|
-
|
|
19
|
+
declare function exists<Item extends PlainObject, Key extends keyof Item>(array: Item[], key: Key, value: Item[Key]): boolean;
|
|
18
20
|
/**
|
|
19
21
|
* Does an item in the array match the filter?
|
|
20
22
|
* @param array Array to search in
|
|
21
23
|
* @param filter Filter callback to match items
|
|
22
24
|
* @returns `true` if a matching item exists, otherwise `false`
|
|
23
25
|
*/
|
|
24
|
-
|
|
26
|
+
declare function exists<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): boolean;
|
|
25
27
|
/**
|
|
26
28
|
* Does the item exist in the array?
|
|
27
29
|
* @param array Array to search in
|
|
28
30
|
* @param item Item to search for
|
|
29
31
|
* @returns `true` if the item exists in the array, otherwise `false`
|
|
30
32
|
*/
|
|
31
|
-
|
|
33
|
+
declare function exists<Item>(array: Item[], item: Item): boolean;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { exists };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FIND_VALUE_INDEX, findValue } from "../internal/array/find.
|
|
1
|
+
import { FIND_VALUE_INDEX, findValue } from "../internal/array/find.mjs";
|
|
2
2
|
//#region src/array/exists.ts
|
|
3
3
|
function exists(array, ...parameters) {
|
|
4
4
|
if (parameters.length === 1 && typeof parameters[0] !== "function") return Array.isArray(array) ? array.includes(parameters[0]) : false;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { PlainObject } from "../models.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/array/filter.d.ts
|
|
2
4
|
/**
|
|
3
5
|
* Get a filtered array of items
|
|
4
6
|
* @param array Array to search in
|
|
@@ -6,7 +8,7 @@ import type { PlainObject } from '../models';
|
|
|
6
8
|
* @param value Value to match against
|
|
7
9
|
* @returns Filtered array of items
|
|
8
10
|
*/
|
|
9
|
-
|
|
11
|
+
declare function filter<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): Item[];
|
|
10
12
|
/**
|
|
11
13
|
* Get a filtered array of items
|
|
12
14
|
* @param array Array to search in
|
|
@@ -14,26 +16,27 @@ export declare function filter<Item, Callback extends (item: Item, index: number
|
|
|
14
16
|
* @param value Value to match against
|
|
15
17
|
* @returns Filtered array of items
|
|
16
18
|
*/
|
|
17
|
-
|
|
19
|
+
declare function filter<Item extends PlainObject, Key extends keyof Item>(array: Item[], key: Key, value: Item[Key]): Item[];
|
|
18
20
|
/**
|
|
19
21
|
* Get a filtered array of items matching the filter
|
|
20
22
|
* @param array Array to search in
|
|
21
23
|
* @param filter Filter callback to match items
|
|
22
24
|
* @returns Filtered array of items
|
|
23
25
|
*/
|
|
24
|
-
|
|
26
|
+
declare function filter<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): Item[];
|
|
25
27
|
/**
|
|
26
28
|
* Get a filtered array of items matching the given item
|
|
27
29
|
* @param array Array to search in
|
|
28
30
|
* @param item Item to match against
|
|
29
31
|
* @returns Filtered array of items
|
|
30
32
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
declare function filter<Item>(array: Item[], item: Item): Item[];
|
|
34
|
+
declare namespace filter {
|
|
35
|
+
var remove: typeof removeFiltered;
|
|
34
36
|
}
|
|
35
37
|
declare function removeFiltered<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): unknown[];
|
|
36
38
|
declare function removeFiltered<Item extends PlainObject, Key extends keyof Item>(array: Item[], key: Key, value: Item[Key]): unknown[];
|
|
37
39
|
declare function removeFiltered<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): unknown[];
|
|
38
40
|
declare function removeFiltered<Item>(array: Item[], item: Item): unknown[];
|
|
39
|
-
|
|
41
|
+
//#endregion
|
|
42
|
+
export { filter };
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { PlainObject } from "../models.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/array/find.d.ts
|
|
2
4
|
/**
|
|
3
5
|
* Get the first items matching the given value
|
|
4
6
|
* @param array Array to search in
|
|
@@ -6,7 +8,7 @@ import type { PlainObject } from '../models';
|
|
|
6
8
|
* @param value Value to match against
|
|
7
9
|
* @returns First item that matches the value, or `undefined` if no match is found
|
|
8
10
|
*/
|
|
9
|
-
|
|
11
|
+
declare function find<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): Item | undefined;
|
|
10
12
|
/**
|
|
11
13
|
* Get the first item matching the given value by key
|
|
12
14
|
* @param array Array to search in
|
|
@@ -14,18 +16,20 @@ export declare function find<Item, Callback extends (item: Item, index: number,
|
|
|
14
16
|
* @param value Value to match against
|
|
15
17
|
* @returns First item that matches the value, or `undefined` if no match is found
|
|
16
18
|
*/
|
|
17
|
-
|
|
19
|
+
declare function find<Item extends PlainObject, Key extends keyof Item>(array: Item[], key: Key, value: Item[Key]): Item | undefined;
|
|
18
20
|
/**
|
|
19
21
|
* Get the first item matching the filter
|
|
20
22
|
* @param array Array to search in
|
|
21
23
|
* @param filter Filter callback to match items
|
|
22
24
|
* @returns First item that matches the filter, or `undefined` if no match is found
|
|
23
25
|
*/
|
|
24
|
-
|
|
26
|
+
declare function find<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): Item | undefined;
|
|
25
27
|
/**
|
|
26
28
|
* Get the first item matching the given value
|
|
27
29
|
* @param array Array to search in
|
|
28
30
|
* @param value Value to match against
|
|
29
31
|
* @returns First item that matches the value, or `undefined` if no match is found
|
|
30
32
|
*/
|
|
31
|
-
|
|
33
|
+
declare function find<Item>(array: Item[], value: Item): Item | undefined;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { find };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FIND_VALUE_VALUE, findValue } from "../internal/array/find.
|
|
1
|
+
import { FIND_VALUE_VALUE, findValue } from "../internal/array/find.mjs";
|
|
2
2
|
//#region src/array/find.ts
|
|
3
3
|
function find(array, ...parameters) {
|
|
4
4
|
return findValue(FIND_VALUE_VALUE, array, parameters);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { NestedArray } from "../models.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/array/flatten.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Flatten an array _(using native `flat` and maximum depth)_
|
|
6
|
+
* @param array Array to flatten
|
|
7
|
+
* @returns Flattened array
|
|
8
|
+
*/
|
|
9
|
+
declare function flatten<Item>(array: Item[]): NestedArray<Item>[];
|
|
10
|
+
//#endregion
|
|
11
|
+
export { flatten };
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
+
//#region src/array/from.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* Get an array with a specified length, filled with indices
|
|
3
4
|
* @param length Length of the array
|
|
4
5
|
* @returns Array of indices
|
|
5
6
|
*/
|
|
6
|
-
|
|
7
|
+
declare function range(length: number): number[];
|
|
7
8
|
/**
|
|
8
9
|
* Get an array of numbers in a specified range
|
|
9
10
|
* @param start Starting number _(inclusive)_
|
|
10
11
|
* @param end Ending number _(exclusive)_
|
|
11
12
|
* @returns Array of numbers in range
|
|
12
13
|
*/
|
|
13
|
-
|
|
14
|
+
declare function range(start: number, end: number): number[];
|
|
14
15
|
/**
|
|
15
16
|
* Get an array of numbers in a specified range with a specified step
|
|
16
17
|
* @param start Starting number _(inclusive)_
|
|
@@ -18,24 +19,26 @@ export declare function range(start: number, end: number): number[];
|
|
|
18
19
|
* @param step Step between numbers
|
|
19
20
|
* @returns Array of numbers in range
|
|
20
21
|
*/
|
|
21
|
-
|
|
22
|
+
declare function range(start: number, end: number, step: number): number[];
|
|
22
23
|
/**
|
|
23
24
|
* Get an array with a specified length, filled with indices
|
|
24
25
|
* @param length Length of the array
|
|
25
26
|
* @returns Array of indices
|
|
26
27
|
*/
|
|
27
|
-
|
|
28
|
+
declare function times(length: number): number[];
|
|
28
29
|
/**
|
|
29
30
|
* Get an array with a specified length, filled by values from a callback
|
|
30
31
|
* @param length Length of the array
|
|
31
32
|
* @param callback Callback function to generate values
|
|
32
33
|
* @returns Array of values generated by the callback
|
|
33
34
|
*/
|
|
34
|
-
|
|
35
|
+
declare function times<Callback extends (index: number) => unknown>(length: number, callback: Callback): ReturnType<Callback>[];
|
|
35
36
|
/**
|
|
36
37
|
* Get an array with a specified length, filled with a specified value
|
|
37
38
|
* @param length Length of the array
|
|
38
39
|
* @param value Value to fill the array with
|
|
39
40
|
* @returns Array filled with the specified value
|
|
40
41
|
*/
|
|
41
|
-
|
|
42
|
+
declare function times<Value>(length: number, value: Value): Value[];
|
|
43
|
+
//#endregion
|
|
44
|
+
export { range, times };
|
|
@@ -1,31 +1,35 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { NumericalKeys, PlainObject } from "../models.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/array/get.d.ts
|
|
2
4
|
/**
|
|
3
5
|
* Get an array from an object, where only values with numerical keys will be included
|
|
4
6
|
* @param value Object to convert to an array
|
|
5
7
|
* @returns Array holding the values of the object's numerical keys
|
|
6
8
|
*/
|
|
7
|
-
|
|
9
|
+
declare function getArray<Value extends PlainObject>(value: Value, indiced: true): Value[NumericalKeys<Value>][];
|
|
8
10
|
/**
|
|
9
11
|
* Get an array from an object
|
|
10
12
|
* @param value Object to convert to an array
|
|
11
13
|
* @returns Array holding the values of the object
|
|
12
14
|
*/
|
|
13
|
-
|
|
15
|
+
declare function getArray<Value extends PlainObject>(value: Value): Value[keyof Value][];
|
|
14
16
|
/**
|
|
15
17
|
* Get an array
|
|
16
18
|
* @param value Original array
|
|
17
19
|
* @returns Original array
|
|
18
20
|
*/
|
|
19
|
-
|
|
21
|
+
declare function getArray<Item>(value: Item[]): Item[];
|
|
20
22
|
/**
|
|
21
23
|
* Get an array from a value
|
|
22
24
|
* @param value Value to convert to an array
|
|
23
25
|
* @returns Array holding the value
|
|
24
26
|
*/
|
|
25
|
-
|
|
27
|
+
declare function getArray<Item>(value: Item): Item[];
|
|
26
28
|
/**
|
|
27
29
|
* Get an array from an unknown value
|
|
28
30
|
* @param value Value to convert to an array
|
|
29
31
|
* @returns Array of value
|
|
30
32
|
*/
|
|
31
|
-
|
|
33
|
+
declare function getArray(value: unknown): unknown[];
|
|
34
|
+
//#endregion
|
|
35
|
+
export { getArray };
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Key, KeyedValue, PlainObject, Simplify } from "../models.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/array/group-by.d.ts
|
|
2
4
|
/**
|
|
3
5
|
* Create a record from an array of items using a specific key and value
|
|
4
6
|
*
|
|
@@ -8,7 +10,7 @@ import type { Key, KeyedValue, PlainObject, Simplify } from '../models';
|
|
|
8
10
|
* @param value Callback to get an item's value
|
|
9
11
|
* @returns Record of keyed values
|
|
10
12
|
*/
|
|
11
|
-
|
|
13
|
+
declare function groupBy<Item, KeyCallback extends (item: Item, index: number, array: Item[]) => Key, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: KeyCallback, value: ValueCallback): Simplify<Record<ReturnType<KeyCallback>, ReturnType<ValueCallback>>>;
|
|
12
14
|
/**
|
|
13
15
|
* Create a record from an array of items using a specific key and value
|
|
14
16
|
*
|
|
@@ -18,7 +20,7 @@ export declare function groupBy<Item, KeyCallback extends (item: Item, index: nu
|
|
|
18
20
|
* @param value Key to use for value
|
|
19
21
|
* @returns Record of keyed values
|
|
20
22
|
*/
|
|
21
|
-
|
|
23
|
+
declare function groupBy<Item extends PlainObject, KeyCallback extends (item: Item, index: number, array: Item[]) => Key, ItemValue extends keyof Item>(array: Item[], key: KeyCallback, value: ItemValue): Record<ReturnType<KeyCallback>, Item[ItemValue]>;
|
|
22
24
|
/**
|
|
23
25
|
* Create a record from an array of items using a specific key and value
|
|
24
26
|
*
|
|
@@ -28,7 +30,7 @@ export declare function groupBy<Item extends PlainObject, KeyCallback extends (i
|
|
|
28
30
|
* @param value Callback to get an item's value
|
|
29
31
|
* @returns Record of keyed values
|
|
30
32
|
*/
|
|
31
|
-
|
|
33
|
+
declare function groupBy<Item extends PlainObject, ItemKey extends keyof Item, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: ItemKey, value: ValueCallback): Simplify<Record<KeyedValue<Item, ItemKey>, ReturnType<ValueCallback>>>;
|
|
32
34
|
/**
|
|
33
35
|
* Create a record from an array of items using a specific key and value
|
|
34
36
|
*
|
|
@@ -38,7 +40,7 @@ export declare function groupBy<Item extends PlainObject, ItemKey extends keyof
|
|
|
38
40
|
* @param value Key to use for value
|
|
39
41
|
* @returns Record of keyed values
|
|
40
42
|
*/
|
|
41
|
-
|
|
43
|
+
declare function groupBy<Item extends PlainObject, ItemKey extends keyof Item, ItemValue extends keyof Item>(array: Item[], key: ItemKey, value: ItemValue): Simplify<Record<KeyedValue<Item, ItemKey>, Item[ItemValue]>>;
|
|
42
44
|
/**
|
|
43
45
|
* Create a record from an array of items using a specific key
|
|
44
46
|
*
|
|
@@ -47,7 +49,7 @@ export declare function groupBy<Item extends PlainObject, ItemKey extends keyof
|
|
|
47
49
|
* @param callback Callback to get an item's grouping key
|
|
48
50
|
* @returns Record of keyed items
|
|
49
51
|
*/
|
|
50
|
-
|
|
52
|
+
declare function groupBy<Item, Callback extends (item: Item, index: number, array: Item[]) => Key>(array: Item[], callback: Callback): Record<ReturnType<Callback>, Item>;
|
|
51
53
|
/**
|
|
52
54
|
* Create a record from an array of items using a specific key
|
|
53
55
|
*
|
|
@@ -56,15 +58,15 @@ export declare function groupBy<Item, Callback extends (item: Item, index: numbe
|
|
|
56
58
|
* @param key Key to use for grouping
|
|
57
59
|
* @returns Record of keyed items
|
|
58
60
|
*/
|
|
59
|
-
|
|
61
|
+
declare function groupBy<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey): Simplify<Record<KeyedValue<Item, ItemKey>, Item>>;
|
|
60
62
|
/**
|
|
61
63
|
* Create a record from an array of items _(using indices as keys)_
|
|
62
64
|
* @param array Array to group
|
|
63
65
|
* @returns Record of indiced items
|
|
64
66
|
*/
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
declare function groupBy<Item>(array: Item[]): Record<number, Item>;
|
|
68
|
+
declare namespace groupBy {
|
|
69
|
+
var arrays: typeof groupArraysBy;
|
|
68
70
|
}
|
|
69
71
|
/**
|
|
70
72
|
* Create a record from an array of items using a specific key and value, grouping values into arrays
|
|
@@ -112,4 +114,5 @@ declare function groupArraysBy<Item, Callback extends (item: Item, index: number
|
|
|
112
114
|
* @returns Record of keyed items
|
|
113
115
|
*/
|
|
114
116
|
declare function groupArraysBy<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey): Simplify<Record<KeyedValue<Item, ItemKey>, Item[]>>;
|
|
115
|
-
|
|
117
|
+
//#endregion
|
|
118
|
+
export { groupBy };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { difference } from "./difference.mjs";
|
|
2
|
+
import { exists } from "./exists.mjs";
|
|
3
|
+
import { filter } from "./filter.mjs";
|
|
4
|
+
import { find } from "./find.mjs";
|
|
5
|
+
import { flatten } from "./flatten.mjs";
|
|
6
|
+
import { range, times } from "./from.mjs";
|
|
7
|
+
import { getArray } from "./get.mjs";
|
|
8
|
+
import { chunk } from "../internal/array/chunk.mjs";
|
|
9
|
+
import { compact } from "../internal/array/compact.mjs";
|
|
10
|
+
import { indexOf } from "../internal/array/index-of.mjs";
|
|
11
|
+
import { shuffle } from "../internal/array/shuffle.mjs";
|
|
12
|
+
import { insert } from "./insert.mjs";
|
|
13
|
+
import { intersection } from "./intersection.mjs";
|
|
14
|
+
import { move } from "./move.mjs";
|
|
15
|
+
import { partition } from "./partition.mjs";
|
|
16
|
+
import { ArrayPosition, endsWithArray, getArrayPosition, includesArray, indexOfArray, startsWithArray } from "./position.mjs";
|
|
17
|
+
import { push } from "./push.mjs";
|
|
18
|
+
import { select } from "./select.mjs";
|
|
19
|
+
import { drop, slice, take } from "./slice.mjs";
|
|
20
|
+
import { sort } from "./sort.mjs";
|
|
21
|
+
import { splice } from "./splice.mjs";
|
|
22
|
+
import { swap } from "./swap.mjs";
|
|
23
|
+
import { toSet } from "./to-set.mjs";
|
|
24
|
+
import { toggle } from "./toggle.mjs";
|
|
25
|
+
import { union } from "./union.mjs";
|
|
26
|
+
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 };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { chunk } from "../internal/array/chunk.mjs";
|
|
2
|
+
import { compact } from "../internal/array/compact.mjs";
|
|
3
|
+
import { indexOf } from "../internal/array/index-of.mjs";
|
|
4
|
+
import { shuffle } from "../internal/array/shuffle.mjs";
|
|
5
|
+
import { difference } from "./difference.mjs";
|
|
6
|
+
import { exists } from "./exists.mjs";
|
|
7
|
+
import { filter } from "./filter.mjs";
|
|
8
|
+
import { find } from "./find.mjs";
|
|
9
|
+
import { flatten } from "./flatten.mjs";
|
|
10
|
+
import { range, times } from "./from.mjs";
|
|
11
|
+
import { getArray } from "./get.mjs";
|
|
12
|
+
import { insert } from "./insert.mjs";
|
|
13
|
+
import { intersection } from "./intersection.mjs";
|
|
14
|
+
import { endsWithArray, getArrayPosition, includesArray, indexOfArray, startsWithArray } from "./position.mjs";
|
|
15
|
+
import { move } from "./move.mjs";
|
|
16
|
+
import { partition } from "./partition.mjs";
|
|
17
|
+
import { push } from "./push.mjs";
|
|
18
|
+
import { select } from "./select.mjs";
|
|
19
|
+
import { drop, slice, take } from "./slice.mjs";
|
|
20
|
+
import { sort } from "./sort.mjs";
|
|
21
|
+
import { splice } from "./splice.mjs";
|
|
22
|
+
import { swap } from "./swap.mjs";
|
|
23
|
+
import { toSet } from "./to-set.mjs";
|
|
24
|
+
import { toggle } from "./toggle.mjs";
|
|
25
|
+
import { union } from "./union.mjs";
|
|
26
|
+
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 };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/array/insert.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* Insert items into an array at a specified index
|
|
3
4
|
* @param array Original array
|
|
@@ -5,11 +6,13 @@
|
|
|
5
6
|
* @param items Inserted items
|
|
6
7
|
* @returns Updated array
|
|
7
8
|
*/
|
|
8
|
-
|
|
9
|
+
declare function insert<Item>(array: Item[], index: number, items: Item[]): Item[];
|
|
9
10
|
/**
|
|
10
11
|
* Insert items into an array _(at the end)_
|
|
11
12
|
* @param array Original array
|
|
12
13
|
* @param items Inserted items
|
|
13
14
|
* @returns Updated array
|
|
14
15
|
*/
|
|
15
|
-
|
|
16
|
+
declare function insert<Item>(array: Item[], items: Item[]): Item[];
|
|
17
|
+
//#endregion
|
|
18
|
+
export { insert };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { INSERT_TYPE_INSERT, insertValues } from "../internal/array/insert.
|
|
1
|
+
import { INSERT_TYPE_INSERT, insertValues } from "../internal/array/insert.mjs";
|
|
2
2
|
//#region src/array/insert.ts
|
|
3
3
|
function insert(array, indexOrItems, items) {
|
|
4
4
|
return insertValues(INSERT_TYPE_INSERT, array, items == null ? indexOrItems : items, typeof indexOrItems === "number" ? indexOrItems : array?.length, 0);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/array/intersection.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* Get the common values between two arrays
|
|
3
4
|
* @param first First array
|
|
@@ -5,7 +6,7 @@
|
|
|
5
6
|
* @param callback Callback to get an item's value for comparison
|
|
6
7
|
* @returns Common values from both arrays
|
|
7
8
|
*/
|
|
8
|
-
|
|
9
|
+
declare function intersection<First, Second>(first: First[], second: Second[], callback: (item: First | Second) => unknown): First[];
|
|
9
10
|
/**
|
|
10
11
|
* Get the common values between two arrays
|
|
11
12
|
* @param first First array
|
|
@@ -13,11 +14,13 @@ export declare function intersection<First, Second>(first: First[], second: Seco
|
|
|
13
14
|
* @param key Key to get an item's value for comparison
|
|
14
15
|
* @returns Common values from both arrays
|
|
15
16
|
*/
|
|
16
|
-
|
|
17
|
+
declare function intersection<First extends Record<string, unknown>, Second extends Record<string, unknown>, Key extends keyof First & keyof Second>(first: First[], second: Second[], key: Key): First[];
|
|
17
18
|
/**
|
|
18
19
|
* Get the common values between two arrays
|
|
19
20
|
* @param first First array
|
|
20
21
|
* @param second Second array
|
|
21
22
|
* @returns Common values from both arrays
|
|
22
23
|
*/
|
|
23
|
-
|
|
24
|
+
declare function intersection<First, Second>(first: First[], second: Second[]): First[];
|
|
25
|
+
//#endregion
|
|
26
|
+
export { intersection };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { COMPARE_SETS_INTERSECTION, compareSets } from "../internal/array/sets.
|
|
1
|
+
import { COMPARE_SETS_INTERSECTION, compareSets } from "../internal/array/sets.mjs";
|
|
2
2
|
//#region src/array/intersection.ts
|
|
3
3
|
function intersection(first, second, key) {
|
|
4
4
|
return compareSets(COMPARE_SETS_INTERSECTION, first, second, key);
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { PlainObject } from "../models.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/array/move.d.ts
|
|
2
4
|
/**
|
|
3
5
|
* Move an item _(or array of items)_ to the position of another item _(or array of items)_ within an array
|
|
4
6
|
*
|
|
@@ -11,7 +13,7 @@ import type { PlainObject } from '../models';
|
|
|
11
13
|
* @param key Key to get an item's value for matching
|
|
12
14
|
* @returns Original array with items moved _(or unchanged if unable to move)_
|
|
13
15
|
*/
|
|
14
|
-
|
|
16
|
+
declare function move<Item extends PlainObject, Key extends keyof Item>(array: Item[], from: Item | Item[], to: Item | Item[], key: Key): Item[];
|
|
15
17
|
/**
|
|
16
18
|
* Move an item _(or array of items)_ to the position of another item _(or array of items)_ within an array
|
|
17
19
|
*
|
|
@@ -24,7 +26,7 @@ export declare function move<Item extends PlainObject, Key extends keyof Item>(a
|
|
|
24
26
|
* @param callback Callback to get an item's value for matching
|
|
25
27
|
* @returns Original array with items moved _(or unchanged if unable to move)_
|
|
26
28
|
*/
|
|
27
|
-
|
|
29
|
+
declare function move<Item>(array: Item[], from: Item | Item[], to: Item | Item[], callback: (item: Item, index: number, array: Item[]) => unknown): Item[];
|
|
28
30
|
/**
|
|
29
31
|
* Move an item _(or array of items)_ to the position of another item _(or array of items)_ within an array
|
|
30
32
|
*
|
|
@@ -36,10 +38,10 @@ export declare function move<Item>(array: Item[], from: Item | Item[], to: Item
|
|
|
36
38
|
* @param to Item or items to move to
|
|
37
39
|
* @returns Original array with items moved _(or unchanged if unable to move)_
|
|
38
40
|
*/
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
declare function move<Item>(array: Item[], from: Item | Item[], to: Item | Item[]): Item[];
|
|
42
|
+
declare namespace move {
|
|
43
|
+
var indices: typeof moveIndices;
|
|
44
|
+
var toIndex: typeof moveToIndex;
|
|
43
45
|
}
|
|
44
46
|
/**
|
|
45
47
|
* Move an item from one index to another within an array
|
|
@@ -83,4 +85,5 @@ declare function moveToIndex<Item>(array: Item[], value: Item | Item[], index: n
|
|
|
83
85
|
* @returns Original array with items moved _(or unchanged if unable to move)_
|
|
84
86
|
*/
|
|
85
87
|
declare function moveToIndex<Item>(array: Item[], value: Item | Item[], index: number): Item[];
|
|
86
|
-
|
|
88
|
+
//#endregion
|
|
89
|
+
export { move };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { arraysOverlap } from "../internal/array/overlap.
|
|
2
|
-
import { indexOfArray } from "./position.
|
|
1
|
+
import { arraysOverlap } from "../internal/array/overlap.mjs";
|
|
2
|
+
import { indexOfArray } from "./position.mjs";
|
|
3
3
|
//#region src/array/move.ts
|
|
4
4
|
function move(array, from, to, key) {
|
|
5
5
|
if (!Array.isArray(array)) return [];
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { PlainObject } from "../models.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/array/partition.d.ts
|
|
2
4
|
/**
|
|
3
5
|
* Get a partitioned array of items
|
|
4
6
|
* @param array Array to search in
|
|
@@ -6,7 +8,7 @@ import type { PlainObject } from '../models';
|
|
|
6
8
|
* @param value Value to match against
|
|
7
9
|
* @returns Partitioned array of items
|
|
8
10
|
*/
|
|
9
|
-
|
|
11
|
+
declare function partition<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): Item[][];
|
|
10
12
|
/**
|
|
11
13
|
* Get a partitioned array of items
|
|
12
14
|
* @param array Array to search in
|
|
@@ -14,18 +16,20 @@ export declare function partition<Item, Callback extends (item: Item, index: num
|
|
|
14
16
|
* @param value Value to match against
|
|
15
17
|
* @returns Partitioned array of items
|
|
16
18
|
*/
|
|
17
|
-
|
|
19
|
+
declare function partition<Item extends PlainObject, Key extends keyof Item>(array: Item[], key: Key, value: Item[Key]): Item[][];
|
|
18
20
|
/**
|
|
19
21
|
* Get a partitioned array of items
|
|
20
22
|
* @param array Array to search in
|
|
21
23
|
* @param filter Filter callback to match items
|
|
22
24
|
* @returns Partitioned array of items
|
|
23
25
|
*/
|
|
24
|
-
|
|
26
|
+
declare function partition<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): Item[][];
|
|
25
27
|
/**
|
|
26
28
|
* Get a partitioned array of items matching the given item
|
|
27
29
|
* @param array Array to search in
|
|
28
30
|
* @param item Item to match against
|
|
29
31
|
* @returns Partitioned array of items
|
|
30
32
|
*/
|
|
31
|
-
|
|
33
|
+
declare function partition<Item>(array: Item[], item: Item): Item[][];
|
|
34
|
+
//#endregion
|
|
35
|
+
export { partition };
|