@oscarpalmer/atoms 0.212.0 → 0.214.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 +1 -1
- package/dist/array/difference.mjs +3 -2
- package/dist/array/exists.d.mts +1 -1
- package/dist/array/exists.mjs +3 -2
- package/dist/array/filter.d.mts +1 -1
- package/dist/array/filter.mjs +1 -0
- package/dist/array/find.d.mts +1 -1
- package/dist/array/find.mjs +4 -3
- package/dist/array/first.d.mts +1 -1
- package/dist/array/flatten.d.mts +1 -1
- package/dist/array/group-by.d.mts +1 -1
- package/dist/array/index.d.mts +2 -2
- package/dist/array/insert.mjs +3 -2
- package/dist/array/intersection.mjs +3 -2
- package/dist/array/last.d.mts +1 -1
- package/dist/array/move.d.mts +1 -1
- package/dist/array/partition.d.mts +1 -1
- package/dist/array/partition.mjs +1 -0
- package/dist/array/push.mjs +3 -2
- package/dist/array/select.d.mts +10 -12
- package/dist/array/select.mjs +1 -0
- package/dist/array/single.d.mts +1 -1
- package/dist/array/single.mjs +1 -0
- package/dist/array/slice.d.mts +1 -1
- package/dist/array/slice.mjs +4 -5
- package/dist/array/sort.d.mts +4 -103
- package/dist/array/sort.mjs +6 -14
- package/dist/array/splice.mjs +3 -2
- package/dist/array/swap.d.mts +1 -1
- package/dist/array/to-map.d.mts +1 -1
- package/dist/array/to-record.d.mts +1 -1
- package/dist/array/to-set.d.mts +1 -1
- package/dist/array/toggle.d.mts +1 -1
- package/dist/array/union.mjs +3 -2
- package/dist/array/unique.d.mts +1 -1
- package/dist/array/unique.mjs +3 -2
- package/dist/array/update.d.mts +1 -1
- package/dist/beacon.d.mts +6 -92
- package/dist/beacon.mjs +6 -16
- package/dist/color/constants.d.mts +2 -2
- package/dist/color/constants.mjs +1 -1
- package/dist/color/index.d.mts +1 -1
- package/dist/color/instance.d.mts +1 -1
- package/dist/color/instance.mjs +0 -1
- package/dist/color/misc/alpha.d.mts +1 -1
- package/dist/color/misc/format.d.mts +1 -1
- package/dist/color/misc/get.d.mts +1 -1
- package/dist/color/misc/is.d.mts +2 -2
- package/dist/color/misc/is.mjs +1 -0
- package/dist/color/misc/state.d.mts +1 -1
- package/dist/color/space/hex.d.mts +1 -1
- package/dist/color/space/hsl.d.mts +1 -1
- package/dist/color/space/hwb.d.mts +1 -1
- package/dist/color/space/rgb.d.mts +1 -1
- package/dist/function/limit.d.mts +2 -2
- package/dist/function/limit.mjs +2 -1
- package/dist/function/once.d.mts +7 -3
- package/dist/function/once.mjs +5 -10
- package/dist/function/retry.d.mts +4 -14
- package/dist/function/retry.mjs +3 -15
- package/dist/herald.d.mts +2 -2
- package/dist/index.d.mts +466 -351
- package/dist/index.mjs +491 -439
- package/dist/internal/aborter.d.mts +1 -6
- package/dist/internal/aborter.mjs +3 -4
- package/dist/internal/array/callbacks.d.mts +3 -7
- package/dist/internal/array/chunk.mjs +2 -2
- package/dist/internal/array/find.d.mts +5 -23
- package/dist/internal/array/find.mjs +5 -9
- package/dist/internal/array/get.d.mts +1 -1
- package/dist/internal/array/group.d.mts +1 -1
- package/dist/internal/array/index-of.d.mts +1 -1
- package/dist/internal/array/index-of.mjs +4 -3
- package/dist/internal/array/insert.d.mts +2 -5
- package/dist/internal/array/insert.mjs +2 -4
- package/dist/internal/array/match.d.mts +2 -5
- package/dist/internal/array/match.mjs +10 -20
- package/dist/internal/array/overlap.d.mts +2 -10
- package/dist/internal/array/sets.d.mts +2 -5
- package/dist/internal/array/sets.mjs +5 -7
- package/dist/internal/function/assert.d.mts +5 -12
- package/dist/internal/function/assert.mjs +2 -2
- package/dist/internal/function/limit.d.mts +2 -37
- package/dist/internal/function/limit.mjs +4 -15
- package/dist/internal/function/memoize.d.mts +5 -70
- package/dist/internal/function/memoize.mjs +2 -5
- package/dist/internal/function/work.d.mts +16 -22
- package/dist/internal/function/work.mjs +1 -8
- package/dist/internal/herald.d.mts +3 -3
- package/dist/internal/herald.mjs +2 -1
- package/dist/internal/is.d.mts +1 -1
- package/dist/internal/math/aggregate.d.mts +2 -14
- package/dist/internal/math/aggregate.mjs +2 -5
- package/dist/internal/number.mjs +4 -7
- package/dist/internal/result/attempt.d.mts +1 -1
- package/dist/internal/result/misc.d.mts +1 -1
- package/dist/internal/string/case.mjs +6 -16
- package/dist/internal/string/misc.mjs +1 -3
- package/dist/internal/subscription.d.mts +1 -100
- package/dist/internal/subscription.mjs +3 -9
- package/dist/internal/value/compare.d.mts +4 -4
- package/dist/internal/value/compare.mjs +1 -1
- package/dist/internal/value/equal.d.mts +6 -57
- package/dist/internal/value/equal.mjs +5 -10
- package/dist/internal/value/get.d.mts +1 -1
- package/dist/internal/value/handlers.d.mts +2 -21
- package/dist/internal/value/has.d.mts +2 -2
- package/dist/internal/value/misc.d.mts +1 -1
- package/dist/internal/value/misc.mjs +8 -14
- package/dist/internal/value/set.d.mts +1 -1
- package/dist/internal/value/set.mjs +2 -2
- package/dist/is.mjs +3 -3
- package/dist/logger.d.mts +3 -70
- package/dist/logger.mjs +2 -5
- package/dist/math.d.mts +1 -1
- package/dist/math.mjs +2 -1
- package/dist/models/aborter.model.d.mts +12 -0
- package/dist/models/aborter.model.mjs +5 -0
- package/dist/models/array/array.find.model.d.mts +22 -0
- package/dist/models/array/array.find.model.mjs +8 -0
- package/dist/models/array/array.match.model.d.mts +14 -0
- package/dist/models/array/array.match.model.mjs +14 -0
- package/dist/models/array/array.misc.model.d.mts +36 -0
- package/dist/models/array/array.misc.model.mjs +12 -0
- package/dist/models/array/array.sort.model.d.mts +122 -0
- package/dist/models/array/array.sort.model.mjs +12 -0
- package/dist/models/beacon.model.d.mts +119 -0
- package/dist/models/beacon.model.mjs +16 -0
- package/dist/{color/models.d.mts → models/color.model.d.mts} +4 -4
- package/dist/models/function/assert.model.d.mts +13 -0
- package/dist/models/function/assert.model.mjs +4 -0
- package/dist/models/function/limiter.model.d.mts +71 -0
- package/dist/models/function/limiter.model.mjs +15 -0
- package/dist/models/function/memoize.model.d.mts +88 -0
- package/dist/models/function/memoize.model.mjs +7 -0
- package/dist/models/function/once.model.d.mts +76 -0
- package/dist/models/function/once.model.mjs +9 -0
- package/dist/models/function/retry.model.d.mts +17 -0
- package/dist/models/function/retry.model.mjs +17 -0
- package/dist/models/function/work.model.d.mts +20 -0
- package/dist/models/function/work.model.mjs +11 -0
- package/dist/{internal/models → models}/herald.model.d.mts +3 -3
- package/dist/{internal/models → models}/herald.model.mjs +2 -2
- package/dist/{models.d.mts → models/index.d.mts} +8 -50
- package/dist/models/logger.model.d.mts +83 -0
- package/dist/models/logger.model.mjs +7 -0
- package/dist/models/math.model.d.mts +16 -0
- package/dist/models/math.model.mjs +7 -0
- package/dist/models/misc.model.d.mts +10 -0
- package/dist/models/misc.model.mjs +11 -0
- package/dist/{internal/models → models}/plan.model.d.mts +17 -15
- package/dist/{internal/models → models}/plan.model.mjs +1 -1
- package/dist/models/promise.model.d.mts +119 -0
- package/dist/models/promise.model.mjs +47 -0
- package/dist/models/query.model.d.mts +9 -0
- package/dist/models/query.model.mjs +14 -0
- package/dist/models/queue.model.d.mts +251 -0
- package/dist/models/queue.model.mjs +29 -0
- package/dist/models/random.model.d.mts +6 -0
- package/dist/models/random.model.mjs +7 -0
- package/dist/{internal/models → models}/result.model.d.mts +10 -2
- package/dist/models/string/string.case.model.d.mts +19 -0
- package/dist/models/string/string.case.model.mjs +14 -0
- package/dist/models/string/string.fuzzy.model.d.mts +108 -0
- package/dist/models/string/string.fuzzy.model.mjs +9 -0
- package/dist/models/string/string.misc.model.d.mts +13 -0
- package/dist/models/string/string.misc.model.mjs +13 -0
- package/dist/models/string/string.normalize.model.d.mts +85 -0
- package/dist/models/string/string.normalize.model.mjs +43 -0
- package/dist/models/string/string.template.model.d.mts +50 -0
- package/dist/models/string/string.template.model.mjs +5 -0
- package/dist/models/subscription.model.d.mts +127 -0
- package/dist/models/subscription.model.mjs +10 -0
- package/dist/models/value/value.clone.model.d.mts +56 -0
- package/dist/models/value/value.clone.model.mjs +24 -0
- package/dist/models/value/value.diff.model.d.mts +61 -0
- package/dist/models/value/value.diff.model.mjs +6 -0
- package/dist/models/value/value.equal.model.d.mts +76 -0
- package/dist/models/value/value.equal.model.mjs +9 -0
- package/dist/models/value/value.handler.model.d.mts +27 -0
- package/dist/models/value/value.handler.model.mjs +1 -0
- package/dist/models/value/value.merge.model.d.mts +82 -0
- package/dist/models/value/value.merge.model.mjs +5 -0
- package/dist/models/value/value.misc.model.d.mts +33 -0
- package/dist/models/value/value.misc.model.mjs +12 -0
- package/dist/models/value/value.transform.model.d.mts +28 -0
- package/dist/models/value/value.transform.model.mjs +4 -0
- package/dist/plan/generate.d.mts +3 -2
- package/dist/plan/generate.mjs +14 -10
- package/dist/plan/index.d.mts +1 -1
- package/dist/plan/index.mjs +2 -2
- package/dist/plan/is.d.mts +31 -2
- package/dist/plan/is.mjs +45 -1
- package/dist/plan/misc.d.mts +21 -2
- package/dist/plan/misc.mjs +32 -2
- package/dist/plan/models.d.mts +1 -1
- package/dist/plan/result.d.mts +7 -7
- package/dist/plan/result.mjs +6 -6
- package/dist/plan/run.d.mts +5 -5
- package/dist/plan/run.mjs +6 -6
- package/dist/promise/delay.d.mts +1 -1
- package/dist/promise/delay.mjs +2 -1
- package/dist/promise/helpers.d.mts +2 -2
- package/dist/promise/helpers.mjs +6 -6
- package/dist/promise/index.d.mts +2 -2
- package/dist/promise/index.mjs +1 -1
- package/dist/promise/misc.d.mts +3 -3
- package/dist/promise/misc.mjs +7 -4
- package/dist/promise/models.d.mts +2 -106
- package/dist/promise/models.mjs +1 -35
- package/dist/promise/timed.d.mts +2 -2
- package/dist/promise/timed.mjs +3 -3
- package/dist/query.d.mts +1 -1
- package/dist/query.mjs +5 -15
- package/dist/queue.d.mts +6 -200
- package/dist/queue.mjs +9 -34
- package/dist/random.mjs +2 -5
- package/dist/result/match.d.mts +1 -1
- package/dist/result/match.mjs +27 -15
- package/dist/result/misc.d.mts +1 -1
- package/dist/result/work/flow.d.mts +13 -21
- package/dist/result/work/flow.mjs +0 -1
- package/dist/result/work/pipe.d.mts +2 -2
- package/dist/result/work/pipe.mjs +0 -1
- package/dist/string/fuzzy.d.mts +5 -87
- package/dist/string/fuzzy.mjs +6 -11
- package/dist/string/index.mjs +6 -8
- package/dist/string/match.mjs +4 -6
- package/dist/string/normalize.d.mts +4 -40
- package/dist/string/normalize.mjs +9 -48
- package/dist/string/template.d.mts +5 -43
- package/dist/string/template.mjs +1 -2
- package/dist/subscription.d.mts +2 -1
- package/dist/value/clone.d.mts +6 -42
- package/dist/value/clone.mjs +10 -30
- package/dist/value/collection.mjs +2 -0
- package/dist/value/diff.d.mts +3 -44
- package/dist/value/diff.mjs +1 -3
- package/dist/value/freeze.d.mts +1 -5
- package/dist/value/index.d.mts +4 -3
- package/dist/value/merge.d.mts +6 -64
- package/dist/value/merge.mjs +8 -8
- package/dist/value/omit.d.mts +1 -1
- package/dist/value/pick.d.mts +1 -1
- package/dist/value/shake.d.mts +4 -6
- package/dist/value/smush.d.mts +4 -6
- package/dist/value/smush.mjs +2 -2
- package/dist/value/transform.d.mts +6 -22
- package/dist/value/transform.mjs +1 -1
- package/dist/value/unsmush.d.mts +4 -10
- package/package.json +12 -3
- package/dist/internal/plan.d.mts +0 -45
- package/dist/internal/plan.mjs +0 -70
- package/dist/promise/constants.d.mts +0 -17
- package/dist/promise/constants.mjs +0 -15
- /package/dist/{color/models.mjs → models/color.model.mjs} +0 -0
- /package/dist/{internal/models/result.model.mjs → models/index.mjs} +0 -0
- /package/dist/{models.mjs → models/result.model.mjs} +0 -0
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
import { GenericCallback } from "../../models.mjs";
|
|
2
|
-
import { UnwrapValue } from "
|
|
1
|
+
import { GenericCallback } from "../../models/index.mjs";
|
|
2
|
+
import { UnwrapValue } from "../../models/result.model.mjs";
|
|
3
|
+
import { AsyncFlow, Flow } from "../../models/function/work.model.mjs";
|
|
3
4
|
//#region src/internal/function/work.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* A synchronous _Flow_, a function that pipe a value through a series of functions
|
|
6
|
-
*/
|
|
7
|
-
export type Flow<Callback extends GenericCallback, Value> = (...args: Parameters<Callback>) => UnwrapValue<Value>;
|
|
8
|
-
/**
|
|
9
|
-
* An asynchronous _Flow_, a function that pipes a value through a series of functions
|
|
10
|
-
*/
|
|
11
|
-
export type FlowPromise<Callback extends GenericCallback, Value> = (...args: Parameters<Callback>) => Promise<UnwrapValue<Value>>;
|
|
12
5
|
/**
|
|
13
6
|
* Create an asynchronous _Flow_, a function that pipes values through a function
|
|
14
7
|
*
|
|
@@ -16,7 +9,7 @@ export type FlowPromise<Callback extends GenericCallback, Value> = (...args: Par
|
|
|
16
9
|
*
|
|
17
10
|
* @returns _Flow_ function
|
|
18
11
|
*/
|
|
19
|
-
export declare function asyncFlow<Fn extends GenericCallback>(fn: Fn):
|
|
12
|
+
export declare function asyncFlow<Fn extends GenericCallback>(fn: Fn): AsyncFlow<Fn, ReturnType<Fn>>;
|
|
20
13
|
/**
|
|
21
14
|
* Create an asynchronous _Flow_, a function that pipes values through a series of functions
|
|
22
15
|
*
|
|
@@ -24,7 +17,7 @@ export declare function asyncFlow<Fn extends GenericCallback>(fn: Fn): FlowPromi
|
|
|
24
17
|
*
|
|
25
18
|
* @returns _Flow_ function
|
|
26
19
|
*/
|
|
27
|
-
export declare function asyncFlow<First extends GenericCallback, Second>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second):
|
|
20
|
+
export declare function asyncFlow<First extends GenericCallback, Second>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second): AsyncFlow<First, Second>;
|
|
28
21
|
/**
|
|
29
22
|
* Create an asynchronous _Flow_, a function that pipes values through a series of functions
|
|
30
23
|
*
|
|
@@ -32,7 +25,7 @@ export declare function asyncFlow<First extends GenericCallback, Second>(first:
|
|
|
32
25
|
*
|
|
33
26
|
* @returns _Flow_ function
|
|
34
27
|
*/
|
|
35
|
-
export declare function asyncFlow<First extends GenericCallback, Second, Third>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second, third: (value: Awaited<UnwrapValue<Second>>) => Third):
|
|
28
|
+
export declare function asyncFlow<First extends GenericCallback, Second, Third>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second, third: (value: Awaited<UnwrapValue<Second>>) => Third): AsyncFlow<First, Third>;
|
|
36
29
|
/**
|
|
37
30
|
* Create an asynchronous _Flow_, a function that pipes values through a series of functions
|
|
38
31
|
*
|
|
@@ -40,7 +33,7 @@ export declare function asyncFlow<First extends GenericCallback, Second, Third>(
|
|
|
40
33
|
*
|
|
41
34
|
* @returns _Flow_ function
|
|
42
35
|
*/
|
|
43
|
-
export declare function asyncFlow<First extends GenericCallback, Second, Third, Fourth>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second, third: (value: Awaited<UnwrapValue<Second>>) => Third, fourth: (value: Awaited<UnwrapValue<Third>>) => Fourth):
|
|
36
|
+
export declare function asyncFlow<First extends GenericCallback, Second, Third, Fourth>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second, third: (value: Awaited<UnwrapValue<Second>>) => Third, fourth: (value: Awaited<UnwrapValue<Third>>) => Fourth): AsyncFlow<First, Fourth>;
|
|
44
37
|
/**
|
|
45
38
|
* Create an asynchronous _Flow_, a function that pipes values through a series of functions
|
|
46
39
|
*
|
|
@@ -48,7 +41,7 @@ export declare function asyncFlow<First extends GenericCallback, Second, Third,
|
|
|
48
41
|
*
|
|
49
42
|
* @returns _Flow_ function
|
|
50
43
|
*/
|
|
51
|
-
export declare function asyncFlow<First extends GenericCallback, Second, Third, Fourth, Fifth>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second, third: (value: Awaited<UnwrapValue<Second>>) => Third, fourth: (value: Awaited<UnwrapValue<Third>>) => Fourth, fifth: (value: Awaited<UnwrapValue<Fourth>>) => Fifth):
|
|
44
|
+
export declare function asyncFlow<First extends GenericCallback, Second, Third, Fourth, Fifth>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second, third: (value: Awaited<UnwrapValue<Second>>) => Third, fourth: (value: Awaited<UnwrapValue<Third>>) => Fourth, fifth: (value: Awaited<UnwrapValue<Fourth>>) => Fifth): AsyncFlow<First, Fifth>;
|
|
52
45
|
/**
|
|
53
46
|
* Create an asynchronous _Flow_, a function that pipes values through a series of functions
|
|
54
47
|
*
|
|
@@ -56,7 +49,7 @@ export declare function asyncFlow<First extends GenericCallback, Second, Third,
|
|
|
56
49
|
*
|
|
57
50
|
* @returns _Flow_ function
|
|
58
51
|
*/
|
|
59
|
-
export declare function asyncFlow<First extends GenericCallback, Second, Third, Fourth, Fifth, Sixth>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second, third: (value: Awaited<UnwrapValue<Second>>) => Third, fourth: (value: Awaited<UnwrapValue<Third>>) => Fourth, fifth: (value: Awaited<UnwrapValue<Fourth>>) => Fifth, sixth: (value: Awaited<UnwrapValue<Fifth>>) => Sixth):
|
|
52
|
+
export declare function asyncFlow<First extends GenericCallback, Second, Third, Fourth, Fifth, Sixth>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second, third: (value: Awaited<UnwrapValue<Second>>) => Third, fourth: (value: Awaited<UnwrapValue<Third>>) => Fourth, fifth: (value: Awaited<UnwrapValue<Fourth>>) => Fifth, sixth: (value: Awaited<UnwrapValue<Fifth>>) => Sixth): AsyncFlow<First, Sixth>;
|
|
60
53
|
/**
|
|
61
54
|
* Create an asynchronous _Flow_, a function that pipes values through a series of functions
|
|
62
55
|
*
|
|
@@ -64,7 +57,7 @@ export declare function asyncFlow<First extends GenericCallback, Second, Third,
|
|
|
64
57
|
*
|
|
65
58
|
* @returns _Flow_ function
|
|
66
59
|
*/
|
|
67
|
-
export declare function asyncFlow<First extends GenericCallback, Second, Third, Fourth, Fifth, Sixth, Seventh>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second, third: (value: Awaited<UnwrapValue<Second>>) => Third, fourth: (value: Awaited<UnwrapValue<Third>>) => Fourth, fifth: (value: Awaited<UnwrapValue<Fourth>>) => Fifth, sixth: (value: Awaited<UnwrapValue<Fifth>>) => Sixth, seventh: (value: Awaited<UnwrapValue<Sixth>>) => Seventh):
|
|
60
|
+
export declare function asyncFlow<First extends GenericCallback, Second, Third, Fourth, Fifth, Sixth, Seventh>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second, third: (value: Awaited<UnwrapValue<Second>>) => Third, fourth: (value: Awaited<UnwrapValue<Third>>) => Fourth, fifth: (value: Awaited<UnwrapValue<Fourth>>) => Fifth, sixth: (value: Awaited<UnwrapValue<Fifth>>) => Sixth, seventh: (value: Awaited<UnwrapValue<Sixth>>) => Seventh): AsyncFlow<First, Seventh>;
|
|
68
61
|
/**
|
|
69
62
|
* Create an asynchronous _Flow_, a function that pipes values through a series of functions
|
|
70
63
|
*
|
|
@@ -72,7 +65,7 @@ export declare function asyncFlow<First extends GenericCallback, Second, Third,
|
|
|
72
65
|
*
|
|
73
66
|
* @returns _Flow_ function
|
|
74
67
|
*/
|
|
75
|
-
export declare function asyncFlow<First extends GenericCallback, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second, third: (value: Awaited<UnwrapValue<Second>>) => Third, fourth: (value: Awaited<UnwrapValue<Third>>) => Fourth, fifth: (value: Awaited<UnwrapValue<Fourth>>) => Fifth, sixth: (value: Awaited<UnwrapValue<Fifth>>) => Sixth, seventh: (value: Awaited<UnwrapValue<Sixth>>) => Seventh, eighth: (value: Awaited<UnwrapValue<Seventh>>) => Eighth):
|
|
68
|
+
export declare function asyncFlow<First extends GenericCallback, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second, third: (value: Awaited<UnwrapValue<Second>>) => Third, fourth: (value: Awaited<UnwrapValue<Third>>) => Fourth, fifth: (value: Awaited<UnwrapValue<Fourth>>) => Fifth, sixth: (value: Awaited<UnwrapValue<Fifth>>) => Sixth, seventh: (value: Awaited<UnwrapValue<Sixth>>) => Seventh, eighth: (value: Awaited<UnwrapValue<Seventh>>) => Eighth): AsyncFlow<First, Eighth>;
|
|
76
69
|
/**
|
|
77
70
|
* Create an asynchronous _Flow_, a function that pipes values through a series of functions
|
|
78
71
|
*
|
|
@@ -80,7 +73,7 @@ export declare function asyncFlow<First extends GenericCallback, Second, Third,
|
|
|
80
73
|
*
|
|
81
74
|
* @returns _Flow_ function
|
|
82
75
|
*/
|
|
83
|
-
export declare function asyncFlow<First extends GenericCallback, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second, third: (value: Awaited<UnwrapValue<Second>>) => Third, fourth: (value: Awaited<UnwrapValue<Third>>) => Fourth, fifth: (value: Awaited<UnwrapValue<Fourth>>) => Fifth, sixth: (value: Awaited<UnwrapValue<Fifth>>) => Sixth, seventh: (value: Awaited<UnwrapValue<Sixth>>) => Seventh, eighth: (value: Awaited<UnwrapValue<Seventh>>) => Eighth, ninth: (value: Awaited<UnwrapValue<Eighth>>) => Ninth):
|
|
76
|
+
export declare function asyncFlow<First extends GenericCallback, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second, third: (value: Awaited<UnwrapValue<Second>>) => Third, fourth: (value: Awaited<UnwrapValue<Third>>) => Fourth, fifth: (value: Awaited<UnwrapValue<Fourth>>) => Fifth, sixth: (value: Awaited<UnwrapValue<Fifth>>) => Sixth, seventh: (value: Awaited<UnwrapValue<Sixth>>) => Seventh, eighth: (value: Awaited<UnwrapValue<Seventh>>) => Eighth, ninth: (value: Awaited<UnwrapValue<Eighth>>) => Ninth): AsyncFlow<First, Ninth>;
|
|
84
77
|
/**
|
|
85
78
|
* Create an asynchronous _Flow_, a function that pipes values through a series of functions
|
|
86
79
|
*
|
|
@@ -88,7 +81,7 @@ export declare function asyncFlow<First extends GenericCallback, Second, Third,
|
|
|
88
81
|
*
|
|
89
82
|
* @returns _Flow_ function
|
|
90
83
|
*/
|
|
91
|
-
export declare function asyncFlow<First extends GenericCallback, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth, Tenth>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second, third: (value: Awaited<UnwrapValue<Second>>) => Third, fourth: (value: Awaited<UnwrapValue<Third>>) => Fourth, fifth: (value: Awaited<UnwrapValue<Fourth>>) => Fifth, sixth: (value: Awaited<UnwrapValue<Fifth>>) => Sixth, seventh: (value: Awaited<UnwrapValue<Sixth>>) => Seventh, eighth: (value: Awaited<UnwrapValue<Seventh>>) => Eighth, ninth: (value: Awaited<UnwrapValue<Eighth>>) => Ninth, tenth: (value: Awaited<UnwrapValue<Ninth>>) => Tenth):
|
|
84
|
+
export declare function asyncFlow<First extends GenericCallback, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth, Tenth>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second, third: (value: Awaited<UnwrapValue<Second>>) => Third, fourth: (value: Awaited<UnwrapValue<Third>>) => Fourth, fifth: (value: Awaited<UnwrapValue<Fourth>>) => Fifth, sixth: (value: Awaited<UnwrapValue<Fifth>>) => Sixth, seventh: (value: Awaited<UnwrapValue<Sixth>>) => Seventh, eighth: (value: Awaited<UnwrapValue<Seventh>>) => Eighth, ninth: (value: Awaited<UnwrapValue<Eighth>>) => Ninth, tenth: (value: Awaited<UnwrapValue<Ninth>>) => Tenth): AsyncFlow<First, Tenth>;
|
|
92
85
|
/**
|
|
93
86
|
* Create an asynchronous _Flow_, a function that pipes values through a series of functions
|
|
94
87
|
*
|
|
@@ -96,7 +89,7 @@ export declare function asyncFlow<First extends GenericCallback, Second, Third,
|
|
|
96
89
|
*
|
|
97
90
|
* @returns _Flow_ function
|
|
98
91
|
*/
|
|
99
|
-
export declare function asyncFlow<Fn extends GenericCallback>(fn: Fn, ...fns: Array<(value: Awaited<UnwrapValue<ReturnType<Fn>>>) => unknown>):
|
|
92
|
+
export declare function asyncFlow<Fn extends GenericCallback>(fn: Fn, ...fns: Array<(value: Awaited<UnwrapValue<ReturnType<Fn>>>) => unknown>): AsyncFlow<Fn, ReturnType<Fn>>;
|
|
100
93
|
/**
|
|
101
94
|
* Create an asynchronous _Flow_, a function that pipes values through a series of functions
|
|
102
95
|
*
|
|
@@ -375,4 +368,5 @@ export declare namespace flow {
|
|
|
375
368
|
export declare namespace pipe {
|
|
376
369
|
export var async: typeof asyncPipe;
|
|
377
370
|
}
|
|
378
|
-
//#endregion
|
|
371
|
+
//#endregion
|
|
372
|
+
export type { AsyncFlow, Flow };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isError, isOk } from "../result/misc.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { WORK_MESSAGE_FLOW_PROMISE, WORK_MESSAGE_NESTING, WORK_MESSAGE_PIPE_PROMISE, assertFlowFunctions, assertPipeFunctions } from "../../models/function/work.model.mjs";
|
|
3
3
|
//#region src/internal/function/work.ts
|
|
4
4
|
function asyncFlow(...fns) {
|
|
5
5
|
assertFlowFunctions(fns);
|
|
@@ -50,13 +50,6 @@ function work(initial, functions, flow) {
|
|
|
50
50
|
}
|
|
51
51
|
return transformed;
|
|
52
52
|
}
|
|
53
|
-
const WORK_MESSAGE_FLOW_ARRAY = "Flow expected to receive an array of functions";
|
|
54
|
-
const WORK_MESSAGE_FLOW_PROMISE = "Synchronous Flow received a promise. Use `flow.async` instead.";
|
|
55
|
-
const WORK_MESSAGE_NESTING = "Return values are too deeply nested.";
|
|
56
|
-
const WORK_MESSAGE_PIPE_ARRAY = "Pipe expected to receive an array of functions";
|
|
57
|
-
const WORK_MESSAGE_PIPE_PROMISE = "Synchronous Pipe received a promise. Use `pipe.async` instead.";
|
|
58
|
-
const assertFlowFunctions = assert.condition((value) => Array.isArray(value) && value.every((item) => typeof item === "function"), WORK_MESSAGE_FLOW_ARRAY, TypeError);
|
|
59
|
-
const assertPipeFunctions = assert.condition((value) => Array.isArray(value) && value.every((item) => typeof item === "function"), WORK_MESSAGE_PIPE_ARRAY, TypeError);
|
|
60
53
|
flow.async = asyncFlow;
|
|
61
54
|
pipe.async = asyncPipe;
|
|
62
55
|
//#endregion
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { GenericCallback } from "../models.mjs";
|
|
2
|
-
import { Subscription } from "
|
|
3
|
-
import { Herald, HeraldEvents, HeraldOptions } from "
|
|
1
|
+
import { GenericCallback } from "../models/index.mjs";
|
|
2
|
+
import { Subscription } from "../models/subscription.model.mjs";
|
|
3
|
+
import { Herald, HeraldEvents, HeraldOptions } from "../models/herald.model.mjs";
|
|
4
4
|
//#region src/internal/herald.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* Create a _Herald_ for announcing named events
|
package/dist/internal/herald.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isPlainObject } from "./is.mjs";
|
|
2
|
+
import "../models/subscription.model.mjs";
|
|
2
3
|
import { isSubscription, subscriptions } from "./subscription.mjs";
|
|
3
|
-
import { HERALD_MESSAGE_ARRAY, HERALD_MESSAGE_ONCREATE, HERALD_MESSAGE_PROPERTY, HERALD_NAME_EVENTS, HERALD_NAME_HERALD, HERALD_PROPERTY, HERALD_SYMBOL, heraldSubscription } from "
|
|
4
|
+
import { HERALD_MESSAGE_ARRAY, HERALD_MESSAGE_ONCREATE, HERALD_MESSAGE_PROPERTY, HERALD_NAME_EVENTS, HERALD_NAME_HERALD, HERALD_PROPERTY, HERALD_SYMBOL, heraldSubscription } from "../models/herald.model.mjs";
|
|
4
5
|
//#region src/internal/herald.ts
|
|
5
6
|
function Events(herald, state) {
|
|
6
7
|
for (const key of state.keys) Object.defineProperty(this, key, { value: (callback, signal) => herald.subscribe(key, callback, signal) });
|
package/dist/internal/is.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ArrayOrPlainObject, Constructor, Key, PlainObject, Primitive, TypedArray } from "../models.mjs";
|
|
1
|
+
import { ArrayOrPlainObject, Constructor, Key, PlainObject, Primitive, TypedArray } from "../models/index.mjs";
|
|
2
2
|
//#region src/internal/is.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Is the value an array or a plain object?
|
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
import { NumericalValues, PlainObject } from "../../models.mjs";
|
|
1
|
+
import { NumericalValues, PlainObject } from "../../models/index.mjs";
|
|
2
|
+
import { Aggregation, AggregationType, NonAverageAggregationType } from "../../models/math.model.mjs";
|
|
2
3
|
//#region src/internal/math/aggregate.d.ts
|
|
3
|
-
type Aggregation = {
|
|
4
|
-
array: boolean;
|
|
5
|
-
count: number;
|
|
6
|
-
first: boolean;
|
|
7
|
-
items?: Record<number, unknown[]>;
|
|
8
|
-
value: number;
|
|
9
|
-
};
|
|
10
|
-
export type AggregationType = "average" | "max" | "min" | "sum";
|
|
11
|
-
type NonAverageAggregationType = "max" | "min" | "sum";
|
|
12
4
|
export declare function aggregate(type: AggregationType, array: unknown[], key: unknown, first?: unknown): Aggregation;
|
|
13
5
|
export declare function getAggregateCallback(key: unknown): Function | undefined;
|
|
14
6
|
export declare function getAggregated(type: NonAverageAggregationType, array: unknown[], key?: unknown, first?: unknown): unknown;
|
|
@@ -140,8 +132,4 @@ export declare function min<Item extends PlainObject>(items: Item[], key: keyof
|
|
|
140
132
|
* @returns Minimum value, or `Number.NaN` if no minimum can be found
|
|
141
133
|
*/
|
|
142
134
|
export declare function min(values: number[]): number;
|
|
143
|
-
export declare const AGGREGATION_AVERAGE: AggregationType;
|
|
144
|
-
export declare const AGGREGATION_MAX = "max";
|
|
145
|
-
export declare const AGGREGATION_MIN = "min";
|
|
146
|
-
export declare const AGGREGATION_SUM = "sum";
|
|
147
135
|
//#endregion
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isNonNumber } from "../is.mjs";
|
|
2
|
+
import "../../models/math.model.mjs";
|
|
2
3
|
//#region src/internal/math/aggregate.ts
|
|
3
4
|
function aggregate(type, array, key, first) {
|
|
4
5
|
const length = Array.isArray(array) ? array.length : 0;
|
|
@@ -62,10 +63,6 @@ function max(array, key, first) {
|
|
|
62
63
|
function min(array, key, first) {
|
|
63
64
|
return getAggregated("min", array, key, first);
|
|
64
65
|
}
|
|
65
|
-
const AGGREGATION_AVERAGE = "average";
|
|
66
|
-
const AGGREGATION_MAX = "max";
|
|
67
|
-
const AGGREGATION_MIN = "min";
|
|
68
|
-
const AGGREGATION_SUM = "sum";
|
|
69
66
|
const aggregators = {
|
|
70
67
|
average: calculateSum,
|
|
71
68
|
max: getAbsoluteValue.bind(void 0, isMaxValue),
|
|
@@ -73,4 +70,4 @@ const aggregators = {
|
|
|
73
70
|
sum: calculateSum
|
|
74
71
|
};
|
|
75
72
|
//#endregion
|
|
76
|
-
export {
|
|
73
|
+
export { aggregate, getAggregateCallback, getAggregated, max, min };
|
package/dist/internal/number.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isNumber } from "./is.mjs";
|
|
2
|
+
import { EXPRESSION_NUMBER_BINARY, EXPRESSION_NUMBER_OCTAL, EXPRESSION_NUMBER_ZEROISH } from "../models/misc.model.mjs";
|
|
2
3
|
//#region src/internal/number.ts
|
|
3
4
|
/**
|
|
4
5
|
* Is the number between a minimum and maximum value?
|
|
@@ -59,14 +60,10 @@ function getNumber(value) {
|
|
|
59
60
|
if (typeof parsed !== "string") return getNumber(parsed);
|
|
60
61
|
const trimmed = parsed.trim();
|
|
61
62
|
if (trimmed.length === 0) return NaN;
|
|
62
|
-
if (
|
|
63
|
-
const isBinary =
|
|
64
|
-
if (isBinary ||
|
|
63
|
+
if (EXPRESSION_NUMBER_ZEROISH.test(parsed)) return 0;
|
|
64
|
+
const isBinary = EXPRESSION_NUMBER_BINARY.test(trimmed);
|
|
65
|
+
if (isBinary || EXPRESSION_NUMBER_OCTAL.test(trimmed)) return Number.parseInt(trimmed.slice(2), isBinary ? 2 : 8);
|
|
65
66
|
return Number(trimmed);
|
|
66
67
|
}
|
|
67
|
-
const NUMBER_EXPRESSION_BINARY = /^0b[01]+$/i;
|
|
68
|
-
const NUMBER_EXPRESSION_OCTAL = /^0o[0-7]+$/i;
|
|
69
|
-
const NUMBER_EXPRESSION_ZEROISH = /^\s*0+\s*$/;
|
|
70
|
-
const NUMBER_OCTAL_VALUE = 8;
|
|
71
68
|
//#endregion
|
|
72
69
|
export { between, clamp, getNumber };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { join, words } from "./misc.mjs";
|
|
2
2
|
import { memoize } from "../function/memoize.mjs";
|
|
3
|
+
import { STRING_CASE_CAMEL, STRING_CASE_KEBAB, STRING_CASE_PASCAL, STRING_CASE_SNAKE, STRING_EXPRESSION_ACRONYM, STRING_EXPRESSION_CAMEL_CASE, STRING_REPLACEMENT_CAMEL_CASE } from "../../models/string/string.case.model.mjs";
|
|
3
4
|
//#region src/internal/string/case.ts
|
|
4
5
|
/**
|
|
5
6
|
* Convert a string to camel case _(thisIsCamelCase)_
|
|
@@ -86,7 +87,7 @@ function toCaseCallback(value) {
|
|
|
86
87
|
const partsLength = parts.length;
|
|
87
88
|
const cased = [];
|
|
88
89
|
for (let partIndex = 0; partIndex < partsLength; partIndex += 1) {
|
|
89
|
-
const items = parts[partIndex].replace(STRING_EXPRESSION_ACRONYM, (full, one, two, three) => three ===
|
|
90
|
+
const items = parts[partIndex].replace(STRING_EXPRESSION_ACRONYM, (full, one, two, three) => three === "s" ? full : `${one}-${two}${three}`).replace(STRING_EXPRESSION_CAMEL_CASE, STRING_REPLACEMENT_CAMEL_CASE).split("-");
|
|
90
91
|
const itemsLength = items.length;
|
|
91
92
|
const partResult = [];
|
|
92
93
|
let itemCount = 0;
|
|
@@ -112,23 +113,12 @@ function upperCase(value) {
|
|
|
112
113
|
memoizedUpperCase ??= memoize((v) => v.toLocaleUpperCase());
|
|
113
114
|
return memoizedUpperCase.run(value);
|
|
114
115
|
}
|
|
115
|
-
const STRING_CASE_CAMEL = "camel";
|
|
116
|
-
const STRING_CASE_KEBAB = "kebab";
|
|
117
|
-
const STRING_CASE_PASCAL = "pascal";
|
|
118
|
-
const STRING_CASE_SNAKE = "snake";
|
|
119
|
-
const STRING_DELIMTER_EMPTY = "";
|
|
120
|
-
const STRING_DELIMITER_HYPHEN = "-";
|
|
121
|
-
const STRING_DELIMITER_UNDERSCORE = "_";
|
|
122
|
-
const STRING_EXPRESSION_CAMEL_CASE = /(\p{Ll})(\p{Lu})/gu;
|
|
123
|
-
const STRING_EXPRESSION_ACRONYM = /(\p{Lu}*)(\p{Lu})(\p{Ll}+)/gu;
|
|
124
|
-
const STRING_REPLACEMENT_CAMEL_CASE = "$1-$2";
|
|
125
|
-
const STRING_S = "s";
|
|
126
116
|
const caseMemoizers = {};
|
|
127
117
|
const delimiters = {
|
|
128
|
-
[STRING_CASE_CAMEL]:
|
|
129
|
-
[STRING_CASE_KEBAB]:
|
|
130
|
-
[STRING_CASE_PASCAL]:
|
|
131
|
-
[STRING_CASE_SNAKE]:
|
|
118
|
+
[STRING_CASE_CAMEL]: "",
|
|
119
|
+
[STRING_CASE_KEBAB]: "-",
|
|
120
|
+
[STRING_CASE_PASCAL]: "",
|
|
121
|
+
[STRING_CASE_SNAKE]: "_"
|
|
132
122
|
};
|
|
133
123
|
let memoizedCapitalize;
|
|
134
124
|
let memoizedLowerCase;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { STRING_EXPRESSION_IGNORED, STRING_EXPRESSION_WORDS } from "../../models/string/string.misc.model.mjs";
|
|
1
2
|
import { unwrap } from "../result/misc.mjs";
|
|
2
|
-
import "../../result/misc.mjs";
|
|
3
3
|
import { attempt } from "../result/attempt.mjs";
|
|
4
4
|
//#region src/internal/string/misc.ts
|
|
5
5
|
/**
|
|
@@ -77,7 +77,5 @@ function tryEncode(value) {
|
|
|
77
77
|
function words(value) {
|
|
78
78
|
return typeof value === "string" ? value.match(STRING_EXPRESSION_WORDS) ?? [] : [];
|
|
79
79
|
}
|
|
80
|
-
const STRING_EXPRESSION_IGNORED = /(^|\.)(__proto__|constructor|prototype)(\.|$)/i;
|
|
81
|
-
const STRING_EXPRESSION_WORDS = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
|
|
82
80
|
//#endregion
|
|
83
81
|
export { getString, ignoreKey, interpolate, join, tryDecode, tryEncode, words };
|
|
@@ -1,104 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Subscription, Subscriptions, SubscriptionsParameters } from "../models/subscription.model.mjs";
|
|
2
2
|
//#region src/internal/subscription.d.ts
|
|
3
|
-
export declare const SUBSCRIPTION_NAME = "subscription";
|
|
4
|
-
export type Subscription = {
|
|
5
|
-
/**
|
|
6
|
-
* Is the subscription active?
|
|
7
|
-
*/
|
|
8
|
-
get active(): boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Unsubscribe from changes
|
|
11
|
-
*/
|
|
12
|
-
unsubscribe(): void;
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Parameters for creating a subscription
|
|
16
|
-
*/
|
|
17
|
-
export type SubscriptionParameters = {
|
|
18
|
-
/**
|
|
19
|
-
* Is the owner of the subscription alive? _(defaults to `true`)_
|
|
20
|
-
*/
|
|
21
|
-
isActive?: () => boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Key used to identify a subscription _(defaults to `undefined`)_
|
|
24
|
-
*/
|
|
25
|
-
key?: unknown;
|
|
26
|
-
/**
|
|
27
|
-
* Signal used to abort the subscription _(defaults to `undefined`)_
|
|
28
|
-
*/
|
|
29
|
-
signal?: AbortSignal;
|
|
30
|
-
/**
|
|
31
|
-
* Value used to identify a subscription
|
|
32
|
-
*/
|
|
33
|
-
value: unknown;
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Property information for subscription identification
|
|
37
|
-
*/
|
|
38
|
-
export type SubscriptionProperty = {
|
|
39
|
-
/**
|
|
40
|
-
* Name of the property used to identify a subscription
|
|
41
|
-
*/
|
|
42
|
-
key: string;
|
|
43
|
-
/**
|
|
44
|
-
* Value of the property used to identify a subscription
|
|
45
|
-
*/
|
|
46
|
-
value: unknown;
|
|
47
|
-
};
|
|
48
|
-
export type Subscriptions<Value = unknown> = {
|
|
49
|
-
/**
|
|
50
|
-
* Items of the subscriptions store
|
|
51
|
-
*
|
|
52
|
-
* - `any` - Set of subscriptions _(for unkeyed subscriptions)_
|
|
53
|
-
* - `keyed` - Map of keys to sets of subscriptions _(for keyed subscriptions)_
|
|
54
|
-
*/
|
|
55
|
-
readonly items: Readonly<SubscriptionsItems>;
|
|
56
|
-
/**
|
|
57
|
-
* Values of the subscriptions store
|
|
58
|
-
*
|
|
59
|
-
* - `from.any` - Map of values to subscriptions _(for unkeyed subscriptions)_
|
|
60
|
-
* - `from.keyed` - Map of keys to maps of values to subscriptions _(for keyed subscriptions)_
|
|
61
|
-
* - `to.any` - Map of subscriptions to values _(for unkeyed subscriptions)_
|
|
62
|
-
* - `to.keyed` - Map of keys to maps of subscriptions to values _(for keyed subscriptions)_
|
|
63
|
-
*/
|
|
64
|
-
readonly values: Readonly<SubscriptionsValues<Value>>;
|
|
65
|
-
/**
|
|
66
|
-
* Clear all subscriptions
|
|
67
|
-
*/
|
|
68
|
-
clear(): void;
|
|
69
|
-
/**
|
|
70
|
-
* Create _(or retrieve)_ a subscription
|
|
71
|
-
*
|
|
72
|
-
* @param parameters Subscription parameters
|
|
73
|
-
* @returns Tuple holding subsccription and existing boolean
|
|
74
|
-
*/
|
|
75
|
-
create(parameters: SubscriptionParameters): [Subscription, boolean];
|
|
76
|
-
};
|
|
77
|
-
/**
|
|
78
|
-
* Parameters for creating a subscription store
|
|
79
|
-
*/
|
|
80
|
-
export type SubscriptionsParameters = {
|
|
81
|
-
/**
|
|
82
|
-
* Allow any or specific keys for subscriptions? _(defaults to `false`, which prevents keyed subscriptions)_
|
|
83
|
-
*/
|
|
84
|
-
keys?: boolean | Set<Key>;
|
|
85
|
-
/**
|
|
86
|
-
* Property information for subscription identification
|
|
87
|
-
*/
|
|
88
|
-
property?: SubscriptionProperty;
|
|
89
|
-
};
|
|
90
|
-
type SubscriptionsItems = {
|
|
91
|
-
any: Set<Subscription>;
|
|
92
|
-
keyed?: Map<Key, Set<Subscription>>;
|
|
93
|
-
};
|
|
94
|
-
type SubscriptionsValues<Value = unknown> = {
|
|
95
|
-
from: SubscriptionsValuesItem<Value, Subscription>;
|
|
96
|
-
to: SubscriptionsValuesItem<Subscription, Value>;
|
|
97
|
-
};
|
|
98
|
-
type SubscriptionsValuesItem<MapKey, MapValue> = {
|
|
99
|
-
any: Map<MapKey, MapValue>;
|
|
100
|
-
keyed?: Map<Key, Map<MapKey, MapValue>>;
|
|
101
|
-
};
|
|
102
3
|
/**
|
|
103
4
|
* Is the value a subscription?
|
|
104
5
|
*
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { isKey, isPlainObject } from "./is.mjs";
|
|
2
|
+
import { SUBSCRIPTION_DISALLOWED_KEY, SUBSCRIPTION_INVALID_KEY, SUBSCRIPTION_INVALID_VALUE, SUBSCRIPTION_NAME, SUBSCRIPTION_PROPERTY, SUBSCRIPTION_STORE, SUBSCRIPTION_SYMBOL } from "../models/subscription.model.mjs";
|
|
2
3
|
import { createAborter } from "./aborter.mjs";
|
|
3
4
|
//#region src/internal/subscription.ts
|
|
4
|
-
const SUBSCRIPTION_NAME = "subscription";
|
|
5
|
-
const SUBSCRIPTION_PROPERTY = "$subscription";
|
|
6
|
-
const SUBSCRIPTION_STORE = "subscriptions";
|
|
7
5
|
function Subscription(state, property, parameters) {
|
|
8
6
|
this[SUBSCRIPTION_SYMBOL] = state;
|
|
9
7
|
this[property.key] = property.value;
|
|
@@ -160,7 +158,7 @@ function isSubscription(value) {
|
|
|
160
158
|
return isSubscriptionInstance(value, SUBSCRIPTION_NAME);
|
|
161
159
|
}
|
|
162
160
|
function isSubscriptionInstance(value, name) {
|
|
163
|
-
return typeof value === "object" && value !== null &&
|
|
161
|
+
return typeof value === "object" && value !== null && "$subscription" in value && value["$subscription"] === name;
|
|
164
162
|
}
|
|
165
163
|
/**
|
|
166
164
|
* Is the value a subscriptions store?
|
|
@@ -211,9 +209,5 @@ function removeSubscription() {
|
|
|
211
209
|
function subscriptions(parameters) {
|
|
212
210
|
return new Subscriptions(parameters);
|
|
213
211
|
}
|
|
214
|
-
const SUBSCRIPTION_DISALLOWED_KEY = "Disallowed key for subscription";
|
|
215
|
-
const SUBSCRIPTION_INVALID_KEY = "Invalid key for subscription";
|
|
216
|
-
const SUBSCRIPTION_INVALID_VALUE = "A subscription requires a non-null value to identify it";
|
|
217
|
-
const SUBSCRIPTION_SYMBOL = Symbol(SUBSCRIPTION_PROPERTY);
|
|
218
212
|
//#endregion
|
|
219
|
-
export {
|
|
213
|
+
export { isSubscription, isSubscriptions, subscriptions };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Constructor } from "../../models.mjs";
|
|
2
|
-
import { CompareHandler } from "
|
|
1
|
+
import { Constructor } from "../../models/index.mjs";
|
|
2
|
+
import { CompareHandler } from "../../models/value/value.handler.model.mjs";
|
|
3
|
+
import { ComparisonHandler } from "../../models/value/value.misc.model.mjs";
|
|
3
4
|
//#region src/internal/value/compare.d.ts
|
|
4
|
-
type Comparator<Value = any> = (first: Value, second: Value) => number;
|
|
5
5
|
/**
|
|
6
6
|
* Compare two values _(for sorting purposes)_
|
|
7
7
|
*
|
|
@@ -26,7 +26,7 @@ export declare function deregisterComparator<Instance>(constructor: Constructor<
|
|
|
26
26
|
* @param constructor Class constructor
|
|
27
27
|
* @param handler Method name or comparison function _(defaults to `compare`)_
|
|
28
28
|
*/
|
|
29
|
-
export declare function registerComparator<Instance>(constructor: Constructor<Instance>, handler?: string |
|
|
29
|
+
export declare function registerComparator<Instance>(constructor: Constructor<Instance>, handler?: string | ComparisonHandler<Instance>): void;
|
|
30
30
|
export declare namespace compare {
|
|
31
31
|
export var deregister: typeof deregisterComparator;
|
|
32
32
|
export var handler: CompareHandler<number>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { max } from "../math/aggregate.mjs";
|
|
2
|
+
import { COMPARE_NAME } from "../../models/value/value.misc.model.mjs";
|
|
2
3
|
import { getString, words } from "../string/misc.mjs";
|
|
3
4
|
import { createCompareHandler } from "./handlers.mjs";
|
|
4
5
|
//#region src/internal/value/compare.ts
|
|
5
|
-
const COMPARE_NAME = "compare";
|
|
6
6
|
/**
|
|
7
7
|
* Compare two values _(for sorting purposes)_
|
|
8
8
|
*
|
|
@@ -1,60 +1,8 @@
|
|
|
1
|
-
import { Constructor } from "../../models.mjs";
|
|
2
|
-
import { CompareHandler } from "
|
|
1
|
+
import { Constructor } from "../../models/index.mjs";
|
|
2
|
+
import { CompareHandler } from "../../models/value/value.handler.model.mjs";
|
|
3
|
+
import { EqualOptions, Equalizer, EqualizerOptions } from "../../models/value/value.equal.model.mjs";
|
|
3
4
|
//#region src/internal/value/equal.d.ts
|
|
4
|
-
|
|
5
|
-
* Options for value equality comparison
|
|
6
|
-
*/
|
|
7
|
-
export type EqualOptions = {
|
|
8
|
-
/**
|
|
9
|
-
* When `true`, strings are compared case-insensitively
|
|
10
|
-
*/
|
|
11
|
-
ignoreCase?: boolean;
|
|
12
|
-
/**
|
|
13
|
-
* Keys _(or key expressions)_ to ignore when comparing objects
|
|
14
|
-
*/
|
|
15
|
-
ignoreKeys?: string | RegExp | Array<string | RegExp>;
|
|
16
|
-
/**
|
|
17
|
-
* Should `null` and `undefined` be considered equal?
|
|
18
|
-
*/
|
|
19
|
-
relaxedNullish?: boolean;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* An equalizer function for comparing values for equality, with predefined options
|
|
23
|
-
*
|
|
24
|
-
* Can be used to compare values, and register or deregister equality comparison handlers for specific classes
|
|
25
|
-
*/
|
|
26
|
-
type Equalizer = {
|
|
27
|
-
/**
|
|
28
|
-
* Are two strings equal?
|
|
29
|
-
*
|
|
30
|
-
* @param first First string
|
|
31
|
-
* @param second Second string
|
|
32
|
-
* @param ignoreCase If `true`, comparison will be case-insensitive
|
|
33
|
-
* @returns `true` if the strings are equal, otherwise `false`
|
|
34
|
-
*/
|
|
35
|
-
compare(first: string, second: string, ignoreCase?: boolean): boolean;
|
|
36
|
-
/**
|
|
37
|
-
* Are two values equal?
|
|
38
|
-
*
|
|
39
|
-
* @param first First value
|
|
40
|
-
* @param second Second value
|
|
41
|
-
* @returns `true` if the values are equal, otherwise `false`
|
|
42
|
-
*/
|
|
43
|
-
compare(first: unknown, second: unknown): boolean;
|
|
44
|
-
/**
|
|
45
|
-
* Deregister a equality comparison handler for a specific class
|
|
46
|
-
*
|
|
47
|
-
* @param constructor Class constructor
|
|
48
|
-
*/
|
|
49
|
-
deregister: <Instance>(constructor: Constructor<Instance>) => void;
|
|
50
|
-
/**
|
|
51
|
-
* Register a equality comparison function for a specific class
|
|
52
|
-
*
|
|
53
|
-
* @param constructor Class constructor
|
|
54
|
-
* @param handler Comparison function
|
|
55
|
-
*/
|
|
56
|
-
register: <Instance>(constructor: Constructor<Instance>, handler: (first: Instance, second: Instance) => boolean) => void;
|
|
57
|
-
};
|
|
5
|
+
declare function Equalizer(this: any, options: EqualizerOptions): void;
|
|
58
6
|
/**
|
|
59
7
|
* Deregister a equality comparison handler for a specific class
|
|
60
8
|
*
|
|
@@ -105,4 +53,5 @@ export declare namespace equal {
|
|
|
105
53
|
export var initialize: typeof initializeEqualizer;
|
|
106
54
|
export var register: typeof registerEqualizer;
|
|
107
55
|
}
|
|
108
|
-
//#endregion
|
|
56
|
+
//#endregion
|
|
57
|
+
export type { EqualOptions, Equalizer };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isNonPlainObject, isPlainObject, isPrimitive, isTypedArray } from "../is.mjs";
|
|
2
2
|
import { round } from "../math/misc.mjs";
|
|
3
3
|
import { createCompareHandler } from "./handlers.mjs";
|
|
4
|
+
import { EQUAL_ERROR_PROPERTIES, EQUAL_EXPRESSION_PROPERTIES, EQUAL_SYMBOL } from "../../models/value/value.equal.model.mjs";
|
|
4
5
|
//#region src/internal/value/equal.ts
|
|
5
6
|
function Equalizer(options) {
|
|
6
7
|
this[EQUAL_SYMBOL] = options;
|
|
@@ -60,9 +61,9 @@ function equalArray(first, second, options) {
|
|
|
60
61
|
const { length } = first;
|
|
61
62
|
if (length !== second.length) return false;
|
|
62
63
|
let offset = 0;
|
|
63
|
-
if (length >=
|
|
64
|
-
offset = round(length /
|
|
65
|
-
offset = offset >
|
|
64
|
+
if (length >= 100) {
|
|
65
|
+
offset = round(length / 10);
|
|
66
|
+
offset = offset > 100 ? 100 : offset;
|
|
66
67
|
for (let index = 0; index < offset; index += 1) if (!(equalValue(first[index], second[index], options) && equalValue(first[length - index - 1], second[length - index - 1], options))) return false;
|
|
67
68
|
}
|
|
68
69
|
const end = length - offset;
|
|
@@ -92,7 +93,7 @@ function equalPlainObject(first, second, options) {
|
|
|
92
93
|
firstKeys = firstKeys.filter((key) => filterKey(key, options));
|
|
93
94
|
secondKeys = secondKeys.filter((key) => filterKey(key, options));
|
|
94
95
|
}
|
|
95
|
-
const secondSet = secondKeys.length >=
|
|
96
|
+
const secondSet = secondKeys.length >= 16 ? new Set(secondKeys) : void 0;
|
|
96
97
|
const { length } = firstKeys;
|
|
97
98
|
if (length !== secondKeys.length) return false;
|
|
98
99
|
for (let index = 0; index < length; index += 1) {
|
|
@@ -169,12 +170,6 @@ function initializeEqualizer(options) {
|
|
|
169
170
|
function registerEqualizer(constructor, handler) {
|
|
170
171
|
equalHandler.base.register(constructor, handler);
|
|
171
172
|
}
|
|
172
|
-
const EQUAL_ARRAY_PEEK_PERCENTAGE = 10;
|
|
173
|
-
const EQUAL_ARRAY_THRESHOLD = 100;
|
|
174
|
-
const EQUAL_ERROR_PROPERTIES = ["name", "message"];
|
|
175
|
-
const EQUAL_EXPRESSION_PROPERTIES = ["source", "flags"];
|
|
176
|
-
const EQUAL_MINIMUM_LENGTH_FOR_SET = 16;
|
|
177
|
-
const EQUAL_SYMBOL = Symbol("equal");
|
|
178
173
|
const equalHandler = createCompareHandler(equal, { callback: Object.is });
|
|
179
174
|
equal.deregister = deregisterEqualizer;
|
|
180
175
|
equal.handler = equalHandler;
|
|
@@ -1,25 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GenericCallback } from "../../models/index.mjs";
|
|
2
|
+
import { BaseHandlerOptions, CompareHandler, ValueHandler } from "../../models/value/value.handler.model.mjs";
|
|
2
3
|
//#region src/internal/value/handlers.d.ts
|
|
3
|
-
type BaseHandler = {
|
|
4
|
-
handlers: WeakMap<WeakKey, string | GenericCallback>;
|
|
5
|
-
options: BaseHandlerOptions;
|
|
6
|
-
owner: GenericCallback;
|
|
7
|
-
deregister(constructor: Constructor): void;
|
|
8
|
-
get(first: unknown, second: unknown): string | GenericCallback | undefined;
|
|
9
|
-
register(constructor: Constructor, handler?: string | GenericCallback): void;
|
|
10
|
-
};
|
|
11
|
-
type BaseHandlerOptions = {
|
|
12
|
-
callback: GenericCallback;
|
|
13
|
-
method?: string;
|
|
14
|
-
};
|
|
15
|
-
export type CompareHandler<Value> = {
|
|
16
|
-
base: BaseHandler;
|
|
17
|
-
handle(first: unknown, second: unknown, ...parameters: unknown[]): Value;
|
|
18
|
-
};
|
|
19
|
-
export type ValueHandler = {
|
|
20
|
-
base: BaseHandler;
|
|
21
|
-
handle(value: unknown, ...parameters: unknown[]): unknown;
|
|
22
|
-
};
|
|
23
4
|
export declare function createCompareHandler<Value>(owner: GenericCallback, options: BaseHandlerOptions): CompareHandler<Value>;
|
|
24
5
|
export declare function createValueHandler(owner: GenericCallback, options: BaseHandlerOptions): ValueHandler;
|
|
25
6
|
//#endregion
|