@oscarpalmer/atoms 0.213.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/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 +425 -318
- package/dist/index.mjs +454 -408
- 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 -2
- 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} +5 -47
- 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 +3 -3
- 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 +11 -7
- package/dist/plan/index.d.mts +1 -1
- package/dist/plan/index.mjs +1 -1
- package/dist/plan/is.d.mts +1 -1
- package/dist/plan/is.mjs +1 -1
- package/dist/plan/misc.d.mts +1 -1
- package/dist/plan/models.d.mts +1 -1
- package/dist/plan/result.d.mts +2 -2
- package/dist/plan/result.mjs +3 -3
- package/dist/plan/run.d.mts +1 -1
- package/dist/plan/run.mjs +3 -3
- 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/pipe.d.mts +2 -2
- 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 -4
- 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
package/dist/beacon.d.mts
CHANGED
|
@@ -1,95 +1,8 @@
|
|
|
1
|
-
import { Subscription } from "./
|
|
1
|
+
import { Subscription } from "./models/subscription.model.mjs";
|
|
2
|
+
import { Beacon, BeaconOptions, BeaconState, Observable, Observer } from "./models/beacon.model.mjs";
|
|
2
3
|
//#region src/beacon.d.ts
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*/
|
|
6
|
-
export type Beacon<Value> = {
|
|
7
|
-
/**
|
|
8
|
-
* Is the beacon active?
|
|
9
|
-
*/
|
|
10
|
-
get active(): boolean;
|
|
11
|
-
/**
|
|
12
|
-
* The observable that can be subscribed to
|
|
13
|
-
*/
|
|
14
|
-
get observable(): Observable<Value>;
|
|
15
|
-
/**
|
|
16
|
-
* The current value
|
|
17
|
-
*/
|
|
18
|
-
get value(): Value;
|
|
19
|
-
/**
|
|
20
|
-
* Deactivate the beacon
|
|
21
|
-
*/
|
|
22
|
-
deactivate(): void;
|
|
23
|
-
/**
|
|
24
|
-
* Emit a new value
|
|
25
|
-
*
|
|
26
|
-
* @param value Value to set and emit
|
|
27
|
-
* @param finish Finish the beacon after emitting? _(defaults to `false`)_
|
|
28
|
-
*/
|
|
29
|
-
emit(value: Value, finish?: boolean): void;
|
|
30
|
-
/**
|
|
31
|
-
* Emit an error
|
|
32
|
-
*
|
|
33
|
-
* @param value Error to emit
|
|
34
|
-
* @param finish Finish the beacon after emitting? _(defaults to `false`)_
|
|
35
|
-
*/
|
|
36
|
-
error(value: Error, finish?: boolean): void;
|
|
37
|
-
/**
|
|
38
|
-
* Finish the beacon
|
|
39
|
-
*/
|
|
40
|
-
finish(): void;
|
|
41
|
-
};
|
|
42
|
-
export type BeaconOptions<Value> = {
|
|
43
|
-
/**
|
|
44
|
-
* Method for comparing values for equality
|
|
45
|
-
*
|
|
46
|
-
* @param first First value
|
|
47
|
-
* @param second Second value
|
|
48
|
-
* @returns `true` if the values are equal, otherwise `false`
|
|
49
|
-
* @default Object.is
|
|
50
|
-
*/
|
|
51
|
-
equal?: (first: Value, second: Value) => boolean;
|
|
52
|
-
};
|
|
53
|
-
export type Observable<Value> = {
|
|
54
|
-
/**
|
|
55
|
-
* Is the observable active?
|
|
56
|
-
*/
|
|
57
|
-
get active(): boolean;
|
|
58
|
-
/**
|
|
59
|
-
* Deactivate the observable
|
|
60
|
-
*/
|
|
61
|
-
deactivate(): void;
|
|
62
|
-
/**
|
|
63
|
-
* Subscribe to value changes
|
|
64
|
-
*
|
|
65
|
-
* @param onNext Callback for when the observable receives a new value
|
|
66
|
-
* @param onError Callback for when the observable receives an error
|
|
67
|
-
* @param onComplete Callback for when the observable is completed
|
|
68
|
-
* @returns Subscription to the observable
|
|
69
|
-
*/
|
|
70
|
-
subscribe(onNext: (value: Value) => void, onError?: (error: Error) => void, onComplete?: () => void): Subscription;
|
|
71
|
-
/**
|
|
72
|
-
* Subscribe to value changes
|
|
73
|
-
*
|
|
74
|
-
* @param observer Observer for changes
|
|
75
|
-
* @returns Subscription to the observable
|
|
76
|
-
*/
|
|
77
|
-
subscribe(observer: Observer<Value>): Subscription;
|
|
78
|
-
};
|
|
79
|
-
type Observer<Value> = {
|
|
80
|
-
/**
|
|
81
|
-
* Callback for when the observable is completed
|
|
82
|
-
*/
|
|
83
|
-
complete?: () => void;
|
|
84
|
-
/**
|
|
85
|
-
* Callback for when the observable receives an error
|
|
86
|
-
*/
|
|
87
|
-
error?: (error: Error) => void;
|
|
88
|
-
/**
|
|
89
|
-
* Callback for when the observable receives a new value
|
|
90
|
-
*/
|
|
91
|
-
next?: (value: Value) => void;
|
|
92
|
-
};
|
|
4
|
+
declare function Beacon(this: any, value: unknown, options?: BeaconOptions<unknown>): void;
|
|
5
|
+
declare function Observable(this: any, beacon: BeaconState<unknown>): void;
|
|
93
6
|
/**
|
|
94
7
|
* Create a new beacon
|
|
95
8
|
*
|
|
@@ -119,4 +32,5 @@ export declare function isBeaconSubscription(value: unknown): value is Subscript
|
|
|
119
32
|
* @returns `true` if the value is an observable, otherwise `false`
|
|
120
33
|
*/
|
|
121
34
|
export declare function isObservable<Value = unknown>(value: unknown): value is Observable<Value>;
|
|
122
|
-
//#endregion
|
|
35
|
+
//#endregion
|
|
36
|
+
export type { Beacon, BeaconOptions, Observable, Observer };
|
package/dist/beacon.mjs
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { noop } from "./internal/function/misc.mjs";
|
|
2
2
|
import { isPlainObject } from "./internal/is.mjs";
|
|
3
|
-
import
|
|
3
|
+
import "./models/subscription.model.mjs";
|
|
4
|
+
import { isSubscription, subscriptions } from "./internal/subscription.mjs";
|
|
5
|
+
import { BEACON_MESSAGE_RETRIEVE, BEACON_MESSAGE_SUBSCRIBE, BEACON_NAME, BEACON_OBSERVABLE, BEACON_PROPERTY, BEACON_SYMBOL, BEACON_TYPE_ERROR, BEACON_TYPE_NEXT, beaconSubscription } from "./models/beacon.model.mjs";
|
|
4
6
|
//#region src/beacon.ts
|
|
5
|
-
const BEACON_PROPERTY = "$beacon";
|
|
6
|
-
const BEACON_NAME = "beacon";
|
|
7
|
-
const BEACON_OBSERVABLE = "observable";
|
|
8
7
|
function Beacon(value, options) {
|
|
9
8
|
this[BEACON_SYMBOL] = {
|
|
10
9
|
value,
|
|
@@ -128,7 +127,7 @@ function isBeacon(value) {
|
|
|
128
127
|
return isBeaconInstance(BEACON_NAME, value);
|
|
129
128
|
}
|
|
130
129
|
function isBeaconInstance(name, value) {
|
|
131
|
-
return typeof value === "object" && value !== null &&
|
|
130
|
+
return typeof value === "object" && value !== null && "$beacon" in value && value["$beacon"] === name;
|
|
132
131
|
}
|
|
133
132
|
/**
|
|
134
133
|
* Is the value a beacon subscription?
|
|
@@ -137,7 +136,7 @@ function isBeaconInstance(name, value) {
|
|
|
137
136
|
* @returns `true` if the value is a beacon subscription, otherwise `false`
|
|
138
137
|
*/
|
|
139
138
|
function isBeaconSubscription(value) {
|
|
140
|
-
return isSubscription(value) && value[
|
|
139
|
+
return isSubscription(value) && value["$beacon"] === "subscription";
|
|
141
140
|
}
|
|
142
141
|
/**
|
|
143
142
|
* Is the value an observable?
|
|
@@ -163,7 +162,7 @@ function subscribeToObservable(first, second, third) {
|
|
|
163
162
|
function updateBeacon(instance, type, value, finish) {
|
|
164
163
|
const state = instance[BEACON_SYMBOL];
|
|
165
164
|
if (!state.active) return;
|
|
166
|
-
if (type ===
|
|
165
|
+
if (type === "next") {
|
|
167
166
|
if (state.options.equal(state.value, value)) return;
|
|
168
167
|
state.value = value;
|
|
169
168
|
}
|
|
@@ -171,14 +170,5 @@ function updateBeacon(instance, type, value, finish) {
|
|
|
171
170
|
if (subscriptions != null && subscriptions.size > 0) for (const [, observer] of subscriptions) observer[type]?.(value);
|
|
172
171
|
if (finish === true) closeBeacon(state, true);
|
|
173
172
|
}
|
|
174
|
-
const BEACON_MESSAGE_RETRIEVE = "Cannot retrieve observable from a closed beacon";
|
|
175
|
-
const BEACON_MESSAGE_SUBSCRIBE = "Cannot subscribe to a closed observable";
|
|
176
|
-
const BEACON_SYMBOL = Symbol(BEACON_PROPERTY);
|
|
177
|
-
const BEACON_TYPE_ERROR = "error";
|
|
178
|
-
const BEACON_TYPE_NEXT = "next";
|
|
179
|
-
const beaconSubscription = {
|
|
180
|
-
key: BEACON_PROPERTY,
|
|
181
|
-
value: SUBSCRIPTION_NAME
|
|
182
|
-
};
|
|
183
173
|
//#endregion
|
|
184
174
|
export { beacon, isBeacon, isBeaconSubscription, isObservable };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SubscriptionProperty } from "../
|
|
2
|
-
import { ColorDefaults, ColorExpressions, ColorTypeExtended, HSLAColor, HSLColor, HWBAColor, HWBColor, RGBAColor, RGBColor } from "
|
|
1
|
+
import { SubscriptionProperty } from "../models/subscription.model.mjs";
|
|
2
|
+
import { ColorDefaults, ColorExpressions, ColorTypeExtended, HSLAColor, HSLColor, HWBAColor, HWBColor, RGBAColor, RGBColor } from "../models/color.model.mjs";
|
|
3
3
|
//#region src/color/constants.d.ts
|
|
4
4
|
type ColorTypes = {
|
|
5
5
|
all: Set<"alpha" | ColorTypeExtended>;
|
package/dist/color/constants.mjs
CHANGED
package/dist/color/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Color, ColorType, ColorTypeExtended, ColorValue, ColorValueExtended, HSLAColor, HSLColor, HWBAColor, HWBColor, RGBAColor, RGBColor } from "
|
|
1
|
+
import { Color, ColorType, ColorTypeExtended, ColorValue, ColorValueExtended, HSLAColor, HSLColor, HWBAColor, HWBColor, RGBAColor, RGBColor } from "../models/color.model.mjs";
|
|
2
2
|
import { getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getHwbColor, getHwbaColor, getRgbColor, getRgbaColor } from "./misc/get.mjs";
|
|
3
3
|
import { isColor, isHexColor, isHslColor, isHslaColor, isHwbColor, isHwbaColor, isRgbColor, isRgbaColor } from "./misc/is.mjs";
|
|
4
4
|
import { getNormalizedHex, hexToHsl, hexToHsla, hexToHwb, hexToHwba, hexToRgb, hexToRgba } from "./space/hex.mjs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Alpha, InternalColor } from "
|
|
1
|
+
import { Alpha, InternalColor } from "../../models/color.model.mjs";
|
|
2
2
|
//#region src/color/misc/alpha.d.ts
|
|
3
3
|
export declare function getAlpha(value: unknown, hex: boolean): Alpha;
|
|
4
4
|
export declare function getColorAlpha(this: InternalColor): number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InternalColor } from "
|
|
1
|
+
import { InternalColor } from "../../models/color.model.mjs";
|
|
2
2
|
//#region src/color/misc/format.d.ts
|
|
3
3
|
export declare function formatHexColor(this: InternalColor, alpha?: boolean): string;
|
|
4
4
|
export declare function formatHslColor(this: InternalColor, alpha?: boolean): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Color, HSLAColor, HSLColor, HWBAColor, HWBColor, RGBAColor, RGBColor } from "
|
|
1
|
+
import { Color, HSLAColor, HSLColor, HWBAColor, HWBColor, RGBAColor, RGBColor } from "../../models/color.model.mjs";
|
|
2
2
|
//#region src/color/misc/get.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Get a foreground color _(usually text)_ based on a background color's luminance as an unprefixed hex color string
|
package/dist/color/misc/is.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Subscription } from "../../
|
|
2
|
-
import { Color, HSLAColor, HSLColor, HWBAColor, HWBColor, RGBAColor, RGBColor } from "
|
|
1
|
+
import { Subscription } from "../../models/subscription.model.mjs";
|
|
2
|
+
import { Color, HSLAColor, HSLColor, HWBAColor, HWBColor, RGBAColor, RGBColor } from "../../models/color.model.mjs";
|
|
3
3
|
//#region src/color/misc/is.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Is the value a _Color_?
|
package/dist/color/misc/is.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import "../../models/subscription.model.mjs";
|
|
1
2
|
import { isSubscription } from "../../internal/subscription.mjs";
|
|
2
3
|
import { between } from "../../internal/number.mjs";
|
|
3
4
|
import { COLOR_ALPHA, COLOR_EXPRESSION, COLOR_KEYS, COLOR_LENGTHS, COLOR_MAX } from "../constants.mjs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ColorState, ColorType, HSLAColor, HSLColor, HWBAColor, HWBColor, InternalColor, RGBAColor, RGBColor } from "
|
|
1
|
+
import { ColorState, ColorType, HSLAColor, HSLColor, HWBAColor, HWBColor, InternalColor, RGBAColor, RGBColor } from "../../models/color.model.mjs";
|
|
2
2
|
//#region src/color/misc/state.d.ts
|
|
3
3
|
export declare function getColorFromState<Type extends ColorType>(state: ColorState, type: Type): NonNullable<ColorState[Type]>;
|
|
4
4
|
export declare function getColorState(value: unknown): ColorState;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ColorState, ColorType, HSLAColor, HSLColor, HWBAColor, HWBColor, InternalColor, RGBAColor, RGBColor } from "
|
|
1
|
+
import { ColorState, ColorType, HSLAColor, HSLColor, HWBAColor, HWBColor, InternalColor, RGBAColor, RGBColor } from "../../models/color.model.mjs";
|
|
2
2
|
//#region src/color/space/hex.d.ts
|
|
3
3
|
export declare function getColorFromHex<Type extends ColorType>(state: ColorState, type: Type): NonNullable<ColorState[Type]>;
|
|
4
4
|
export declare function getHexColor(this: InternalColor): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ColorState, ColorType, HSLAColor, HSLColor, HWBAColor, HWBColor, InternalColor, RGBAColor, RGBColor } from "
|
|
1
|
+
import { ColorState, ColorType, HSLAColor, HSLColor, HWBAColor, HWBColor, InternalColor, RGBAColor, RGBColor } from "../../models/color.model.mjs";
|
|
2
2
|
//#region src/color/space/hsl.d.ts
|
|
3
3
|
export declare function getColorFromHsl<Type extends ColorType>(state: ColorState, type: Type): NonNullable<ColorState[Type]>;
|
|
4
4
|
export declare function getHslValue(this: InternalColor): HSLColor;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ColorState, ColorType, HSLAColor, HSLColor, HWBAColor, HWBColor, InternalColor, RGBAColor, RGBColor } from "
|
|
1
|
+
import { ColorState, ColorType, HSLAColor, HSLColor, HWBAColor, HWBColor, InternalColor, RGBAColor, RGBColor } from "../../models/color.model.mjs";
|
|
2
2
|
//#region src/color/space/hwb.d.ts
|
|
3
3
|
export declare function convertHwbToHsl(input: HWBAColor | HWBColor): HSLAColor;
|
|
4
4
|
export declare function getColorFromHwb<Type extends ColorType>(state: ColorState, type: Type): NonNullable<ColorState[Type]>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ColorState, ColorType, HSLAColor, HSLColor, HWBAColor, HWBColor, InternalColor, RGBAColor, RGBColor } from "
|
|
1
|
+
import { ColorState, ColorType, HSLAColor, HSLColor, HWBAColor, HWBColor, InternalColor, RGBAColor, RGBColor } from "../../models/color.model.mjs";
|
|
2
2
|
//#region src/color/space/rgb.d.ts
|
|
3
3
|
export declare function convertRgbToHex(rgb: RGBAColor | RGBColor, alpha: boolean): string;
|
|
4
4
|
export declare function convertRgbToHsla(value: unknown): HSLAColor;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { GenericAsyncCallback, GenericCallback } from "../models.mjs";
|
|
2
|
-
import { AsyncLimiter, Limiter } from "../
|
|
1
|
+
import { GenericAsyncCallback, GenericCallback } from "../models/index.mjs";
|
|
2
|
+
import { AsyncLimiter, Limiter } from "../models/function/limiter.model.mjs";
|
|
3
3
|
//#region src/function/limit.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Debounce a function, ensuring it is only called after `time` milliseconds have passed
|
package/dist/function/limit.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { LIMITER_DEBOUNCE, LIMITER_THROTTLE
|
|
1
|
+
import { LIMITER_DEBOUNCE, LIMITER_THROTTLE } from "../models/function/limiter.model.mjs";
|
|
2
|
+
import { getAsyncLimiter, getLimiter } from "../internal/function/limit.mjs";
|
|
2
3
|
//#region src/function/limit.ts
|
|
3
4
|
/**
|
|
4
5
|
* Debounce a function, ensuring it is only called after `time` milliseconds have passed
|
package/dist/function/once.d.mts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { GenericAsyncCallback, GenericCallback
|
|
1
|
+
import { GenericAsyncCallback, GenericCallback } from "../models/index.mjs";
|
|
2
|
+
import { AsyncOnce, Once } from "../models/function/once.model.mjs";
|
|
2
3
|
//#region src/function/once.d.ts
|
|
4
|
+
declare function AsyncOnce(this: any, callback: GenericAsyncCallback): void;
|
|
5
|
+
declare function Once(this: any, callback: GenericCallback): void;
|
|
3
6
|
/**
|
|
4
7
|
* Create an asynchronous function that can only be called once, rejecting or resolving the same result on subsequent calls
|
|
5
8
|
*
|
|
@@ -8,7 +11,7 @@ import { GenericAsyncCallback, GenericCallback, Once, OnceAsync } from "../model
|
|
|
8
11
|
* @param callback Callback to use once
|
|
9
12
|
* @returns _Once_ callback
|
|
10
13
|
*/
|
|
11
|
-
export declare function asyncOnce<Callback extends GenericAsyncCallback>(callback: Callback):
|
|
14
|
+
export declare function asyncOnce<Callback extends GenericAsyncCallback>(callback: Callback): AsyncOnce<Callback>;
|
|
12
15
|
/**
|
|
13
16
|
* Is the value an asynchronous once callback?
|
|
14
17
|
*
|
|
@@ -38,4 +41,5 @@ export declare namespace once {
|
|
|
38
41
|
export var is: typeof isOnce;
|
|
39
42
|
export var isAsync: typeof isAsyncOnce;
|
|
40
43
|
}
|
|
41
|
-
//#endregion
|
|
44
|
+
//#endregion
|
|
45
|
+
export type { AsyncOnce, Once };
|
package/dist/function/once.mjs
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { assert } from "../internal/function/assert.mjs";
|
|
2
|
+
import { ONCE_MESSAGE_CLEARED, ONCE_MESSAGE_EXPECTATION, ONCE_NAME_ASYNC, ONCE_NAME_SYNC, ONCE_PROPERTY, ONCE_SYMBOL } from "../models/function/once.model.mjs";
|
|
2
3
|
//#region src/function/once.ts
|
|
3
|
-
const ONCE_NAME_ASYNC = "asyncOnce";
|
|
4
|
-
const ONCE_NAME_SYNC = "once";
|
|
5
|
-
const ONCE_PROPERTY = "$once";
|
|
6
4
|
function AsyncOnce(callback) {
|
|
7
5
|
this[ONCE_SYMBOL] = {
|
|
8
6
|
callback,
|
|
@@ -94,9 +92,9 @@ function handleOnceResult(state, value, error) {
|
|
|
94
92
|
const items = state.items.splice(0);
|
|
95
93
|
const { length } = items;
|
|
96
94
|
for (let index = 0; index < length; index += 1) {
|
|
97
|
-
const
|
|
98
|
-
if (error) reject(value);
|
|
99
|
-
else resolve(value);
|
|
95
|
+
const item = items[index];
|
|
96
|
+
if (error) item.reject(value);
|
|
97
|
+
else item.resolve(value);
|
|
100
98
|
}
|
|
101
99
|
}
|
|
102
100
|
/**
|
|
@@ -118,7 +116,7 @@ function isOnce(value) {
|
|
|
118
116
|
return isOnceInstance(value, ONCE_NAME_SYNC);
|
|
119
117
|
}
|
|
120
118
|
function isOnceInstance(value, name) {
|
|
121
|
-
return typeof value === "object" && value !== null &&
|
|
119
|
+
return typeof value === "object" && value !== null && "$once" in value && value["$once"] === name;
|
|
122
120
|
}
|
|
123
121
|
/**
|
|
124
122
|
* Create a function that can only be called once, returning the same value on subsequent calls
|
|
@@ -161,9 +159,6 @@ function runOnceAsync(...parameters) {
|
|
|
161
159
|
});
|
|
162
160
|
});
|
|
163
161
|
}
|
|
164
|
-
const ONCE_MESSAGE_CLEARED = "Once has been cleared";
|
|
165
|
-
const ONCE_MESSAGE_EXPECTATION = "Once expected a function";
|
|
166
|
-
const ONCE_SYMBOL = Symbol(ONCE_PROPERTY);
|
|
167
162
|
asyncOnce.is = isAsyncOnce;
|
|
168
163
|
once.async = asyncOnce;
|
|
169
164
|
once.is = isOnce;
|
|
@@ -1,17 +1,6 @@
|
|
|
1
|
-
import { GenericAsyncCallback, GenericCallback } from "../models.mjs";
|
|
1
|
+
import { GenericAsyncCallback, GenericCallback } from "../models/index.mjs";
|
|
2
|
+
import { RetryError, RetryOptions } from "../models/function/retry.model.mjs";
|
|
2
3
|
//#region src/function/retry.d.ts
|
|
3
|
-
/**
|
|
4
|
-
* An error thrown when a retry fails
|
|
5
|
-
*/
|
|
6
|
-
export declare class RetryError extends Error {
|
|
7
|
-
readonly original: unknown;
|
|
8
|
-
constructor(message: string, original: unknown);
|
|
9
|
-
}
|
|
10
|
-
export type RetryOptions = {
|
|
11
|
-
delay?: number;
|
|
12
|
-
times?: number;
|
|
13
|
-
when?: (error: unknown) => boolean;
|
|
14
|
-
};
|
|
15
4
|
/**
|
|
16
5
|
* Retry a callback a specified number of times, with a delay between attempts
|
|
17
6
|
*
|
|
@@ -43,4 +32,5 @@ export declare function retry<Callback extends GenericCallback>(callback: Callba
|
|
|
43
32
|
export declare namespace retry {
|
|
44
33
|
export var async: typeof asyncRetry;
|
|
45
34
|
}
|
|
46
|
-
//#endregion
|
|
35
|
+
//#endregion
|
|
36
|
+
export { RetryError };
|
package/dist/function/retry.mjs
CHANGED
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
import { isPlainObject } from "../internal/is.mjs";
|
|
2
2
|
import { asyncAttempt, attempt } from "../internal/result/attempt.mjs";
|
|
3
|
+
import { LIMITER_WAIT } from "../models/function/limiter.model.mjs";
|
|
3
4
|
import { getNumberOrDefault } from "../internal/defaults.mjs";
|
|
4
|
-
import {
|
|
5
|
+
import { getLimiter } from "../internal/function/limit.mjs";
|
|
6
|
+
import { RETRY_MESSAGE_EXPECTATION, RETRY_MESSAGE_FAILED, RetryError } from "../models/function/retry.model.mjs";
|
|
5
7
|
//#region src/function/retry.ts
|
|
6
8
|
/**
|
|
7
|
-
* An error thrown when a retry fails
|
|
8
|
-
*/
|
|
9
|
-
var RetryError = class extends Error {
|
|
10
|
-
original;
|
|
11
|
-
constructor(message, original) {
|
|
12
|
-
super(message);
|
|
13
|
-
this.original = original;
|
|
14
|
-
this.name = RETRY_ERROR_NAME;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
9
|
* Retry a callback a specified number of times, with a delay between attempts
|
|
19
10
|
*
|
|
20
11
|
* _Available as `asyncRetry` and `retry.async`_
|
|
@@ -77,9 +68,6 @@ function retry(callback, options) {
|
|
|
77
68
|
function shouldRetry() {
|
|
78
69
|
return true;
|
|
79
70
|
}
|
|
80
|
-
const RETRY_ERROR_NAME = "RetryError";
|
|
81
|
-
const RETRY_MESSAGE_EXPECTATION = "Retry expected a function";
|
|
82
|
-
const RETRY_MESSAGE_FAILED = "Retry failed";
|
|
83
71
|
retry.async = asyncRetry;
|
|
84
72
|
//#endregion
|
|
85
73
|
export { RetryError, retry };
|
package/dist/herald.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Herald, HeraldEvents } from "./
|
|
1
|
+
import { Herald, HeraldEvents, HeraldOptions } from "./models/herald.model.mjs";
|
|
2
2
|
import { herald, isHerald, isHeraldEvents, isHeraldSubscription } from "./internal/herald.mjs";
|
|
3
|
-
export { type Herald, type HeraldEvents, herald, isHerald, isHeraldEvents, isHeraldSubscription };
|
|
3
|
+
export { type Herald, type HeraldEvents, type HeraldOptions, herald, isHerald, isHeraldEvents, isHeraldSubscription };
|