@oscarpalmer/atoms 0.202.0 → 0.204.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/difference.d.mts +4 -5
- package/dist/array/exists.d.mts +5 -6
- package/dist/array/filter.d.mts +10 -11
- package/dist/array/filter.mjs +0 -1
- package/dist/array/find.d.mts +10 -11
- package/dist/array/find.mjs +0 -1
- package/dist/array/first.d.mts +10 -11
- package/dist/array/first.mjs +0 -1
- package/dist/array/flatten.d.mts +2 -3
- package/dist/array/from.d.mts +7 -8
- package/dist/array/group-by.d.mts +7 -8
- package/dist/array/group-by.mjs +0 -1
- package/dist/array/insert.d.mts +3 -4
- package/dist/array/intersection.d.mts +4 -5
- package/dist/array/last.d.mts +10 -11
- package/dist/array/last.mjs +0 -1
- package/dist/array/move.d.mts +9 -10
- package/dist/array/move.mjs +0 -4
- package/dist/array/partition.d.mts +5 -6
- package/dist/array/push.d.mts +2 -3
- package/dist/array/reverse.d.mts +2 -3
- package/dist/array/select.d.mts +11 -12
- package/dist/array/select.mjs +0 -1
- package/dist/array/single.d.mts +4 -5
- package/dist/array/slice.d.mts +12 -13
- package/dist/array/sort.d.mts +31 -32
- package/dist/array/sort.mjs +38 -39
- package/dist/array/splice.d.mts +5 -6
- package/dist/array/swap.d.mts +8 -9
- package/dist/array/swap.mjs +0 -1
- package/dist/array/to-map.d.mts +7 -8
- package/dist/array/to-map.mjs +0 -1
- package/dist/array/to-record.d.mts +7 -8
- package/dist/array/to-record.mjs +0 -1
- package/dist/array/to-set.d.mts +4 -5
- package/dist/array/toggle.d.mts +4 -5
- package/dist/array/union.d.mts +4 -5
- package/dist/array/unique.d.mts +4 -5
- package/dist/array/update.d.mts +4 -5
- package/dist/beacon.d.mts +8 -9
- package/dist/beacon.mjs +96 -71
- package/dist/color/constants.d.mts +14 -13
- package/dist/color/constants.mjs +9 -2
- package/dist/color/index.d.mts +2 -2
- package/dist/color/instance.d.mts +3 -3
- package/dist/color/instance.mjs +91 -69
- package/dist/color/misc/alpha.d.mts +7 -6
- package/dist/color/misc/alpha.mjs +8 -2
- package/dist/color/misc/format.d.mts +6 -7
- package/dist/color/misc/format.mjs +15 -12
- package/dist/color/misc/get.d.mts +14 -15
- package/dist/color/misc/is.d.mts +16 -17
- package/dist/color/misc/is.mjs +7 -7
- package/dist/color/misc/state.d.mts +33 -10
- package/dist/color/misc/state.mjs +28 -48
- package/dist/color/models.d.mts +25 -19
- package/dist/color/space/hex.d.mts +14 -11
- package/dist/color/space/hex.mjs +21 -2
- package/dist/color/space/hsl.d.mts +13 -10
- package/dist/color/space/hsl.mjs +25 -4
- package/dist/color/space/hwb.d.mts +14 -11
- package/dist/color/space/hwb.mjs +24 -3
- package/dist/color/space/rgb.d.mts +16 -13
- package/dist/color/space/rgb.mjs +41 -20
- package/dist/function/limit.d.mts +9 -8
- package/dist/function/limit.mjs +5 -7
- package/dist/function/once.d.mts +26 -6
- package/dist/function/once.mjs +129 -76
- package/dist/function/retry.d.mts +5 -6
- package/dist/function/retry.mjs +3 -4
- package/dist/index.d.mts +184 -60
- package/dist/index.mjs +1292 -970
- package/dist/internal/aborter.d.mts +9 -0
- package/dist/internal/{abort.mjs → aborter.mjs} +1 -1
- package/dist/internal/array/callbacks.d.mts +4 -5
- package/dist/internal/array/chunk.d.mts +2 -3
- package/dist/internal/array/compact.d.mts +3 -4
- package/dist/internal/array/find.d.mts +10 -11
- package/dist/internal/array/get.d.mts +7 -8
- package/dist/internal/array/get.mjs +3 -2
- package/dist/internal/array/group.d.mts +2 -3
- package/dist/internal/array/index-of.d.mts +10 -11
- package/dist/internal/array/index-of.mjs +0 -1
- package/dist/internal/array/insert.d.mts +5 -6
- package/dist/internal/array/match.d.mts +17 -18
- package/dist/internal/array/overlap.d.mts +2 -3
- package/dist/internal/array/sets.d.mts +5 -6
- package/dist/internal/array/shuffle.d.mts +2 -3
- package/dist/internal/array/update.d.mts +2 -3
- package/dist/internal/defaults.d.mts +3 -4
- package/dist/internal/function/assert.d.mts +10 -11
- package/dist/internal/function/assert.mjs +0 -7
- package/dist/internal/function/limit.d.mts +41 -0
- package/dist/internal/function/limit.mjs +106 -0
- package/dist/internal/function/memoize.d.mts +4 -5
- package/dist/internal/function/memoize.mjs +55 -31
- package/dist/internal/function/misc.d.mts +2 -3
- package/dist/internal/function/work.d.mts +53 -54
- package/dist/internal/function/work.mjs +0 -2
- package/dist/internal/herald.d.mts +8 -9
- package/dist/internal/herald.mjs +38 -27
- package/dist/internal/is.d.mts +19 -20
- package/dist/internal/math/aggregate.d.mts +14 -15
- package/dist/internal/math/misc.d.mts +3 -4
- package/dist/internal/number.d.mts +4 -5
- package/dist/internal/random.d.mts +3 -4
- package/dist/internal/result/misc.d.mts +29 -14
- package/dist/internal/result/misc.mjs +4 -3
- package/dist/internal/result/models.d.mts +9 -10
- package/dist/internal/sized/map.d.mts +2 -3
- package/dist/internal/sized/misc.d.mts +2 -3
- package/dist/internal/string/case.d.mts +9 -10
- package/dist/internal/string/misc.d.mts +8 -9
- package/dist/internal/subscription.d.mts +10 -11
- package/dist/internal/subscription.mjs +72 -58
- package/dist/internal/value/compare.d.mts +17 -9
- package/dist/internal/value/compare.mjs +6 -11
- package/dist/internal/value/equal.d.mts +34 -15
- package/dist/internal/value/equal.mjs +20 -13
- package/dist/internal/value/get.d.mts +3 -4
- package/dist/internal/value/handlers.d.mts +19 -9
- package/dist/internal/value/handlers.mjs +48 -50
- package/dist/internal/value/has.d.mts +6 -7
- package/dist/internal/value/has.mjs +0 -1
- package/dist/internal/value/misc.d.mts +6 -7
- package/dist/internal/value/misc.mjs +4 -3
- package/dist/internal/value/partial.d.mts +3 -4
- package/dist/internal/value/partial.mjs +2 -1
- package/dist/internal/value/set.d.mts +4 -5
- package/dist/internal/value/set.mjs +2 -1
- package/dist/is.d.mts +13 -13
- package/dist/logger.d.mts +5 -4
- package/dist/logger.mjs +72 -64
- package/dist/math.d.mts +20 -20
- package/dist/models.d.mts +45 -49
- package/dist/promise/constants.d.mts +14 -15
- package/dist/promise/delay.d.mts +3 -4
- package/dist/promise/delay.mjs +5 -5
- package/dist/promise/helpers.d.mts +7 -8
- package/dist/promise/helpers.mjs +4 -3
- package/dist/promise/index.d.mts +13 -14
- package/dist/promise/index.mjs +1 -2
- package/dist/promise/misc.d.mts +7 -7
- package/dist/promise/models.d.mts +17 -18
- package/dist/promise/timed.d.mts +4 -5
- package/dist/promise/timed.mjs +6 -6
- package/dist/query.d.mts +3 -4
- package/dist/queue.d.mts +14 -15
- package/dist/queue.mjs +198 -136
- package/dist/random.d.mts +8 -8
- package/dist/result/index.d.mts +8 -9
- package/dist/result/index.mjs +0 -1
- package/dist/result/match.d.mts +6 -7
- package/dist/result/match.mjs +0 -1
- package/dist/result/misc.d.mts +3 -3
- package/dist/result/work/flow.d.mts +28 -29
- package/dist/result/work/flow.mjs +0 -1
- package/dist/result/work/pipe.d.mts +24 -25
- package/dist/result/work/pipe.mjs +0 -1
- package/dist/sized/set.d.mts +2 -3
- package/dist/string/fuzzy.d.mts +21 -12
- package/dist/string/fuzzy.mjs +77 -52
- package/dist/string/index.d.mts +8 -8
- package/dist/string/match.d.mts +4 -5
- package/dist/string/normalize.d.mts +8 -9
- package/dist/string/normalize.mjs +9 -5
- package/dist/string/template.d.mts +9 -9
- package/dist/string/template.mjs +11 -5
- package/dist/value/clone.d.mts +21 -13
- package/dist/value/clone.mjs +19 -25
- package/dist/value/collection.d.mts +4 -5
- package/dist/value/diff.d.mts +5 -6
- package/dist/value/freeze.d.mts +18 -19
- package/dist/value/freeze.mjs +1 -5
- package/dist/value/merge.d.mts +13 -14
- package/dist/value/merge.mjs +21 -7
- package/dist/value/omit.d.mts +2 -3
- package/dist/value/pick.d.mts +2 -3
- package/dist/value/shake.d.mts +3 -4
- package/dist/value/smush.d.mts +3 -4
- package/dist/value/transform.d.mts +15 -10
- package/dist/value/transform.mjs +12 -8
- package/dist/value/unsmush.d.mts +3 -4
- package/package.json +2 -2
- package/dist/internal/abort.d.mts +0 -10
- package/dist/internal/function/timer.d.mts +0 -10
- package/dist/internal/function/timer.mjs +0 -87
package/dist/array/splice.d.mts
CHANGED
|
@@ -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
|
package/dist/array/swap.d.mts
CHANGED
|
@@ -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
|
package/dist/array/swap.mjs
CHANGED
package/dist/array/to-map.d.mts
CHANGED
|
@@ -19,7 +19,7 @@ import { Key, KeyOrCallback, KeyOrCallbackKey, KeyOrCallbackValue } from "../mod
|
|
|
19
19
|
* ); // => Map { 10 => 3, 20 => 2 }
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
|
-
declare function toMap<Item, KeyArg extends KeyOrCallback<Item, Key>, ValueArg extends KeyOrCallback<Item>>(array: Item[], key: KeyArg, value: ValueArg): Map<KeyOrCallbackKey<Item, KeyArg>, KeyOrCallbackValue<Item, ValueArg>>;
|
|
22
|
+
export declare function toMap<Item, KeyArg extends KeyOrCallback<Item, Key>, ValueArg extends KeyOrCallback<Item>>(array: Item[], key: KeyArg, value: ValueArg): Map<KeyOrCallbackKey<Item, KeyArg>, KeyOrCallbackValue<Item, ValueArg>>;
|
|
23
23
|
/**
|
|
24
24
|
* Create a _Map_ from an array of items using a specific key
|
|
25
25
|
*
|
|
@@ -37,7 +37,7 @@ declare function toMap<Item, KeyArg extends KeyOrCallback<Item, Key>, ValueArg e
|
|
|
37
37
|
* ); // => Map { 10 => {id: 3, value: 10}, 20 => {id: 2, value: 20} }
|
|
38
38
|
* ```
|
|
39
39
|
*/
|
|
40
|
-
declare function toMap<Item, KeyArg extends KeyOrCallback<Item, Key>>(array: Item[], key: KeyArg): Map<KeyOrCallbackKey<Item, KeyArg>, Item>;
|
|
40
|
+
export declare function toMap<Item, KeyArg extends KeyOrCallback<Item, Key>>(array: Item[], key: KeyArg): Map<KeyOrCallbackKey<Item, KeyArg>, Item>;
|
|
41
41
|
/**
|
|
42
42
|
* Create a _Map_ from an array of items _(using indices as keys)_
|
|
43
43
|
*
|
|
@@ -51,8 +51,8 @@ declare function toMap<Item, KeyArg extends KeyOrCallback<Item, Key>>(array: Ite
|
|
|
51
51
|
* ); // => Map { 0 => {id: 1, value: 10}, 1 => {id: 2, value: 20}, 2 => {id: 3, value: 10} }
|
|
52
52
|
* ```
|
|
53
53
|
*/
|
|
54
|
-
declare function toMap<Item>(array: Item[]): Map<number, Item>;
|
|
55
|
-
declare namespace toMap {
|
|
54
|
+
export declare function toMap<Item>(array: Item[]): Map<number, Item>;
|
|
55
|
+
export declare namespace toMap {
|
|
56
56
|
var arrays: typeof toMapArrays;
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
@@ -74,7 +74,7 @@ declare namespace toMap {
|
|
|
74
74
|
* ); // => Map { 10 => [1, 3], 20 => [2] }
|
|
75
75
|
* ```
|
|
76
76
|
*/
|
|
77
|
-
declare function toMapArrays<Item, KeyArg extends KeyOrCallback<Item, Key>, ValueArg extends KeyOrCallback<Item>>(array: Item[], key: KeyArg, value: ValueArg): Map<KeyOrCallbackKey<Item, KeyArg>, Array<KeyOrCallbackValue<Item, ValueArg>>>;
|
|
77
|
+
export declare function toMapArrays<Item, KeyArg extends KeyOrCallback<Item, Key>, ValueArg extends KeyOrCallback<Item>>(array: Item[], key: KeyArg, value: ValueArg): Map<KeyOrCallbackKey<Item, KeyArg>, Array<KeyOrCallbackValue<Item, ValueArg>>>;
|
|
78
78
|
/**
|
|
79
79
|
* Create a _Map_ from an array of items using a specific key, grouping items into arrays
|
|
80
80
|
*
|
|
@@ -92,6 +92,5 @@ declare function toMapArrays<Item, KeyArg extends KeyOrCallback<Item, Key>, Valu
|
|
|
92
92
|
* ); // => Map { 10 => [{id: 1, value: 10}, {id: 3, value: 10}], 20 => [{id: 2, value: 20}] }
|
|
93
93
|
* ```
|
|
94
94
|
*/
|
|
95
|
-
declare function toMapArrays<Item, KeyArg extends KeyOrCallback<Item, Key>>(array: Item[], key: KeyArg): Map<KeyOrCallbackKey<Item, KeyArg>, Item[]>;
|
|
96
|
-
//#endregion
|
|
97
|
-
export { toMap, toMapArrays };
|
|
95
|
+
export declare function toMapArrays<Item, KeyArg extends KeyOrCallback<Item, Key>>(array: Item[], key: KeyArg): Map<KeyOrCallbackKey<Item, KeyArg>, Item[]>;
|
|
96
|
+
//#endregion
|
package/dist/array/to-map.mjs
CHANGED
|
@@ -19,7 +19,7 @@ import { Key, KeyOrCallback, KeyOrCallbackKey, KeyOrCallbackValue, Simplify } fr
|
|
|
19
19
|
* ); // => { 10: 3, 20: 2 }
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
|
-
declare function toRecord<Item, KeyArg extends KeyOrCallback<Item, Key>, ValueArg extends KeyOrCallback<Item>>(array: Item[], key: KeyArg, value: ValueArg): Simplify<Record<KeyOrCallbackKey<Item, KeyArg>, KeyOrCallbackValue<Item, ValueArg>>>;
|
|
22
|
+
export declare function toRecord<Item, KeyArg extends KeyOrCallback<Item, Key>, ValueArg extends KeyOrCallback<Item>>(array: Item[], key: KeyArg, value: ValueArg): Simplify<Record<KeyOrCallbackKey<Item, KeyArg>, KeyOrCallbackValue<Item, ValueArg>>>;
|
|
23
23
|
/**
|
|
24
24
|
* Create a record from an array of items using a specific key
|
|
25
25
|
*
|
|
@@ -37,7 +37,7 @@ declare function toRecord<Item, KeyArg extends KeyOrCallback<Item, Key>, ValueAr
|
|
|
37
37
|
* ); // => { 10: {id: 3, value: 10}, 20: {id: 2, value: 20} }
|
|
38
38
|
* ```
|
|
39
39
|
*/
|
|
40
|
-
declare function toRecord<Item, KeyArg extends KeyOrCallback<Item, Key>>(array: Item[], key: KeyArg): Simplify<Record<KeyOrCallbackKey<Item, KeyArg>, Item>>;
|
|
40
|
+
export declare function toRecord<Item, KeyArg extends KeyOrCallback<Item, Key>>(array: Item[], key: KeyArg): Simplify<Record<KeyOrCallbackKey<Item, KeyArg>, Item>>;
|
|
41
41
|
/**
|
|
42
42
|
* Create a record from an array of items _(using indices as keys)_
|
|
43
43
|
*
|
|
@@ -51,8 +51,8 @@ declare function toRecord<Item, KeyArg extends KeyOrCallback<Item, Key>>(array:
|
|
|
51
51
|
* ); // => { 0: {id: 1, value: 10}, 1: {id: 2, value: 20}, 2: {id: 3, value: 10} }
|
|
52
52
|
* ```
|
|
53
53
|
*/
|
|
54
|
-
declare function toRecord<Item>(array: Item[]): Record<number, Item>;
|
|
55
|
-
declare namespace toRecord {
|
|
54
|
+
export declare function toRecord<Item>(array: Item[]): Record<number, Item>;
|
|
55
|
+
export declare namespace toRecord {
|
|
56
56
|
var arrays: typeof toRecordArrays;
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
@@ -74,7 +74,7 @@ declare namespace toRecord {
|
|
|
74
74
|
* ); // => { 10: [1, 3], 20: [2] }
|
|
75
75
|
* ```
|
|
76
76
|
*/
|
|
77
|
-
declare function toRecordArrays<Item, KeyArg extends KeyOrCallback<Item, Key>, ValueArg extends KeyOrCallback<Item>>(array: Item[], key: KeyArg, value: ValueArg): Simplify<Record<KeyOrCallbackKey<Item, KeyArg>, Array<KeyOrCallbackValue<Item, ValueArg>>>>;
|
|
77
|
+
export declare function toRecordArrays<Item, KeyArg extends KeyOrCallback<Item, Key>, ValueArg extends KeyOrCallback<Item>>(array: Item[], key: KeyArg, value: ValueArg): Simplify<Record<KeyOrCallbackKey<Item, KeyArg>, Array<KeyOrCallbackValue<Item, ValueArg>>>>;
|
|
78
78
|
/**
|
|
79
79
|
* Create a record from an array of items using a specific key, grouping items into arrays
|
|
80
80
|
*
|
|
@@ -92,6 +92,5 @@ declare function toRecordArrays<Item, KeyArg extends KeyOrCallback<Item, Key>, V
|
|
|
92
92
|
* ); // => { 10: [{id: 1, value: 10}, {id: 3, value: 10}], 20: [{id: 2, value: 20}] }
|
|
93
93
|
* ```
|
|
94
94
|
*/
|
|
95
|
-
declare function toRecordArrays<Item, KeyArg extends KeyOrCallback<Item, Key>>(array: Item[], key: KeyArg): Simplify<Record<KeyOrCallbackKey<Item, KeyArg>, Item[]>>;
|
|
96
|
-
//#endregion
|
|
97
|
-
export { toRecord, toRecordArrays };
|
|
95
|
+
export declare function toRecordArrays<Item, KeyArg extends KeyOrCallback<Item, Key>>(array: Item[], key: KeyArg): Simplify<Record<KeyOrCallbackKey<Item, KeyArg>, Item[]>>;
|
|
96
|
+
//#endregion
|
package/dist/array/to-record.mjs
CHANGED
package/dist/array/to-set.d.mts
CHANGED
|
@@ -15,7 +15,7 @@ import { PlainObject } from "../models.mjs";
|
|
|
15
15
|
* ); // => Set { 1, 2, 3 }
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
|
-
declare function toSet<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback): Set<ReturnType<Callback>>;
|
|
18
|
+
export declare function toSet<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback): Set<ReturnType<Callback>>;
|
|
19
19
|
/**
|
|
20
20
|
* Create a _Set_ from an array of items using a key
|
|
21
21
|
*
|
|
@@ -31,7 +31,7 @@ declare function toSet<Item, Callback extends (item: Item, index: number, array:
|
|
|
31
31
|
* ); // => Set { 1, 2, 3 }
|
|
32
32
|
* ```
|
|
33
33
|
*/
|
|
34
|
-
declare function toSet<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey): Set<Item[ItemKey]>;
|
|
34
|
+
export declare function toSet<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey): Set<Item[ItemKey]>;
|
|
35
35
|
/**
|
|
36
36
|
* Create a _Set_ from an array of items
|
|
37
37
|
*
|
|
@@ -43,6 +43,5 @@ declare function toSet<Item extends PlainObject, ItemKey extends keyof Item>(arr
|
|
|
43
43
|
* toSet([1, 2, 3]); // => Set { 1, 2, 3 }
|
|
44
44
|
* ```
|
|
45
45
|
*/
|
|
46
|
-
declare function toSet<Item>(array: Item[]): Set<Item>;
|
|
47
|
-
//#endregion
|
|
48
|
-
export { toSet };
|
|
46
|
+
export declare function toSet<Item>(array: Item[]): Set<Item>;
|
|
47
|
+
//#endregion
|
package/dist/array/toggle.d.mts
CHANGED
|
@@ -19,7 +19,7 @@ import { PlainObject } from "../models.mjs";
|
|
|
19
19
|
* ); // => [{id: 1}, {id: 3}, {id: 4}]
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
|
-
declare function toggle<Item>(destination: Item[], toggled: Item[], callback: (item: Item, index: number, array: Item[]) => unknown): Item[];
|
|
22
|
+
export declare function toggle<Item>(destination: Item[], toggled: Item[], callback: (item: Item, index: number, array: Item[]) => unknown): Item[];
|
|
23
23
|
/**
|
|
24
24
|
* Toggle an item in an array
|
|
25
25
|
*
|
|
@@ -39,7 +39,7 @@ declare function toggle<Item>(destination: Item[], toggled: Item[], callback: (i
|
|
|
39
39
|
* ); // => [{id: 1}, {id: 3}, {id: 4}]
|
|
40
40
|
* ```
|
|
41
41
|
*/
|
|
42
|
-
declare function toggle<Item extends PlainObject, ItemKey extends keyof Item>(destination: Item[], toggled: Item[], key: ItemKey): Item[];
|
|
42
|
+
export declare function toggle<Item extends PlainObject, ItemKey extends keyof Item>(destination: Item[], toggled: Item[], key: ItemKey): Item[];
|
|
43
43
|
/**
|
|
44
44
|
* Toggle an item in an array
|
|
45
45
|
*
|
|
@@ -57,6 +57,5 @@ declare function toggle<Item extends PlainObject, ItemKey extends keyof Item>(de
|
|
|
57
57
|
* ); // => [1, 3, 4]
|
|
58
58
|
* ```
|
|
59
59
|
*/
|
|
60
|
-
declare function toggle<Item>(destination: Item[], toggled: Item[]): Item[];
|
|
61
|
-
//#endregion
|
|
62
|
-
export { toggle };
|
|
60
|
+
export declare function toggle<Item>(destination: Item[], toggled: Item[]): Item[];
|
|
61
|
+
//#endregion
|
package/dist/array/union.d.mts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* ); // => [{id: 1}, {id: 2}, {id: 3}, {id: 4}]
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
|
-
declare function union<First, Second>(first: First[], second: Second[], callback: (item: First | Second) => unknown): (First | Second)[];
|
|
19
|
+
export declare function union<First, Second>(first: First[], second: Second[], callback: (item: First | Second) => unknown): (First | Second)[];
|
|
20
20
|
/**
|
|
21
21
|
* Get the combined, unique values from two arrays
|
|
22
22
|
*
|
|
@@ -34,7 +34,7 @@ declare function union<First, Second>(first: First[], second: Second[], callback
|
|
|
34
34
|
* ); // => [{id: 1}, {id: 2}, {id: 3}, {id: 4}]
|
|
35
35
|
* ```
|
|
36
36
|
*/
|
|
37
|
-
declare function union<First extends Record<string, unknown>, Second extends Record<string, unknown>, SharedKey extends keyof First & keyof Second>(first: First[], second: Second[], key: SharedKey): (First | Second)[];
|
|
37
|
+
export declare function union<First extends Record<string, unknown>, Second extends Record<string, unknown>, SharedKey extends keyof First & keyof Second>(first: First[], second: Second[], key: SharedKey): (First | Second)[];
|
|
38
38
|
/**
|
|
39
39
|
* Get the combined, unique values from two arrays
|
|
40
40
|
*
|
|
@@ -50,6 +50,5 @@ declare function union<First extends Record<string, unknown>, Second extends Rec
|
|
|
50
50
|
* ); // => [1, 2, 3, 4]
|
|
51
51
|
* ```
|
|
52
52
|
*/
|
|
53
|
-
declare function union<First, Second>(first: First[], second: Second[]): (First | Second)[];
|
|
54
|
-
//#endregion
|
|
55
|
-
export { union };
|
|
53
|
+
export declare function union<First, Second>(first: First[], second: Second[]): (First | Second)[];
|
|
54
|
+
//#endregion
|
package/dist/array/unique.d.mts
CHANGED
|
@@ -15,7 +15,7 @@ import { PlainObject } from "../models.mjs";
|
|
|
15
15
|
* ); // => [{id: 1}, {id: 2}, {id: 3}]
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
|
-
declare function unique<Item>(array: Item[], callback: (item: Item, index: number, array: Item[]) => unknown): Item[];
|
|
18
|
+
export declare function unique<Item>(array: Item[], callback: (item: Item, index: number, array: Item[]) => unknown): Item[];
|
|
19
19
|
/**
|
|
20
20
|
* Get an array of unique items
|
|
21
21
|
*
|
|
@@ -31,7 +31,7 @@ declare function unique<Item>(array: Item[], callback: (item: Item, index: numbe
|
|
|
31
31
|
* ); // => [{id: 1}, {id: 2}, {id: 3}]
|
|
32
32
|
* ```
|
|
33
33
|
*/
|
|
34
|
-
declare function unique<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey): Item[];
|
|
34
|
+
export declare function unique<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey): Item[];
|
|
35
35
|
/**
|
|
36
36
|
* Get an array of unique items
|
|
37
37
|
*
|
|
@@ -43,6 +43,5 @@ declare function unique<Item extends PlainObject, ItemKey extends keyof Item>(ar
|
|
|
43
43
|
* unique([1, 2, 3, 2]); // => [1, 2, 3]
|
|
44
44
|
* ```
|
|
45
45
|
*/
|
|
46
|
-
declare function unique<Item>(array: Item[]): Item[];
|
|
47
|
-
//#endregion
|
|
48
|
-
export { unique };
|
|
46
|
+
export declare function unique<Item>(array: Item[]): Item[];
|
|
47
|
+
//#endregion
|
package/dist/array/update.d.mts
CHANGED
|
@@ -19,7 +19,7 @@ import { PlainObject } from "../models.mjs";
|
|
|
19
19
|
* ); // => [{id: 1}, {id: 2, name: 'Updated'}, {id: 3}, {id: 4, name: 'New'}]
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
|
-
declare function update<Item>(destination: Item[], updated: Item[], callback: (item: Item, index: number, array: Item[]) => unknown): Item[];
|
|
22
|
+
export declare function update<Item>(destination: Item[], updated: Item[], callback: (item: Item, index: number, array: Item[]) => unknown): Item[];
|
|
23
23
|
/**
|
|
24
24
|
* Update an item in an array
|
|
25
25
|
*
|
|
@@ -39,7 +39,7 @@ declare function update<Item>(destination: Item[], updated: Item[], callback: (i
|
|
|
39
39
|
* ); // => [{id: 1}, {id: 2, name: 'Updated'}, {id: 3}, {id: 4, name: 'New'}]
|
|
40
40
|
* ```
|
|
41
41
|
*/
|
|
42
|
-
declare function update<Item extends PlainObject, ItemKey extends keyof Item>(destination: Item[], updated: Item[], key: ItemKey): Item[];
|
|
42
|
+
export declare function update<Item extends PlainObject, ItemKey extends keyof Item>(destination: Item[], updated: Item[], key: ItemKey): Item[];
|
|
43
43
|
/**
|
|
44
44
|
* Update an item in an array
|
|
45
45
|
*
|
|
@@ -57,6 +57,5 @@ declare function update<Item extends PlainObject, ItemKey extends keyof Item>(de
|
|
|
57
57
|
* ); // => [1, 2, 3, 4]
|
|
58
58
|
* ```
|
|
59
59
|
*/
|
|
60
|
-
declare function update<Item>(destination: Item[], updated: Item[]): Item[];
|
|
61
|
-
//#endregion
|
|
62
|
-
export { update };
|
|
60
|
+
export declare function update<Item>(destination: Item[], updated: Item[]): Item[];
|
|
61
|
+
//#endregion
|
package/dist/beacon.d.mts
CHANGED
|
@@ -3,7 +3,7 @@ import { Subscription } from "./internal/subscription.mjs";
|
|
|
3
3
|
/**
|
|
4
4
|
* A beacon is a lighthouse, holding an observable value that can be subscribed to and emitted from
|
|
5
5
|
*/
|
|
6
|
-
type Beacon<Value> = {
|
|
6
|
+
export type Beacon<Value> = {
|
|
7
7
|
/**
|
|
8
8
|
* Is the beacon active?
|
|
9
9
|
*/
|
|
@@ -39,7 +39,7 @@ type Beacon<Value> = {
|
|
|
39
39
|
*/
|
|
40
40
|
finish(): void;
|
|
41
41
|
};
|
|
42
|
-
type BeaconOptions<Value> = {
|
|
42
|
+
export type BeaconOptions<Value> = {
|
|
43
43
|
/**
|
|
44
44
|
* Method for comparing values for equality
|
|
45
45
|
*
|
|
@@ -50,7 +50,7 @@ type BeaconOptions<Value> = {
|
|
|
50
50
|
*/
|
|
51
51
|
equal?: (first: Value, second: Value) => boolean;
|
|
52
52
|
};
|
|
53
|
-
type Observable<Value> = {
|
|
53
|
+
export type Observable<Value> = {
|
|
54
54
|
/**
|
|
55
55
|
* Is the observable active?
|
|
56
56
|
*/
|
|
@@ -97,27 +97,26 @@ type Observer<Value> = {
|
|
|
97
97
|
* @param options Beacon options
|
|
98
98
|
* @returns Beacon instance
|
|
99
99
|
*/
|
|
100
|
-
declare function beacon<Value>(value: Value, options?: BeaconOptions<Value>): Beacon<Value>;
|
|
100
|
+
export declare function beacon<Value>(value: Value, options?: BeaconOptions<Value>): Beacon<Value>;
|
|
101
101
|
/**
|
|
102
102
|
* Is the value a beacon?
|
|
103
103
|
*
|
|
104
104
|
* @param value Value to check
|
|
105
105
|
* @returns `true` if the value is a beacon, otherwise `false`
|
|
106
106
|
*/
|
|
107
|
-
declare function isBeacon<Value = unknown>(value: unknown): value is Beacon<Value>;
|
|
107
|
+
export declare function isBeacon<Value = unknown>(value: unknown): value is Beacon<Value>;
|
|
108
108
|
/**
|
|
109
109
|
* Is the value a beacon subscription?
|
|
110
110
|
*
|
|
111
111
|
* @param value Value to check
|
|
112
112
|
* @returns `true` if the value is a beacon subscription, otherwise `false`
|
|
113
113
|
*/
|
|
114
|
-
declare function isBeaconSubscription(value: unknown): value is Subscription;
|
|
114
|
+
export declare function isBeaconSubscription(value: unknown): value is Subscription;
|
|
115
115
|
/**
|
|
116
116
|
* Is the value an observable?
|
|
117
117
|
*
|
|
118
118
|
* @param value Value to check
|
|
119
119
|
* @returns `true` if the value is an observable, otherwise `false`
|
|
120
120
|
*/
|
|
121
|
-
declare function isObservable<Value = unknown>(value: unknown): value is Observable<Value>;
|
|
122
|
-
//#endregion
|
|
123
|
-
export { Beacon, BeaconOptions, Observable, beacon, isBeacon, isBeaconSubscription, isObservable };
|
|
121
|
+
export declare function isObservable<Value = unknown>(value: unknown): value is Observable<Value>;
|
|
122
|
+
//#endregion
|
package/dist/beacon.mjs
CHANGED
|
@@ -2,6 +2,48 @@ import { noop } from "./internal/function/misc.mjs";
|
|
|
2
2
|
import { isPlainObject } from "./internal/is.mjs";
|
|
3
3
|
import { SUBSCRIPTION_NAME, isSubscription, subscriptions } from "./internal/subscription.mjs";
|
|
4
4
|
//#region src/beacon.ts
|
|
5
|
+
const BEACON_PROPERTY = "$beacon";
|
|
6
|
+
const BEACON_NAME = "beacon";
|
|
7
|
+
const BEACON_OBSERVABLE = "observable";
|
|
8
|
+
function Beacon(value, options) {
|
|
9
|
+
this[BEACON_SYMBOL] = {
|
|
10
|
+
value,
|
|
11
|
+
active: true,
|
|
12
|
+
options: createBeaconOptions(options)
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
Beacon.prototype[BEACON_PROPERTY] = BEACON_NAME;
|
|
16
|
+
Beacon.prototype.deactivate = deactivateBeacon;
|
|
17
|
+
Beacon.prototype.emit = emitBeaconValue;
|
|
18
|
+
Beacon.prototype.error = emitBeaconError;
|
|
19
|
+
Beacon.prototype.finish = finishBeacon;
|
|
20
|
+
Object.defineProperties(Beacon.prototype, {
|
|
21
|
+
active: {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: getBeaconActive
|
|
24
|
+
},
|
|
25
|
+
observable: {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: getBeaconObservable
|
|
28
|
+
},
|
|
29
|
+
value: {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get: getBeaconValue
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
function Observable(beacon) {
|
|
35
|
+
this[BEACON_SYMBOL] = {
|
|
36
|
+
beacon,
|
|
37
|
+
active: beacon.active
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
Observable.prototype[BEACON_PROPERTY] = BEACON_OBSERVABLE;
|
|
41
|
+
Observable.prototype.deactivate = deactiveateObservable;
|
|
42
|
+
Observable.prototype.subscribe = subscribeToObservable;
|
|
43
|
+
Object.defineProperty(Observable.prototype, "active", {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: getObservableActive
|
|
46
|
+
});
|
|
5
47
|
/**
|
|
6
48
|
* Create a new beacon
|
|
7
49
|
*
|
|
@@ -10,60 +52,22 @@ import { SUBSCRIPTION_NAME, isSubscription, subscriptions } from "./internal/sub
|
|
|
10
52
|
* @returns Beacon instance
|
|
11
53
|
*/
|
|
12
54
|
function beacon(value, options) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
};
|
|
26
|
-
Object.defineProperties(instance, {
|
|
27
|
-
[BEACON_PROPERTY]: { value: BEACON_NAME },
|
|
28
|
-
active: {
|
|
29
|
-
enumerable: true,
|
|
30
|
-
get: () => state.active
|
|
31
|
-
},
|
|
32
|
-
observable: {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: () => getObservable(state)
|
|
35
|
-
},
|
|
36
|
-
value: {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: () => state.value
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
return Object.freeze(instance);
|
|
55
|
+
return new Beacon(value, options);
|
|
56
|
+
}
|
|
57
|
+
function closeBeacon(state, emit) {
|
|
58
|
+
if (!state.active) return;
|
|
59
|
+
state.active = false;
|
|
60
|
+
const subscriptions = state.subscriptions?.values.to.any;
|
|
61
|
+
if (subscriptions != null && subscriptions.size > 0) {
|
|
62
|
+
for (const [, observer] of subscriptions) if (emit) observer.complete?.();
|
|
63
|
+
}
|
|
64
|
+
state.subscriptions?.clear();
|
|
65
|
+
state.observable?.deactivate();
|
|
66
|
+
state.observable = void 0;
|
|
42
67
|
}
|
|
43
68
|
function createBeaconOptions(input) {
|
|
44
69
|
const options = isPlainObject(input) ? input : {};
|
|
45
|
-
|
|
46
|
-
return options;
|
|
47
|
-
}
|
|
48
|
-
function createObservable(beacon) {
|
|
49
|
-
const state = {
|
|
50
|
-
beacon,
|
|
51
|
-
active: beacon.active
|
|
52
|
-
};
|
|
53
|
-
const instance = {
|
|
54
|
-
deactivate: () => {
|
|
55
|
-
state.active = false;
|
|
56
|
-
},
|
|
57
|
-
subscribe: (first, second, third) => subscribeToObservable(state, first, second, third)
|
|
58
|
-
};
|
|
59
|
-
Object.defineProperties(instance, {
|
|
60
|
-
[BEACON_PROPERTY]: { value: BEACON_OBSERVABLE },
|
|
61
|
-
active: {
|
|
62
|
-
enumerable: true,
|
|
63
|
-
get: () => beacon.active && state.active
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
return Object.freeze(instance);
|
|
70
|
+
return { equal: typeof options.equal === "function" ? options.equal : Object.is };
|
|
67
71
|
}
|
|
68
72
|
function createObserver(first, second, third) {
|
|
69
73
|
let observer = { next: noop };
|
|
@@ -73,25 +77,44 @@ function createObserver(first, second, third) {
|
|
|
73
77
|
complete: getObservableCallback(third)
|
|
74
78
|
};
|
|
75
79
|
else if (typeof first === "object") {
|
|
76
|
-
|
|
77
|
-
observer.
|
|
78
|
-
observer.
|
|
80
|
+
const object = first;
|
|
81
|
+
observer.complete = getObservableCallback(object?.complete);
|
|
82
|
+
observer.error = getObservableCallback(object?.error);
|
|
83
|
+
observer.next = getObservableCallback(object?.next);
|
|
79
84
|
}
|
|
80
85
|
return observer;
|
|
81
86
|
}
|
|
82
|
-
function
|
|
83
|
-
|
|
84
|
-
state.active = false;
|
|
85
|
-
for (const [, observer] of state.subscriptions.values.to.any) if (emit) observer.complete?.();
|
|
86
|
-
state.subscriptions.clear();
|
|
87
|
-
state.observable?.deactivate();
|
|
88
|
-
state.observable = void 0;
|
|
87
|
+
function deactivateBeacon() {
|
|
88
|
+
closeBeacon(this[BEACON_SYMBOL], false);
|
|
89
89
|
}
|
|
90
|
-
function
|
|
90
|
+
function deactiveateObservable() {
|
|
91
|
+
this[BEACON_SYMBOL].active = false;
|
|
92
|
+
}
|
|
93
|
+
function emitBeaconError(error, finish) {
|
|
94
|
+
updateBeacon(this, BEACON_TYPE_ERROR, error, finish ?? false);
|
|
95
|
+
}
|
|
96
|
+
function emitBeaconValue(value, finish) {
|
|
97
|
+
updateBeacon(this, BEACON_TYPE_NEXT, value, finish ?? false);
|
|
98
|
+
}
|
|
99
|
+
function finishBeacon() {
|
|
100
|
+
closeBeacon(this[BEACON_SYMBOL], true);
|
|
101
|
+
}
|
|
102
|
+
function getBeaconActive() {
|
|
103
|
+
return this[BEACON_SYMBOL].active;
|
|
104
|
+
}
|
|
105
|
+
function getBeaconObservable() {
|
|
106
|
+
const state = this[BEACON_SYMBOL];
|
|
91
107
|
if (!state.active) throw new Error(BEACON_MESSAGE_RETRIEVE);
|
|
92
|
-
state.observable ??=
|
|
108
|
+
state.observable ??= new Observable(state);
|
|
93
109
|
return state.observable;
|
|
94
110
|
}
|
|
111
|
+
function getBeaconValue() {
|
|
112
|
+
return this[BEACON_SYMBOL].value;
|
|
113
|
+
}
|
|
114
|
+
function getObservableActive() {
|
|
115
|
+
const state = this[BEACON_SYMBOL];
|
|
116
|
+
return state.beacon.active && state.active;
|
|
117
|
+
}
|
|
95
118
|
function getObservableCallback(value) {
|
|
96
119
|
return typeof value === "function" ? value : noop;
|
|
97
120
|
}
|
|
@@ -105,7 +128,7 @@ function isBeacon(value) {
|
|
|
105
128
|
return isBeaconInstance(BEACON_NAME, value);
|
|
106
129
|
}
|
|
107
130
|
function isBeaconInstance(name, value) {
|
|
108
|
-
return
|
|
131
|
+
return typeof value === "object" && value !== null && BEACON_PROPERTY in value && value[BEACON_PROPERTY] === name;
|
|
109
132
|
}
|
|
110
133
|
/**
|
|
111
134
|
* Is the value a beacon subscription?
|
|
@@ -125,8 +148,10 @@ function isBeaconSubscription(value) {
|
|
|
125
148
|
function isObservable(value) {
|
|
126
149
|
return isBeaconInstance(BEACON_OBSERVABLE, value);
|
|
127
150
|
}
|
|
128
|
-
function subscribeToObservable(
|
|
151
|
+
function subscribeToObservable(first, second, third) {
|
|
152
|
+
const state = this[BEACON_SYMBOL];
|
|
129
153
|
if (!state.beacon.active || !state.active) throw new Error(BEACON_MESSAGE_SUBSCRIBE);
|
|
154
|
+
state.beacon.subscriptions ??= subscriptions({ property: beaconSubscription });
|
|
130
155
|
const observer = createObserver(first, second, third);
|
|
131
156
|
const [subscription] = state.beacon.subscriptions.create({
|
|
132
157
|
isActive: () => state.beacon.active && state.active,
|
|
@@ -135,20 +160,20 @@ function subscribeToObservable(state, first, second, third) {
|
|
|
135
160
|
observer.next?.(state.beacon.value);
|
|
136
161
|
return subscription;
|
|
137
162
|
}
|
|
138
|
-
function updateBeacon(
|
|
163
|
+
function updateBeacon(instance, type, value, finish) {
|
|
164
|
+
const state = instance[BEACON_SYMBOL];
|
|
139
165
|
if (!state.active) return;
|
|
140
166
|
if (type === BEACON_TYPE_NEXT) {
|
|
141
167
|
if (state.options.equal(state.value, value)) return;
|
|
142
168
|
state.value = value;
|
|
143
169
|
}
|
|
144
|
-
|
|
145
|
-
if (
|
|
170
|
+
const subscriptions = state.subscriptions?.values.to.any;
|
|
171
|
+
if (subscriptions != null && subscriptions.size > 0) for (const [, observer] of subscriptions) observer[type]?.(value);
|
|
172
|
+
if (finish === true) closeBeacon(state, true);
|
|
146
173
|
}
|
|
147
174
|
const BEACON_MESSAGE_RETRIEVE = "Cannot retrieve observable from a closed beacon";
|
|
148
175
|
const BEACON_MESSAGE_SUBSCRIBE = "Cannot subscribe to a closed observable";
|
|
149
|
-
const
|
|
150
|
-
const BEACON_NAME = "beacon";
|
|
151
|
-
const BEACON_OBSERVABLE = "observable";
|
|
176
|
+
const BEACON_SYMBOL = Symbol(BEACON_PROPERTY);
|
|
152
177
|
const BEACON_TYPE_ERROR = "error";
|
|
153
178
|
const BEACON_TYPE_NEXT = "next";
|
|
154
179
|
const beaconSubscription = {
|