@oscarpalmer/atoms 0.204.1 → 0.205.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/dist/array/filter.d.mts +1 -1
- package/dist/array/find.d.mts +3 -3
- package/dist/array/first.d.mts +3 -4
- package/dist/array/first.mjs +1 -1
- package/dist/array/group-by.d.mts +3 -3
- package/dist/array/index.d.mts +2 -5
- package/dist/array/index.mjs +2 -5
- package/dist/array/last.d.mts +3 -4
- package/dist/array/last.mjs +1 -1
- package/dist/array/move.d.mts +4 -4
- package/dist/array/push.d.mts +2 -1
- package/dist/array/push.mjs +1 -1
- package/dist/array/select.d.mts +95 -84
- package/dist/array/select.mjs +6 -6
- package/dist/array/sort.d.mts +6 -6
- package/dist/array/swap.d.mts +3 -3
- package/dist/array/swap.mjs +1 -1
- package/dist/array/to-map.d.mts +3 -3
- package/dist/array/to-record.d.mts +3 -3
- package/dist/beacon.mjs +2 -2
- package/dist/color/constants.d.mts +14 -41
- package/dist/color/instance.d.mts +0 -1
- package/dist/color/misc/state.d.mts +2 -29
- package/dist/color/models.d.mts +18 -4
- package/dist/function/limit.d.mts +4 -4
- package/dist/function/once.d.mts +6 -8
- package/dist/function/retry.d.mts +2 -2
- package/dist/index.d.mts +997 -1020
- package/dist/index.mjs +104 -102
- package/dist/internal/array/compact.d.mts +1 -1
- package/dist/internal/array/find.d.mts +4 -4
- package/dist/internal/array/index-of.d.mts +3 -3
- package/dist/internal/array/insert.d.mts +1 -1
- package/dist/internal/array/match.d.mts +1 -1
- package/dist/internal/array/sets.d.mts +1 -1
- package/dist/internal/function/assert.d.mts +7 -7
- package/dist/internal/function/limit.d.mts +1 -1
- package/dist/internal/function/work.d.mts +4 -4
- package/dist/internal/herald.d.mts +1 -1
- package/dist/internal/math/aggregate.d.mts +2 -2
- package/dist/internal/result/misc.d.mts +6 -6
- package/dist/internal/sized/map.d.mts +2 -2
- package/dist/internal/value/compare.d.mts +7 -19
- package/dist/internal/value/equal.d.mts +8 -31
- package/dist/internal/value/handlers.d.mts +2 -5
- package/dist/internal/value/has.d.mts +3 -3
- package/dist/is.d.mts +4 -4
- package/dist/promise/helpers.d.mts +2 -2
- package/dist/promise/index.d.mts +7 -7
- package/dist/promise/models.d.mts +1 -1
- package/dist/promise/timed.d.mts +1 -1
- package/dist/queue.d.mts +1 -1
- package/dist/result/index.d.mts +1 -1
- package/dist/result/index.mjs +3 -1
- package/dist/result/match.d.mts +3 -3
- package/dist/result/work/flow.d.mts +1 -1
- package/dist/result/work/pipe.d.mts +1 -1
- package/dist/sized/set.d.mts +1 -1
- package/dist/string/fuzzy.d.mts +4 -4
- package/dist/string/normalize.d.mts +1 -1
- package/dist/string/template.d.mts +1 -2
- package/dist/value/clone.d.mts +8 -20
- package/dist/value/diff.d.mts +1 -1
- package/dist/value/freeze.d.mts +4 -4
- package/dist/value/merge.d.mts +5 -5
- package/dist/value/transform.d.mts +1 -1
- package/package.json +25 -10
- package/plugin/index.js +1 -1
package/dist/array/filter.d.mts
CHANGED
|
@@ -139,6 +139,6 @@ export declare function filter<Item>(array: Item[], filter: (item: Item, index:
|
|
|
139
139
|
*/
|
|
140
140
|
export declare function filter<Item>(array: Item[], item: Item): Item[];
|
|
141
141
|
export declare namespace filter {
|
|
142
|
-
var remove: typeof exclude;
|
|
142
|
+
export var remove: typeof exclude;
|
|
143
143
|
}
|
|
144
144
|
//#endregion
|
package/dist/array/find.d.mts
CHANGED
|
@@ -65,9 +65,6 @@ export declare function find<Item>(array: Item[], filter: (item: Item, index: nu
|
|
|
65
65
|
* ```
|
|
66
66
|
*/
|
|
67
67
|
export declare function find<Item>(array: Item[], value: Item): Item | undefined;
|
|
68
|
-
export declare namespace find {
|
|
69
|
-
var last: typeof findLast;
|
|
70
|
-
}
|
|
71
68
|
/**
|
|
72
69
|
* Get the last item matching the given value
|
|
73
70
|
*
|
|
@@ -141,4 +138,7 @@ export declare function findLast<Item>(array: Item[], filter: (item: Item, index
|
|
|
141
138
|
* ```
|
|
142
139
|
*/
|
|
143
140
|
export declare function findLast<Item>(array: Item[], value: Item): Item | undefined;
|
|
141
|
+
export declare namespace find {
|
|
142
|
+
export var last: typeof findLast;
|
|
143
|
+
}
|
|
144
144
|
//#endregion
|
package/dist/array/first.d.mts
CHANGED
|
@@ -66,10 +66,6 @@ export declare function first<Item>(array: Item[], filter: (item: Item, index: n
|
|
|
66
66
|
* ```
|
|
67
67
|
*/
|
|
68
68
|
export declare function first<Item>(array: Item[]): Item | undefined;
|
|
69
|
-
export declare namespace first {
|
|
70
|
-
var _a: typeof firstOrDefault;
|
|
71
|
-
export { _a as default };
|
|
72
|
-
}
|
|
73
69
|
/**
|
|
74
70
|
* Get the first item matching the given value, or a default value if no match is found
|
|
75
71
|
*
|
|
@@ -149,4 +145,7 @@ export declare function firstOrDefault<Item>(array: Item[], defaultValue: Item,
|
|
|
149
145
|
* ```
|
|
150
146
|
*/
|
|
151
147
|
export declare function firstOrDefault<Item>(array: Item[], defaultValue: Item): Item;
|
|
148
|
+
export declare namespace first {
|
|
149
|
+
export var defaulted: typeof firstOrDefault;
|
|
150
|
+
}
|
|
152
151
|
//#endregion
|
package/dist/array/first.mjs
CHANGED
|
@@ -6,6 +6,6 @@ function first(array, ...parameters) {
|
|
|
6
6
|
function firstOrDefault(array, defaultValue, ...parameters) {
|
|
7
7
|
return findAbsoluteValueOrDefault(array, parameters, defaultValue, true, false);
|
|
8
8
|
}
|
|
9
|
-
first.
|
|
9
|
+
first.defaulted = firstOrDefault;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { first, firstOrDefault };
|
|
@@ -52,9 +52,6 @@ export declare function groupBy<Item, KeyArg extends KeyOrCallback<Item, Key>>(a
|
|
|
52
52
|
* ```
|
|
53
53
|
*/
|
|
54
54
|
export declare function groupBy<Item>(array: Item[]): Record<number, Item>;
|
|
55
|
-
export declare namespace groupBy {
|
|
56
|
-
var arrays: typeof groupArraysBy;
|
|
57
|
-
}
|
|
58
55
|
/**
|
|
59
56
|
* Create a record from an array of items using a specific key, grouping values into arrays
|
|
60
57
|
*
|
|
@@ -99,4 +96,7 @@ export declare function groupArraysBy<Item, KeyArg extends KeyOrCallback<Item, K
|
|
|
99
96
|
* ```
|
|
100
97
|
*/
|
|
101
98
|
export declare function groupArraysBy<Item, KeyArg extends KeyOrCallback<Item, Key>>(array: Item[], key: KeyArg): Simplify<Record<KeyOrCallbackKey<Item, KeyArg>, Item[]>>;
|
|
99
|
+
export declare namespace groupBy {
|
|
100
|
+
export var arrays: typeof groupArraysBy;
|
|
101
|
+
}
|
|
102
102
|
//#endregion
|
package/dist/array/index.d.mts
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
import { difference } from "./difference.mjs";
|
|
2
2
|
import { exists } from "./exists.mjs";
|
|
3
|
-
import { find, findLast } from "./find.mjs";
|
|
4
3
|
import { flatten } from "./flatten.mjs";
|
|
5
4
|
import { range, times } from "./from.mjs";
|
|
6
5
|
import { chunk } from "../internal/array/chunk.mjs";
|
|
7
6
|
import { compact } from "../internal/array/compact.mjs";
|
|
8
7
|
import { getArray } from "../internal/array/get.mjs";
|
|
9
|
-
import { indexOf, lastIndexOf } from "../internal/array/index-of.mjs";
|
|
10
8
|
import { ArrayComparison, endsWithArray, getArrayComparison, includesArray, indexOfArray, startsWithArray } from "../internal/array/match.mjs";
|
|
11
9
|
import { shuffle } from "../internal/array/shuffle.mjs";
|
|
12
10
|
import { insert } from "./insert.mjs";
|
|
13
11
|
import { intersection } from "./intersection.mjs";
|
|
14
12
|
import { partition } from "./partition.mjs";
|
|
15
|
-
import { push } from "./push.mjs";
|
|
13
|
+
import { append as push } from "./push.mjs";
|
|
16
14
|
import { reverse } from "./reverse.mjs";
|
|
17
|
-
import { reverseSelect, select } from "./select.mjs";
|
|
18
15
|
import { single } from "./single.mjs";
|
|
19
16
|
import { drop, slice, take } from "./slice.mjs";
|
|
20
17
|
import { splice } from "./splice.mjs";
|
|
@@ -23,4 +20,4 @@ import { toggle } from "./toggle.mjs";
|
|
|
23
20
|
import { union } from "./union.mjs";
|
|
24
21
|
import { unique } from "./unique.mjs";
|
|
25
22
|
import { update } from "./update.mjs";
|
|
26
|
-
export { ArrayComparison, chunk, compact, difference, drop, endsWithArray, exists,
|
|
23
|
+
export { ArrayComparison, push as append, push, chunk, compact, difference, drop, endsWithArray, exists, flatten, getArray, getArrayComparison, includesArray, indexOfArray, insert, intersection, partition, range, reverse, shuffle, single, slice, splice, startsWithArray, take, times, toSet, toggle, union, unique, update };
|
package/dist/array/index.mjs
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
import { chunk } from "../internal/array/chunk.mjs";
|
|
2
2
|
import { compact } from "../internal/array/compact.mjs";
|
|
3
3
|
import { getArray } from "../internal/array/get.mjs";
|
|
4
|
-
import { indexOf, lastIndexOf } from "../internal/array/index-of.mjs";
|
|
5
4
|
import { endsWithArray, getArrayComparison, includesArray, indexOfArray, startsWithArray } from "../internal/array/match.mjs";
|
|
6
5
|
import { shuffle } from "../internal/array/shuffle.mjs";
|
|
7
6
|
import { difference } from "./difference.mjs";
|
|
8
7
|
import { exists } from "./exists.mjs";
|
|
9
|
-
import { find, findLast } from "./find.mjs";
|
|
10
8
|
import { flatten } from "./flatten.mjs";
|
|
11
9
|
import { range, times } from "./from.mjs";
|
|
12
10
|
import { insert } from "./insert.mjs";
|
|
13
11
|
import { intersection } from "./intersection.mjs";
|
|
14
12
|
import { partition } from "./partition.mjs";
|
|
15
|
-
import { push } from "./push.mjs";
|
|
13
|
+
import { append as push } from "./push.mjs";
|
|
16
14
|
import { reverse } from "./reverse.mjs";
|
|
17
|
-
import { reverseSelect, select } from "./select.mjs";
|
|
18
15
|
import { single } from "./single.mjs";
|
|
19
16
|
import { drop, slice, take } from "./slice.mjs";
|
|
20
17
|
import { splice } from "./splice.mjs";
|
|
@@ -23,4 +20,4 @@ import { toggle } from "./toggle.mjs";
|
|
|
23
20
|
import { union } from "./union.mjs";
|
|
24
21
|
import { unique } from "./unique.mjs";
|
|
25
22
|
import { update } from "./update.mjs";
|
|
26
|
-
export { chunk, compact, difference, drop, endsWithArray, exists,
|
|
23
|
+
export { push as append, push, chunk, compact, difference, drop, endsWithArray, exists, flatten, getArray, getArrayComparison, includesArray, indexOfArray, insert, intersection, partition, range, reverse, shuffle, single, slice, splice, startsWithArray, take, times, toSet, toggle, union, unique, update };
|
package/dist/array/last.d.mts
CHANGED
|
@@ -64,10 +64,6 @@ export declare function last<Item>(array: Item[], filter: (item: Item, index: nu
|
|
|
64
64
|
* ```
|
|
65
65
|
*/
|
|
66
66
|
export declare function last<Item>(array: Item[]): Item | undefined;
|
|
67
|
-
export declare namespace last {
|
|
68
|
-
var _a: typeof lastOrDefault;
|
|
69
|
-
export { _a as default };
|
|
70
|
-
}
|
|
71
67
|
/**
|
|
72
68
|
* Get the last item matching the given value
|
|
73
69
|
*
|
|
@@ -147,4 +143,7 @@ export declare function lastOrDefault<Item>(array: Item[], defaultValue: Item, f
|
|
|
147
143
|
* ```
|
|
148
144
|
*/
|
|
149
145
|
export declare function lastOrDefault<Item>(array: Item[], defaultValue: Item): Item;
|
|
146
|
+
export declare namespace last {
|
|
147
|
+
export var defaulted: typeof lastOrDefault;
|
|
148
|
+
}
|
|
150
149
|
//#endregion
|
package/dist/array/last.mjs
CHANGED
|
@@ -6,6 +6,6 @@ function last(array, ...parameters) {
|
|
|
6
6
|
function lastOrDefault(array, defaultValue, ...parameters) {
|
|
7
7
|
return findAbsoluteValueOrDefault(array, parameters, defaultValue, true, true);
|
|
8
8
|
}
|
|
9
|
-
last.
|
|
9
|
+
last.defaulted = lastOrDefault;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { last, lastOrDefault };
|
package/dist/array/move.d.mts
CHANGED
|
@@ -68,10 +68,6 @@ export declare function move<Item extends PlainObject, ItemKey extends keyof Ite
|
|
|
68
68
|
* ```
|
|
69
69
|
*/
|
|
70
70
|
export declare function move<Item>(array: Item[], from: Item | Item[], to: Item | Item[]): Item[];
|
|
71
|
-
export declare namespace move {
|
|
72
|
-
var indices: typeof moveIndices;
|
|
73
|
-
var toIndex: typeof moveToIndex;
|
|
74
|
-
}
|
|
75
71
|
/**
|
|
76
72
|
* Move an item from one index to another within an array
|
|
77
73
|
*
|
|
@@ -162,4 +158,8 @@ export declare function moveToIndex<Item extends PlainObject, ItemKey extends ke
|
|
|
162
158
|
* ```
|
|
163
159
|
*/
|
|
164
160
|
export declare function moveToIndex<Item>(array: Item[], value: Item | Item[], index: number): Item[];
|
|
161
|
+
export declare namespace move {
|
|
162
|
+
export var indices: typeof moveIndices;
|
|
163
|
+
export var toIndex: typeof moveToIndex;
|
|
164
|
+
}
|
|
165
165
|
//#endregion
|
package/dist/array/push.d.mts
CHANGED
package/dist/array/push.mjs
CHANGED
package/dist/array/select.d.mts
CHANGED
|
@@ -3,9 +3,87 @@ import { PlainObject } from "../models.mjs";
|
|
|
3
3
|
type MapKeyOrCallback<Item> = ((item: Item, index: number, array: Item[]) => unknown) | (Item extends PlainObject ? keyof Item : never);
|
|
4
4
|
type Mapped<Item, Map extends MapKeyOrCallback<Item>> = Map extends ((item: Item, index: number, array: Item[]) => unknown) ? ReturnType<Map> : Map extends keyof Item ? Item[Map] : never;
|
|
5
5
|
type ObjectKeysOf<Item> = { [Key in keyof Item]: Item[Key] extends PlainObject ? Key : never; }[keyof Item];
|
|
6
|
+
/**
|
|
7
|
+
* Get a filtered and mapped array of items
|
|
8
|
+
*
|
|
9
|
+
* @param array Array to search in
|
|
10
|
+
* @param filterCallback Callback to get an item's value for matching
|
|
11
|
+
* @param filterValue Value to match against
|
|
12
|
+
* @param map Callback or key to map the matched items
|
|
13
|
+
* @returns Filtered and mapped array of items
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* select(
|
|
18
|
+
* [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
|
|
19
|
+
* item => item.id,
|
|
20
|
+
* 2,
|
|
21
|
+
* item => item.name,
|
|
22
|
+
* ); // => ['Bob']
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function filterAndMap<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>>;
|
|
26
|
+
/**
|
|
27
|
+
* Get a filtered and mapped array of items
|
|
28
|
+
*
|
|
29
|
+
* @param array Array to search in
|
|
30
|
+
* @param filterKey Key to get an item's value for matching
|
|
31
|
+
* @param filterValue Value to match against
|
|
32
|
+
* @param map Callback or key to map the matched items
|
|
33
|
+
* @returns Filtered and mapped array of items
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* select(
|
|
38
|
+
* [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
|
|
39
|
+
* 'id',
|
|
40
|
+
* 2,
|
|
41
|
+
* 'name',
|
|
42
|
+
* ); // => ['Bob']
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare function filterAndMap<Item extends PlainObject, ItemKey extends keyof Item, Map extends MapKeyOrCallback<Item>>(array: Item[], filterKey: ItemKey, filterValue: Item[ItemKey], map: Map): Array<Mapped<Item, Map>>;
|
|
46
|
+
/**
|
|
47
|
+
* Get a filtered and mapped array of items
|
|
48
|
+
*
|
|
49
|
+
* @param array Array to search in
|
|
50
|
+
* @param filter Filter callback to match items
|
|
51
|
+
* @param map Callback or key to map the matched items
|
|
52
|
+
* @returns Filtered and mapped array of items
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* select(
|
|
57
|
+
* [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
|
|
58
|
+
* item => item.id === 2,
|
|
59
|
+
* item => item.name,
|
|
60
|
+
* ); // => ['Bob']
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export declare function filterAndMap<Item, Map extends MapKeyOrCallback<Item>>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean, map: Map): Array<Mapped<Item, Map>>;
|
|
64
|
+
/**
|
|
65
|
+
* Get a filtered and mapped array of items
|
|
66
|
+
*
|
|
67
|
+
* @param array Array to search in
|
|
68
|
+
* @param item Item to match against
|
|
69
|
+
* @param map Callback or key to map the matched items
|
|
70
|
+
* @returns Filtered and mapped array of items
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* select(
|
|
75
|
+
* [1, 2, 3, 2, 1],
|
|
76
|
+
* 3,
|
|
77
|
+
* value => value ** 2,
|
|
78
|
+
* ); // => [9]
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export declare function filterAndMap<Item, Map extends MapKeyOrCallback<Item>>(array: Item[], item: Item, map: Map): Array<Mapped<Item, Map>>;
|
|
6
82
|
/**
|
|
7
83
|
* Get a mapped and filtered array of items
|
|
8
84
|
*
|
|
85
|
+
* _Available as `reverseSelect`_ and `select.reverse`_
|
|
86
|
+
*
|
|
9
87
|
* @param array Array to search in
|
|
10
88
|
* @param map Callback or key to map the items
|
|
11
89
|
* @param filterCallback Callback to get a mapped value's value for matching
|
|
@@ -22,10 +100,12 @@ type ObjectKeysOf<Item> = { [Key in keyof Item]: Item[Key] extends PlainObject ?
|
|
|
22
100
|
* ); // => ['Bob']
|
|
23
101
|
* ```
|
|
24
102
|
*/
|
|
25
|
-
export declare function
|
|
103
|
+
export declare function mapAndFilter<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
104
|
/**
|
|
27
105
|
* Get a mapped and filtered array of items
|
|
28
106
|
*
|
|
107
|
+
* _Available as `reverseSelect`_ and `select.reverse`_
|
|
108
|
+
*
|
|
29
109
|
* @param array Array to search in
|
|
30
110
|
* @param map Callback to map the items
|
|
31
111
|
* @param filterKey Key to get a mapped value's value for matching
|
|
@@ -42,10 +122,12 @@ export declare function reverseSelect<Item, Map extends MapKeyOrCallback<Item>,
|
|
|
42
122
|
* ); // => [{label: 'Bob'}]
|
|
43
123
|
* ```
|
|
44
124
|
*/
|
|
45
|
-
export declare function
|
|
125
|
+
export declare function mapAndFilter<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
126
|
/**
|
|
47
127
|
* Get a mapped and filtered array of items
|
|
48
128
|
*
|
|
129
|
+
* _Available as `reverseSelect`_ and `select.reverse`_
|
|
130
|
+
*
|
|
49
131
|
* @param array Array to search in
|
|
50
132
|
* @param map Key to map the items
|
|
51
133
|
* @param filterKey Key to get a mapped value's value for matching
|
|
@@ -62,10 +144,12 @@ export declare function reverseSelect<Item, MapCallback extends (item: Item, ind
|
|
|
62
144
|
* ); // => [{tag: 'b'}]
|
|
63
145
|
* ```
|
|
64
146
|
*/
|
|
65
|
-
export declare function
|
|
147
|
+
export declare function mapAndFilter<Item, MapKey extends ObjectKeysOf<Item>, ItemKey extends keyof Item[MapKey]>(array: Item[], map: MapKey, filterKey: ItemKey, filterValue: Item[MapKey][ItemKey]): Array<Item[MapKey]>;
|
|
66
148
|
/**
|
|
67
149
|
* Get a mapped and filtered array of items
|
|
68
150
|
*
|
|
151
|
+
* _Available as `reverseSelect`_ and `select.reverse`_
|
|
152
|
+
*
|
|
69
153
|
* @param array Array to search in
|
|
70
154
|
* @param map Callback or key to map the items
|
|
71
155
|
* @param filter Filter callback to match mapped values
|
|
@@ -80,10 +164,12 @@ export declare function reverseSelect<Item, MapKey extends ObjectKeysOf<Item>, I
|
|
|
80
164
|
* ); // => ['Bob']
|
|
81
165
|
* ```
|
|
82
166
|
*/
|
|
83
|
-
export declare function
|
|
167
|
+
export declare function mapAndFilter<Item, Map extends MapKeyOrCallback<Item>>(array: Item[], map: Map, filter: (item: Mapped<Item, Map>, index: number, array: Item[]) => boolean): Array<Mapped<Item, Map>>;
|
|
84
168
|
/**
|
|
85
169
|
* Get a mapped and filtered array of items
|
|
86
170
|
*
|
|
171
|
+
* _Available as `reverseSelect`_ and `select.reverse`_
|
|
172
|
+
*
|
|
87
173
|
* @param array Array to search in
|
|
88
174
|
* @param map Callback or key to map the items
|
|
89
175
|
* @param value Mapped value to match against
|
|
@@ -98,84 +184,9 @@ export declare function reverseSelect<Item, Map extends MapKeyOrCallback<Item>>(
|
|
|
98
184
|
* ); // => [4, 4]
|
|
99
185
|
* ```
|
|
100
186
|
*/
|
|
101
|
-
export declare function
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
*
|
|
105
|
-
* @param array Array to search in
|
|
106
|
-
* @param filterCallback Callback to get an item's value for matching
|
|
107
|
-
* @param filterValue Value to match against
|
|
108
|
-
* @param map Callback or key to map the matched items
|
|
109
|
-
* @returns Filtered and mapped array of items
|
|
110
|
-
*
|
|
111
|
-
* @example
|
|
112
|
-
* ```typescript
|
|
113
|
-
* select(
|
|
114
|
-
* [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
|
|
115
|
-
* item => item.id,
|
|
116
|
-
* 2,
|
|
117
|
-
* item => item.name,
|
|
118
|
-
* ); // => ['Bob']
|
|
119
|
-
* ```
|
|
120
|
-
*/
|
|
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
|
-
/**
|
|
123
|
-
* Get a filtered and mapped array of items
|
|
124
|
-
*
|
|
125
|
-
* @param array Array to search in
|
|
126
|
-
* @param filterKey Key to get an item's value for matching
|
|
127
|
-
* @param filterValue Value to match against
|
|
128
|
-
* @param map Callback or key to map the matched items
|
|
129
|
-
* @returns Filtered and mapped array of items
|
|
130
|
-
*
|
|
131
|
-
* @example
|
|
132
|
-
* ```typescript
|
|
133
|
-
* select(
|
|
134
|
-
* [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
|
|
135
|
-
* 'id',
|
|
136
|
-
* 2,
|
|
137
|
-
* 'name',
|
|
138
|
-
* ); // => ['Bob']
|
|
139
|
-
* ```
|
|
140
|
-
*/
|
|
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
|
-
/**
|
|
143
|
-
* Get a filtered and mapped array of items
|
|
144
|
-
*
|
|
145
|
-
* @param array Array to search in
|
|
146
|
-
* @param filter Filter callback to match items
|
|
147
|
-
* @param map Callback or key to map the matched items
|
|
148
|
-
* @returns Filtered and mapped array of items
|
|
149
|
-
*
|
|
150
|
-
* @example
|
|
151
|
-
* ```typescript
|
|
152
|
-
* select(
|
|
153
|
-
* [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
|
|
154
|
-
* item => item.id === 2,
|
|
155
|
-
* item => item.name,
|
|
156
|
-
* ); // => ['Bob']
|
|
157
|
-
* ```
|
|
158
|
-
*/
|
|
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
|
-
/**
|
|
161
|
-
* Get a filtered and mapped array of items
|
|
162
|
-
*
|
|
163
|
-
* @param array Array to search in
|
|
164
|
-
* @param item Item to match against
|
|
165
|
-
* @param map Callback or key to map the matched items
|
|
166
|
-
* @returns Filtered and mapped array of items
|
|
167
|
-
*
|
|
168
|
-
* @example
|
|
169
|
-
* ```typescript
|
|
170
|
-
* select(
|
|
171
|
-
* [1, 2, 3, 2, 1],
|
|
172
|
-
* 3,
|
|
173
|
-
* value => value ** 2,
|
|
174
|
-
* ); // => [9]
|
|
175
|
-
* ```
|
|
176
|
-
*/
|
|
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
|
-
var reverse: typeof reverseSelect;
|
|
187
|
+
export declare function mapAndFilter<Item, Map extends MapKeyOrCallback<Item>>(array: Item[], map: Map, value: Mapped<Item, Map>): Array<Mapped<Item, Map>>;
|
|
188
|
+
export declare namespace filterAndMap {
|
|
189
|
+
export var reverse: typeof mapAndFilter;
|
|
180
190
|
}
|
|
181
|
-
//#endregion
|
|
191
|
+
//#endregion
|
|
192
|
+
export { filterAndMap as select, mapAndFilter as reverseSelect };
|
package/dist/array/select.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { findValues } from "../internal/array/find.mjs";
|
|
2
2
|
//#region src/array/select.ts
|
|
3
|
-
function
|
|
3
|
+
function filterAndMap(array, ...parameters) {
|
|
4
|
+
return selectValues(array, parameters);
|
|
5
|
+
}
|
|
6
|
+
function mapAndFilter(array, ...parameters) {
|
|
4
7
|
const mapper = parameters.shift();
|
|
5
8
|
return findValues("all", array, parameters, {
|
|
6
9
|
callback: mapper,
|
|
7
10
|
reverse: true
|
|
8
11
|
}).matched;
|
|
9
12
|
}
|
|
10
|
-
function select(array, ...parameters) {
|
|
11
|
-
return selectValues(array, parameters);
|
|
12
|
-
}
|
|
13
13
|
function selectValues(array, parameters) {
|
|
14
14
|
const mapper = parameters.pop();
|
|
15
15
|
return findValues("all", array, parameters, {
|
|
@@ -17,6 +17,6 @@ function selectValues(array, parameters) {
|
|
|
17
17
|
reverse: false
|
|
18
18
|
}).matched;
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
filterAndMap.reverse = mapAndFilter;
|
|
21
21
|
//#endregion
|
|
22
|
-
export {
|
|
22
|
+
export { filterAndMap, filterAndMap as select, mapAndFilter, mapAndFilter as reverseSelect };
|
package/dist/array/sort.d.mts
CHANGED
|
@@ -67,7 +67,7 @@ type ComparisonSorter<Item> = (first: Item, second: Item) => number;
|
|
|
67
67
|
/**
|
|
68
68
|
* Direction to sort by
|
|
69
69
|
*/
|
|
70
|
-
export type SortDirection =
|
|
70
|
+
export type SortDirection = "ascending" | "descending";
|
|
71
71
|
/**
|
|
72
72
|
* Sorter for an array with predefined sorters
|
|
73
73
|
*
|
|
@@ -244,11 +244,11 @@ export declare function sort<Item>(array: Item[], sorter: ArraySorter<Item>, des
|
|
|
244
244
|
* @returns Sorted array
|
|
245
245
|
*/
|
|
246
246
|
export declare function sort<Item>(array: Item[], descending?: boolean): Item[];
|
|
247
|
-
export declare namespace sort {
|
|
248
|
-
var getIndex: typeof getSortedIndex;
|
|
249
|
-
var initialize: typeof initializeSorter;
|
|
250
|
-
var is: typeof isSorted;
|
|
251
|
-
}
|
|
252
247
|
export declare const SORT_DIRECTION_ASCENDING: SortDirection;
|
|
253
248
|
export declare const SORT_DIRECTION_DESCENDING: SortDirection;
|
|
249
|
+
export declare namespace sort {
|
|
250
|
+
export var getIndex: typeof getSortedIndex;
|
|
251
|
+
export var initialize: typeof initializeSorter;
|
|
252
|
+
export var is: typeof isSorted;
|
|
253
|
+
}
|
|
254
254
|
//#endregion
|
package/dist/array/swap.d.mts
CHANGED
|
@@ -166,9 +166,6 @@ export declare function swap<Item extends PlainObject, ItemKey extends keyof Ite
|
|
|
166
166
|
* ```
|
|
167
167
|
*/
|
|
168
168
|
export declare function swap<Item>(array: Item[], first: Item, second: Item): Item[];
|
|
169
|
-
export declare namespace swap {
|
|
170
|
-
var indices: typeof swapIndices;
|
|
171
|
-
}
|
|
172
169
|
/**
|
|
173
170
|
* Swap two indiced items in an array
|
|
174
171
|
*
|
|
@@ -182,4 +179,7 @@ export declare namespace swap {
|
|
|
182
179
|
* @returns Original array with items swapped _(or unchanged if unable to swap)_
|
|
183
180
|
*/
|
|
184
181
|
declare function swapIndices<Item>(array: Item[], first: number, second: number): Item[];
|
|
182
|
+
export declare namespace swap {
|
|
183
|
+
export var indices: typeof swapIndices;
|
|
184
|
+
}
|
|
185
185
|
//#endregion
|
package/dist/array/swap.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getArrayCallback } from "../internal/array/callbacks.mjs";
|
|
2
|
-
import { indexOf } from "../internal/array/index-of.mjs";
|
|
3
2
|
import { indexOfArray } from "../internal/array/match.mjs";
|
|
4
3
|
import { arraysOverlap } from "../internal/array/overlap.mjs";
|
|
4
|
+
import { indexOf } from "../internal/array/index-of.mjs";
|
|
5
5
|
//#region src/array/swap.ts
|
|
6
6
|
function swap(array, first, second, third) {
|
|
7
7
|
if (!Array.isArray(array)) return [];
|
package/dist/array/to-map.d.mts
CHANGED
|
@@ -52,9 +52,6 @@ export declare function toMap<Item, KeyArg extends KeyOrCallback<Item, Key>>(arr
|
|
|
52
52
|
* ```
|
|
53
53
|
*/
|
|
54
54
|
export declare function toMap<Item>(array: Item[]): Map<number, Item>;
|
|
55
|
-
export declare namespace toMap {
|
|
56
|
-
var arrays: typeof toMapArrays;
|
|
57
|
-
}
|
|
58
55
|
/**
|
|
59
56
|
* Create a _Map_ from an array of items using a specific key, grouping values into arrays
|
|
60
57
|
*
|
|
@@ -93,4 +90,7 @@ export declare function toMapArrays<Item, KeyArg extends KeyOrCallback<Item, Key
|
|
|
93
90
|
* ```
|
|
94
91
|
*/
|
|
95
92
|
export declare function toMapArrays<Item, KeyArg extends KeyOrCallback<Item, Key>>(array: Item[], key: KeyArg): Map<KeyOrCallbackKey<Item, KeyArg>, Item[]>;
|
|
93
|
+
export declare namespace toMap {
|
|
94
|
+
export var arrays: typeof toMapArrays;
|
|
95
|
+
}
|
|
96
96
|
//#endregion
|
|
@@ -52,9 +52,6 @@ export declare function toRecord<Item, KeyArg extends KeyOrCallback<Item, Key>>(
|
|
|
52
52
|
* ```
|
|
53
53
|
*/
|
|
54
54
|
export declare function toRecord<Item>(array: Item[]): Record<number, Item>;
|
|
55
|
-
export declare namespace toRecord {
|
|
56
|
-
var arrays: typeof toRecordArrays;
|
|
57
|
-
}
|
|
58
55
|
/**
|
|
59
56
|
* Create a record from an array of items using a specific key, grouping values into arrays
|
|
60
57
|
*
|
|
@@ -93,4 +90,7 @@ export declare function toRecordArrays<Item, KeyArg extends KeyOrCallback<Item,
|
|
|
93
90
|
* ```
|
|
94
91
|
*/
|
|
95
92
|
export declare function toRecordArrays<Item, KeyArg extends KeyOrCallback<Item, Key>>(array: Item[], key: KeyArg): Simplify<Record<KeyOrCallbackKey<Item, KeyArg>, Item[]>>;
|
|
93
|
+
export declare namespace toRecord {
|
|
94
|
+
export var arrays: typeof toRecordArrays;
|
|
95
|
+
}
|
|
96
96
|
//#endregion
|
package/dist/beacon.mjs
CHANGED
|
@@ -38,7 +38,7 @@ function Observable(beacon) {
|
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
Observable.prototype[BEACON_PROPERTY] = BEACON_OBSERVABLE;
|
|
41
|
-
Observable.prototype.deactivate =
|
|
41
|
+
Observable.prototype.deactivate = deactivateObservable;
|
|
42
42
|
Observable.prototype.subscribe = subscribeToObservable;
|
|
43
43
|
Object.defineProperty(Observable.prototype, "active", {
|
|
44
44
|
enumerable: true,
|
|
@@ -87,7 +87,7 @@ function createObserver(first, second, third) {
|
|
|
87
87
|
function deactivateBeacon() {
|
|
88
88
|
closeBeacon(this[BEACON_SYMBOL], false);
|
|
89
89
|
}
|
|
90
|
-
function
|
|
90
|
+
function deactivateObservable() {
|
|
91
91
|
this[BEACON_SYMBOL].active = false;
|
|
92
92
|
}
|
|
93
93
|
function emitBeaconError(error, finish) {
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { SubscriptionProperty } from "../internal/subscription.mjs";
|
|
2
|
-
import { ColorTypeExtended, HSLAColor, HSLColor, HWBAColor, HWBColor, RGBAColor, RGBColor } from "./models.mjs";
|
|
2
|
+
import { ColorDefaults, ColorExpressions, ColorTypeExtended, HSLAColor, HSLColor, HWBAColor, HWBColor, RGBAColor, RGBColor } from "./models.mjs";
|
|
3
3
|
//#region src/color/constants.d.ts
|
|
4
4
|
type ColorTypes = {
|
|
5
|
-
all: Set<
|
|
6
|
-
hex:
|
|
7
|
-
hexa:
|
|
8
|
-
hsl:
|
|
9
|
-
hsla:
|
|
10
|
-
hwb:
|
|
11
|
-
hwba:
|
|
12
|
-
rgb:
|
|
13
|
-
rgba:
|
|
14
|
-
wildcard:
|
|
5
|
+
all: Set<"alpha" | ColorTypeExtended>;
|
|
6
|
+
hex: "hex";
|
|
7
|
+
hexa: "hexa";
|
|
8
|
+
hsl: "hsl";
|
|
9
|
+
hsla: "hsla";
|
|
10
|
+
hwb: "hwb";
|
|
11
|
+
hwba: "hwba";
|
|
12
|
+
rgb: "rgb";
|
|
13
|
+
rgba: "rgba";
|
|
14
|
+
wildcard: "*";
|
|
15
15
|
};
|
|
16
16
|
export declare const COLOR_ALPHA: {
|
|
17
17
|
fullHexShort: string;
|
|
@@ -20,35 +20,8 @@ export declare const COLOR_ALPHA: {
|
|
|
20
20
|
noneHex: string;
|
|
21
21
|
noneValue: number;
|
|
22
22
|
};
|
|
23
|
-
export declare const COLOR_DEFAULTS:
|
|
24
|
-
|
|
25
|
-
hex: string;
|
|
26
|
-
value: number;
|
|
27
|
-
};
|
|
28
|
-
hexBlack: string;
|
|
29
|
-
hexWhite: string;
|
|
30
|
-
hsl: {
|
|
31
|
-
hue: number;
|
|
32
|
-
saturation: number;
|
|
33
|
-
lightness: number;
|
|
34
|
-
};
|
|
35
|
-
hwb: {
|
|
36
|
-
hue: number;
|
|
37
|
-
whiteness: number;
|
|
38
|
-
blackness: number;
|
|
39
|
-
};
|
|
40
|
-
rgb: {
|
|
41
|
-
blue: number;
|
|
42
|
-
green: number;
|
|
43
|
-
red: number;
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
export declare const COLOR_EXPRESSION: {
|
|
47
|
-
alphaHex: RegExp;
|
|
48
|
-
hexLong: RegExp;
|
|
49
|
-
hexShort: RegExp;
|
|
50
|
-
prefix: RegExp;
|
|
51
|
-
};
|
|
23
|
+
export declare const COLOR_DEFAULTS: ColorDefaults;
|
|
24
|
+
export declare const COLOR_EXPRESSION: ColorExpressions;
|
|
52
25
|
export declare const COLOR_LENGTHS: {
|
|
53
26
|
hexLong: number;
|
|
54
27
|
hexShort: number;
|
|
@@ -68,7 +41,7 @@ export declare const COLOR_MAX: {
|
|
|
68
41
|
};
|
|
69
42
|
export declare const COLOR_NAME = "color";
|
|
70
43
|
export declare const COLOR_PROPERTY = "$color";
|
|
71
|
-
export declare const COLOR_SYMBOL:
|
|
44
|
+
export declare const COLOR_SYMBOL: symbol;
|
|
72
45
|
export declare const COLOR_TYPE: ColorTypes;
|
|
73
46
|
export declare const COLOR_SRGB: {
|
|
74
47
|
luminanceBlue: number;
|