@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,7 +1,7 @@
|
|
|
1
|
-
import { Subscription } from "
|
|
2
|
-
import { Herald, HeraldEvents } from "
|
|
3
|
-
import { COLOR_SYMBOL } from "
|
|
4
|
-
//#region src/color
|
|
1
|
+
import { Subscription } from "./subscription.model.mjs";
|
|
2
|
+
import { Herald, HeraldEvents } from "./herald.model.mjs";
|
|
3
|
+
import { COLOR_SYMBOL } from "../color/constants.mjs";
|
|
4
|
+
//#region src/models/color.model.d.ts
|
|
5
5
|
export type Alpha = {
|
|
6
6
|
hex: string;
|
|
7
7
|
value: number;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { NestedKeys, PlainObject } from "../index.mjs";
|
|
2
|
+
//#region src/models/function/assert.model.d.ts
|
|
3
|
+
export type AssertNestedPick<Value, Path extends string> = Value extends PlainObject ? Path extends `${infer Head}.${infer Rest}` ? Head extends keyof Value ? { [Key in Head]: AssertNestedPick<Value[Key], Rest>; } : never : Path extends keyof Value ? { [Key in Path]: Value[Key]; } : never : never;
|
|
4
|
+
/**
|
|
5
|
+
* Asserter for a property of a value
|
|
6
|
+
*/
|
|
7
|
+
export type AssertProperty<Value extends PlainObject, Path extends NestedKeys<Value>, Asserted extends AssertNestedPick<Value, Path> = AssertNestedPick<Value, Path>> = Asserter<Asserted>;
|
|
8
|
+
/**
|
|
9
|
+
* A function that asserts a value is of a specific type, throwing an error if it is not
|
|
10
|
+
*/
|
|
11
|
+
export type Asserter<Value> = (value: unknown) => asserts value is Value;
|
|
12
|
+
export declare const ASSERT_MESSAGE_VALUE_DEFINED = "Expected value to be defined";
|
|
13
|
+
//#endregion
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { GenericAsyncCallback, GenericCallback } from "../index.mjs";
|
|
2
|
+
//#region src/models/function/limiter.model.d.ts
|
|
3
|
+
export type AsyncLimiterItem = {
|
|
4
|
+
parameters: unknown[];
|
|
5
|
+
promise: Promise<unknown>;
|
|
6
|
+
reject(reason?: unknown): void;
|
|
7
|
+
resolve(value?: unknown): void;
|
|
8
|
+
running: boolean;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* An asynchronous function that can be cancelled
|
|
12
|
+
*/
|
|
13
|
+
export type AsyncLimiter<Callback extends GenericAsyncCallback> = {
|
|
14
|
+
/**
|
|
15
|
+
* Cancel the function
|
|
16
|
+
*/
|
|
17
|
+
cancel(): void;
|
|
18
|
+
/**
|
|
19
|
+
* Call the function
|
|
20
|
+
*
|
|
21
|
+
* @param parameters Function parameters
|
|
22
|
+
* @returns Function result
|
|
23
|
+
*/
|
|
24
|
+
run(...parameters: Parameters<Callback>): Promise<ReturnType<Callback>>;
|
|
25
|
+
};
|
|
26
|
+
export type AsyncLimiterState = {
|
|
27
|
+
last?: AsyncLimiterItem;
|
|
28
|
+
} & LimiterState<GenericAsyncCallback>;
|
|
29
|
+
export type InternalAsyncLimiter = {
|
|
30
|
+
[LIMITER_SYMBOL]: AsyncLimiterState;
|
|
31
|
+
} & AsyncLimiter<GenericAsyncCallback>;
|
|
32
|
+
export type InternalLimiter = {
|
|
33
|
+
[LIMITER_SYMBOL]: LimiterState;
|
|
34
|
+
} & Limiter<GenericCallback>;
|
|
35
|
+
/**
|
|
36
|
+
* A function that can be cancelled
|
|
37
|
+
*/
|
|
38
|
+
export type Limiter<Callback extends GenericCallback> = {
|
|
39
|
+
/**
|
|
40
|
+
* Cancel the function
|
|
41
|
+
*/
|
|
42
|
+
cancel(): void;
|
|
43
|
+
/**
|
|
44
|
+
* Call the function
|
|
45
|
+
*
|
|
46
|
+
* @param parameters Function parameters
|
|
47
|
+
* @returns Function result
|
|
48
|
+
*/
|
|
49
|
+
run(...parameters: Parameters<Callback>): ReturnType<Callback>;
|
|
50
|
+
};
|
|
51
|
+
export type LimiterState<Callback = GenericCallback> = {
|
|
52
|
+
callback: Callback;
|
|
53
|
+
interval: number;
|
|
54
|
+
parameters: unknown[];
|
|
55
|
+
start?: number;
|
|
56
|
+
throttle: boolean;
|
|
57
|
+
timer?: number;
|
|
58
|
+
type: LimiterType;
|
|
59
|
+
};
|
|
60
|
+
export type LimiterType = "debounce" | "throttle" | "wait";
|
|
61
|
+
export declare const LIMITER_DEBOUNCE: LimiterType;
|
|
62
|
+
export declare const LIMITER_NAME_ASYNC = "asyncLimiter";
|
|
63
|
+
export declare const LIMITER_NAME_SYNC = "limiter";
|
|
64
|
+
export declare const LIMITER_PROPERTY = "$limiter";
|
|
65
|
+
export declare const LIMITER_OFFSET = 5;
|
|
66
|
+
export declare const LIMITER_SYMBOL: unique symbol;
|
|
67
|
+
export declare const LIMITER_THROTTLE: LimiterType;
|
|
68
|
+
export declare const LIMITER_WAIT: LimiterType;
|
|
69
|
+
export declare const clearTimer: (handle: number) => void;
|
|
70
|
+
export declare const startTimer: (callback: FrameRequestCallback) => number;
|
|
71
|
+
//#endregion
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/models/function/limiter.model.ts
|
|
2
|
+
const LIMITER_DEBOUNCE = "debounce";
|
|
3
|
+
const LIMITER_NAME_ASYNC = "asyncLimiter";
|
|
4
|
+
const LIMITER_NAME_SYNC = "limiter";
|
|
5
|
+
const LIMITER_PROPERTY = "$limiter";
|
|
6
|
+
const LIMITER_OFFSET = 5;
|
|
7
|
+
const LIMITER_SYMBOL = Symbol("limiter");
|
|
8
|
+
const LIMITER_THROTTLE = "throttle";
|
|
9
|
+
const LIMITER_WAIT = "wait";
|
|
10
|
+
// istanbul ignore next
|
|
11
|
+
const clearTimer = typeof cancelAnimationFrame === "function" ? cancelAnimationFrame : clearTimeout;
|
|
12
|
+
// istanbul ignore next
|
|
13
|
+
const startTimer = typeof requestAnimationFrame === "function" ? requestAnimationFrame : setTimeout;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { LIMITER_DEBOUNCE, LIMITER_NAME_ASYNC, LIMITER_NAME_SYNC, LIMITER_OFFSET, LIMITER_PROPERTY, LIMITER_SYMBOL, LIMITER_THROTTLE, LIMITER_WAIT, clearTimer, startTimer };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { GenericCallback } from "../index.mjs";
|
|
2
|
+
import { SizedMap } from "../../internal/sized/map.mjs";
|
|
3
|
+
//#region src/models/function/memoize.model.d.ts
|
|
4
|
+
export type InternalMemoized = {
|
|
5
|
+
[MEMOIZED_SYMBOL]: MemoizedState;
|
|
6
|
+
} & Memoized<GenericCallback>;
|
|
7
|
+
/**
|
|
8
|
+
* A _Memoized_ function instance, caching and retrieving results based on the its parameters _(or a custom cache key)_
|
|
9
|
+
*/
|
|
10
|
+
export type Memoized<Callback extends GenericCallback> = {
|
|
11
|
+
/**
|
|
12
|
+
* Maximum cache size
|
|
13
|
+
*
|
|
14
|
+
* @returns Maximum cache size _(or `Number.NaN` if the instance has been destroyed)_
|
|
15
|
+
*/
|
|
16
|
+
get maximum(): number;
|
|
17
|
+
/**
|
|
18
|
+
* Current cache size
|
|
19
|
+
*
|
|
20
|
+
* @returns Current cache size _(or `Number.NaN` if the instance has been destroyed)_
|
|
21
|
+
*/
|
|
22
|
+
get size(): number;
|
|
23
|
+
/**
|
|
24
|
+
* Clear the cache
|
|
25
|
+
*/
|
|
26
|
+
clear(): void;
|
|
27
|
+
/**
|
|
28
|
+
* Delete a result from the cache
|
|
29
|
+
*
|
|
30
|
+
* @param key Key to delete
|
|
31
|
+
* @returns `true` if the key existed and was removed, otherwise `false`
|
|
32
|
+
*/
|
|
33
|
+
delete(key: unknown): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Destroy the instance
|
|
36
|
+
*
|
|
37
|
+
* _(When a Memoized instance is destroyed, its cache and callback are removed, and calls to `run` will throw an error)_
|
|
38
|
+
*/
|
|
39
|
+
destroy(): void;
|
|
40
|
+
/**
|
|
41
|
+
* Get a result from the cache
|
|
42
|
+
*
|
|
43
|
+
* @param key Key to get
|
|
44
|
+
* @returns Cached result or `undefined` if it does not exist
|
|
45
|
+
*/
|
|
46
|
+
get(key: unknown): ReturnType<Callback> | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Does the result exist?
|
|
49
|
+
*
|
|
50
|
+
* @param key Key to check
|
|
51
|
+
* @returns `true` if the result exists, otherwise `false`
|
|
52
|
+
*/
|
|
53
|
+
has(key: unknown): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Run the callback with the provided parameters
|
|
56
|
+
*
|
|
57
|
+
* @param parameters Parameters to pass to the callback
|
|
58
|
+
* @returns Cached or computed _(then cached)_ result
|
|
59
|
+
*/
|
|
60
|
+
run(...parameters: Parameters<Callback>): ReturnType<Callback>;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Options for a _Memoized_ function
|
|
64
|
+
*/
|
|
65
|
+
export type MemoizedOptions<Callback extends GenericCallback> = {
|
|
66
|
+
/**
|
|
67
|
+
* Callback for getting a cache key for the provided parameters
|
|
68
|
+
*/
|
|
69
|
+
cacheKey?: (...parameters: Parameters<Callback>) => unknown;
|
|
70
|
+
/**
|
|
71
|
+
* Size of the cache
|
|
72
|
+
*/
|
|
73
|
+
cacheSize?: number;
|
|
74
|
+
};
|
|
75
|
+
export type MemoizedState = {
|
|
76
|
+
cache: SizedMap<unknown, unknown>;
|
|
77
|
+
getter: GenericCallback;
|
|
78
|
+
options: MemoizedStateOptions;
|
|
79
|
+
};
|
|
80
|
+
export type MemoizedStateOptions = {
|
|
81
|
+
cacheKey?: GenericCallback;
|
|
82
|
+
cacheSize: number;
|
|
83
|
+
};
|
|
84
|
+
export declare const MEMOIZED_CACHE_SIZE_DEFAULT = 1024;
|
|
85
|
+
export declare const MEMOIZED_CALLBACK = "Memoized requires a callback function";
|
|
86
|
+
export declare const MEMOIZED_KEY_SEPARATOR = "_";
|
|
87
|
+
export declare const MEMOIZED_SYMBOL: unique symbol;
|
|
88
|
+
//#endregion
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
//#region src/models/function/memoize.model.ts
|
|
2
|
+
const MEMOIZED_CACHE_SIZE_DEFAULT = 1024;
|
|
3
|
+
const MEMOIZED_CALLBACK = "Memoized requires a callback function";
|
|
4
|
+
const MEMOIZED_KEY_SEPARATOR = "_";
|
|
5
|
+
const MEMOIZED_SYMBOL = Symbol("memoized");
|
|
6
|
+
//#endregion
|
|
7
|
+
export { MEMOIZED_CACHE_SIZE_DEFAULT, MEMOIZED_CALLBACK, MEMOIZED_KEY_SEPARATOR, MEMOIZED_SYMBOL };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { GenericAsyncCallback, GenericCallback } from "../index.mjs";
|
|
2
|
+
//#region src/models/function/once.model.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* An asynchronous function that can only be called once, returning the same value on subsequent calls
|
|
5
|
+
*/
|
|
6
|
+
export type AsyncOnce<Callback extends GenericAsyncCallback> = {
|
|
7
|
+
/**
|
|
8
|
+
* Did the callback's promise reject?
|
|
9
|
+
*/
|
|
10
|
+
readonly error: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Has the callback finished?
|
|
13
|
+
*/
|
|
14
|
+
readonly finished: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Run the callback
|
|
17
|
+
*
|
|
18
|
+
* @param parameters Callback parameters
|
|
19
|
+
* @returns Call result
|
|
20
|
+
*/
|
|
21
|
+
run(...parameters: Parameters<Callback>): ReturnType<Callback>;
|
|
22
|
+
} & OnceProperties;
|
|
23
|
+
export type AsyncOnceItem<Value> = {
|
|
24
|
+
reject(reason?: unknown): void;
|
|
25
|
+
resolve(value: Value): void;
|
|
26
|
+
};
|
|
27
|
+
export type AsyncOnceState<Value> = {
|
|
28
|
+
error: boolean;
|
|
29
|
+
finished: boolean;
|
|
30
|
+
items: Array<AsyncOnceItem<Value>>;
|
|
31
|
+
} & OnceState<Value, GenericAsyncCallback>;
|
|
32
|
+
export type InternalAsyncOnce = {
|
|
33
|
+
[ONCE_SYMBOL]: AsyncOnceState<unknown>;
|
|
34
|
+
} & AsyncOnce<GenericAsyncCallback>;
|
|
35
|
+
export type InternalOnce = {
|
|
36
|
+
[ONCE_SYMBOL]: OnceState<unknown>;
|
|
37
|
+
} & Once<GenericCallback>;
|
|
38
|
+
/**
|
|
39
|
+
* A callback function that can only be called once, returning the same value on subsequent calls
|
|
40
|
+
*/
|
|
41
|
+
export type Once<Callback extends GenericCallback> = {
|
|
42
|
+
/**
|
|
43
|
+
* Run the callback
|
|
44
|
+
*
|
|
45
|
+
* @param parameters Callback parameters
|
|
46
|
+
* @returns Call result
|
|
47
|
+
*/
|
|
48
|
+
run(...parameters: Parameters<Callback>): ReturnType<Callback>;
|
|
49
|
+
} & OnceProperties;
|
|
50
|
+
type OnceProperties = {
|
|
51
|
+
/**
|
|
52
|
+
* Has the callback been called?
|
|
53
|
+
*/
|
|
54
|
+
readonly called: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Has the callback's value been cleared?
|
|
57
|
+
*/
|
|
58
|
+
readonly cleared: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Clear the callback's cached value
|
|
61
|
+
*/
|
|
62
|
+
clear(): void;
|
|
63
|
+
};
|
|
64
|
+
export type OnceState<Value, Callback = GenericCallback> = {
|
|
65
|
+
callback: Callback;
|
|
66
|
+
called: boolean;
|
|
67
|
+
cleared: boolean;
|
|
68
|
+
value: Value;
|
|
69
|
+
};
|
|
70
|
+
export declare const ONCE_NAME_ASYNC = "asyncOnce";
|
|
71
|
+
export declare const ONCE_NAME_SYNC = "once";
|
|
72
|
+
export declare const ONCE_PROPERTY = "$once";
|
|
73
|
+
export declare const ONCE_MESSAGE_CLEARED = "Once has been cleared";
|
|
74
|
+
export declare const ONCE_MESSAGE_EXPECTATION = "Once expected a function";
|
|
75
|
+
export declare const ONCE_SYMBOL: unique symbol;
|
|
76
|
+
//#endregion
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/models/function/once.model.ts
|
|
2
|
+
const ONCE_NAME_ASYNC = "asyncOnce";
|
|
3
|
+
const ONCE_NAME_SYNC = "once";
|
|
4
|
+
const ONCE_PROPERTY = "$once";
|
|
5
|
+
const ONCE_MESSAGE_CLEARED = "Once has been cleared";
|
|
6
|
+
const ONCE_MESSAGE_EXPECTATION = "Once expected a function";
|
|
7
|
+
const ONCE_SYMBOL = Symbol(ONCE_PROPERTY);
|
|
8
|
+
//#endregion
|
|
9
|
+
export { ONCE_MESSAGE_CLEARED, ONCE_MESSAGE_EXPECTATION, ONCE_NAME_ASYNC, ONCE_NAME_SYNC, ONCE_PROPERTY, ONCE_SYMBOL };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/models/function/retry.model.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* An error thrown when a retry fails
|
|
4
|
+
*/
|
|
5
|
+
export declare class RetryError extends Error {
|
|
6
|
+
readonly original: unknown;
|
|
7
|
+
constructor(message: string, original: unknown);
|
|
8
|
+
}
|
|
9
|
+
export type RetryOptions = {
|
|
10
|
+
delay?: number;
|
|
11
|
+
times?: number;
|
|
12
|
+
when?: (error: unknown) => boolean;
|
|
13
|
+
};
|
|
14
|
+
export declare const RETRY_ERROR_NAME = "RetryError";
|
|
15
|
+
export declare const RETRY_MESSAGE_EXPECTATION = "Retry expected a function";
|
|
16
|
+
export declare const RETRY_MESSAGE_FAILED = "Retry failed";
|
|
17
|
+
//#endregion
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/models/function/retry.model.ts
|
|
2
|
+
/**
|
|
3
|
+
* An error thrown when a retry fails
|
|
4
|
+
*/
|
|
5
|
+
var RetryError = class extends Error {
|
|
6
|
+
original;
|
|
7
|
+
constructor(message, original) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.original = original;
|
|
10
|
+
this.name = RETRY_ERROR_NAME;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
const RETRY_ERROR_NAME = "RetryError";
|
|
14
|
+
const RETRY_MESSAGE_EXPECTATION = "Retry expected a function";
|
|
15
|
+
const RETRY_MESSAGE_FAILED = "Retry failed";
|
|
16
|
+
//#endregion
|
|
17
|
+
export { RETRY_ERROR_NAME, RETRY_MESSAGE_EXPECTATION, RETRY_MESSAGE_FAILED, RetryError };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { GenericCallback } from "../index.mjs";
|
|
2
|
+
import { Asserter } from "./assert.model.mjs";
|
|
3
|
+
import { UnwrapValue } from "../result.model.mjs";
|
|
4
|
+
//#region src/models/function/work.model.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* An asynchronous _Flow_, a function that pipes a value through a series of functions
|
|
7
|
+
*/
|
|
8
|
+
export type AsyncFlow<Callback extends GenericCallback, Value> = (...args: Parameters<Callback>) => Promise<UnwrapValue<Value>>;
|
|
9
|
+
/**
|
|
10
|
+
* A synchronous _Flow_, a function that pipe a value through a series of functions
|
|
11
|
+
*/
|
|
12
|
+
export type Flow<Callback extends GenericCallback, Value> = (...args: Parameters<Callback>) => UnwrapValue<Value>;
|
|
13
|
+
export declare const WORK_MESSAGE_FLOW_ARRAY = "Flow expected to receive an array of functions";
|
|
14
|
+
export declare const WORK_MESSAGE_FLOW_PROMISE = "Synchronous Flow received a promise. Use `flow.async` instead.";
|
|
15
|
+
export declare const WORK_MESSAGE_NESTING = "Return values are too deeply nested.";
|
|
16
|
+
export declare const WORK_MESSAGE_PIPE_ARRAY = "Pipe expected to receive an array of functions";
|
|
17
|
+
export declare const WORK_MESSAGE_PIPE_PROMISE = "Synchronous Pipe received a promise. Use `pipe.async` instead.";
|
|
18
|
+
export declare const assertFlowFunctions: Asserter<Function[]>;
|
|
19
|
+
export declare const assertPipeFunctions: Asserter<Function[]>;
|
|
20
|
+
//#endregion
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { assert } from "../../internal/function/assert.mjs";
|
|
2
|
+
//#region src/models/function/work.model.ts
|
|
3
|
+
const WORK_MESSAGE_FLOW_ARRAY = "Flow expected to receive an array of functions";
|
|
4
|
+
const WORK_MESSAGE_FLOW_PROMISE = "Synchronous Flow received a promise. Use `flow.async` instead.";
|
|
5
|
+
const WORK_MESSAGE_NESTING = "Return values are too deeply nested.";
|
|
6
|
+
const WORK_MESSAGE_PIPE_ARRAY = "Pipe expected to receive an array of functions";
|
|
7
|
+
const WORK_MESSAGE_PIPE_PROMISE = "Synchronous Pipe received a promise. Use `pipe.async` instead.";
|
|
8
|
+
const assertFlowFunctions = assert.condition((value) => Array.isArray(value) && value.every((item) => typeof item === "function"), WORK_MESSAGE_FLOW_ARRAY, TypeError);
|
|
9
|
+
const assertPipeFunctions = assert.condition((value) => Array.isArray(value) && value.every((item) => typeof item === "function"), WORK_MESSAGE_PIPE_ARRAY, TypeError);
|
|
10
|
+
//#endregion
|
|
11
|
+
export { WORK_MESSAGE_FLOW_ARRAY, WORK_MESSAGE_FLOW_PROMISE, WORK_MESSAGE_NESTING, WORK_MESSAGE_PIPE_ARRAY, WORK_MESSAGE_PIPE_PROMISE, assertFlowFunctions, assertPipeFunctions };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { GenericCallback } from "
|
|
2
|
-
import { Subscription, SubscriptionProperty, Subscriptions } from "
|
|
3
|
-
//#region src/
|
|
1
|
+
import { GenericCallback } from "./index.mjs";
|
|
2
|
+
import { Subscription, SubscriptionProperty, Subscriptions } from "./subscription.model.mjs";
|
|
3
|
+
//#region src/models/herald.model.d.ts
|
|
4
4
|
export type Herald<Events extends Record<string, GenericCallback>> = {
|
|
5
5
|
readonly events: HeraldEvents<Events>;
|
|
6
6
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SUBSCRIPTION_NAME } from "
|
|
2
|
-
//#region src/
|
|
1
|
+
import { SUBSCRIPTION_NAME } from "./subscription.model.mjs";
|
|
2
|
+
//#region src/models/herald.model.ts
|
|
3
3
|
const HERALD_MESSAGE_ARRAY = "Herald requires an array of event names.";
|
|
4
4
|
const HERALD_MESSAGE_ONCREATE = `Herald requires a valid onCreate callback for subscription creation`;
|
|
5
5
|
const HERALD_MESSAGE_PROPERTY = `Herald requires valid property information for subscription identification`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region src/models.d.ts
|
|
1
|
+
//#region src/models/index.d.ts
|
|
2
2
|
/**
|
|
3
3
|
* A generic array or object
|
|
4
4
|
*/
|
|
@@ -13,6 +13,10 @@ export type BuiltIns = void | Date | Primitive | RegExp;
|
|
|
13
13
|
* A generic class constructor
|
|
14
14
|
*/
|
|
15
15
|
export type Constructor<Instance = unknown> = new (...args: any[]) => Instance;
|
|
16
|
+
/**
|
|
17
|
+
* A frozen value with readonly properties _(going as deep as possible)_
|
|
18
|
+
*/
|
|
19
|
+
export type Frozen<Value> = Value extends unknown[] ? Readonly<Value> : Value extends PlainObject ? { readonly [Key in keyof Value]: Frozen<Value[Key]>; } : Value extends Map<infer Key, infer Value> ? ReadonlyMap<Key, Frozen<Value>> : Value extends Set<infer Item> ? ReadonlySet<Frozen<Item>> : Readonly<Value>;
|
|
16
20
|
/**
|
|
17
21
|
* A generic async callback function
|
|
18
22
|
*/
|
|
@@ -63,7 +67,7 @@ type _NestedValue<Value, Path extends string> = Path extends `${infer ItemKey}.$
|
|
|
63
67
|
/**
|
|
64
68
|
* The nested _(keyed)_ values of an object _(up to 5 levels deep)_
|
|
65
69
|
*/
|
|
66
|
-
export type NestedValues<Value extends PlainObject> = { [Path in NestedKeys<Value>]: NestedValue<Value, Path>; }
|
|
70
|
+
export type NestedValues<Value extends PlainObject> = Simplify<{ [Path in NestedKeys<Value>]: NestedValue<Value, Path>; }>;
|
|
67
71
|
/**
|
|
68
72
|
* The numerical keys of an object
|
|
69
73
|
*/
|
|
@@ -71,53 +75,7 @@ export type NumericalKeys<Value> = { [ItemKey in keyof Value]: ItemKey extends n
|
|
|
71
75
|
/**
|
|
72
76
|
* The numerical values of an object
|
|
73
77
|
*/
|
|
74
|
-
export type NumericalValues<Item extends PlainObject> = { [ItemKey in keyof Item as Item[ItemKey] extends number ? ItemKey : never]: Item[ItemKey]; }
|
|
75
|
-
/**
|
|
76
|
-
* An asynchronous function that can only be called once, returning the same value on subsequent calls
|
|
77
|
-
*/
|
|
78
|
-
export type OnceAsync<Callback extends GenericAsyncCallback> = {
|
|
79
|
-
/**
|
|
80
|
-
* Did the callback's promise reject?
|
|
81
|
-
*/
|
|
82
|
-
readonly error: boolean;
|
|
83
|
-
/**
|
|
84
|
-
* Has the callback finished?
|
|
85
|
-
*/
|
|
86
|
-
readonly finished: boolean;
|
|
87
|
-
/**
|
|
88
|
-
* Run the callback
|
|
89
|
-
*
|
|
90
|
-
* @param parameters Callback parameters
|
|
91
|
-
* @returns Call result
|
|
92
|
-
*/
|
|
93
|
-
run(...parameters: Parameters<Callback>): ReturnType<Callback>;
|
|
94
|
-
} & OnceProperties;
|
|
95
|
-
/**
|
|
96
|
-
* A callback function that can only be called once, returning the same value on subsequent calls
|
|
97
|
-
*/
|
|
98
|
-
export type Once<Callback extends GenericCallback> = {
|
|
99
|
-
/**
|
|
100
|
-
* Run the callback
|
|
101
|
-
*
|
|
102
|
-
* @param parameters Callback parameters
|
|
103
|
-
* @returns Call result
|
|
104
|
-
*/
|
|
105
|
-
run(...parameters: Parameters<Callback>): ReturnType<Callback>;
|
|
106
|
-
} & OnceProperties;
|
|
107
|
-
type OnceProperties = {
|
|
108
|
-
/**
|
|
109
|
-
* Has the callback been called?
|
|
110
|
-
*/
|
|
111
|
-
readonly called: boolean;
|
|
112
|
-
/**
|
|
113
|
-
* Has the callback's value been cleared?
|
|
114
|
-
*/
|
|
115
|
-
readonly cleared: boolean;
|
|
116
|
-
/**
|
|
117
|
-
* Clear the callback's cached value
|
|
118
|
-
*/
|
|
119
|
-
clear(): void;
|
|
120
|
-
};
|
|
78
|
+
export type NumericalValues<Item extends PlainObject> = Simplify<{ [ItemKey in keyof Item as Item[ItemKey] extends number ? ItemKey : never]: Item[ItemKey]; }>;
|
|
121
79
|
/**
|
|
122
80
|
* A generic object
|
|
123
81
|
*/
|
|
@@ -131,7 +89,7 @@ export type Primitive = null | undefined | string | number | boolean | symbol |
|
|
|
131
89
|
/**
|
|
132
90
|
* Set required keys for a type
|
|
133
91
|
*/
|
|
134
|
-
export type RequiredKeys<Model extends object, Keys extends keyof Model> = Required<Pick<Model, Keys>> & Omit<Model, Keys
|
|
92
|
+
export type RequiredKeys<Model extends object, Keys extends keyof Model> = Simplify<Required<Pick<Model, Keys>> & Omit<Model, Keys>>;
|
|
135
93
|
/**
|
|
136
94
|
* Flattens the type to improve type hints in IDEs
|
|
137
95
|
*
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
//#region src/models/logger.model.d.ts
|
|
2
|
+
export type InternalTimeLogger = {
|
|
3
|
+
[LOGGER_SYMBOL]: TimeLoggerState;
|
|
4
|
+
} & TimeLogger;
|
|
5
|
+
export type Lumberjack = {
|
|
6
|
+
/**
|
|
7
|
+
* Log any number of values at the "debug" log level
|
|
8
|
+
*/
|
|
9
|
+
get debug(): typeof console.debug;
|
|
10
|
+
/**
|
|
11
|
+
* Log the value and shows all its properties
|
|
12
|
+
*/
|
|
13
|
+
get dir(): typeof console.dir;
|
|
14
|
+
/**
|
|
15
|
+
* Is logging to the console enabled? _(defaults to `true`)_
|
|
16
|
+
*/
|
|
17
|
+
get enabled(): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Enable or disable logging to the console
|
|
20
|
+
*/
|
|
21
|
+
set enabled(value: boolean);
|
|
22
|
+
/**
|
|
23
|
+
* Log any number of values at the "error" log level
|
|
24
|
+
*/
|
|
25
|
+
get error(): typeof console.error;
|
|
26
|
+
/**
|
|
27
|
+
* Log any number of values at the "info" log level
|
|
28
|
+
*/
|
|
29
|
+
get info(): typeof console.info;
|
|
30
|
+
/**
|
|
31
|
+
* Log any number of values at the "log" log level
|
|
32
|
+
*/
|
|
33
|
+
get log(): typeof console.log;
|
|
34
|
+
/**
|
|
35
|
+
* Log data as a table, with optional properties to use as columns
|
|
36
|
+
*/
|
|
37
|
+
get table(): typeof console.table;
|
|
38
|
+
/**
|
|
39
|
+
* Log any number of values together with a trace from where it was called
|
|
40
|
+
*/
|
|
41
|
+
get trace(): typeof console.trace;
|
|
42
|
+
/**
|
|
43
|
+
* Log any number of values at the "warn" log level
|
|
44
|
+
*/
|
|
45
|
+
get warn(): typeof console.warn;
|
|
46
|
+
/**
|
|
47
|
+
* Start a timed logger with a label
|
|
48
|
+
*
|
|
49
|
+
* @param label Label for the logger
|
|
50
|
+
* @returns _TimedLogger_ instance
|
|
51
|
+
*/
|
|
52
|
+
time(label: string): TimeLogger;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* A named timer that can be used to log durations to the console
|
|
56
|
+
*/
|
|
57
|
+
export type TimeLogger = {
|
|
58
|
+
/**
|
|
59
|
+
* Is the timer active? _(i.e. has it been started and not stopped, and is logging enabled?)_
|
|
60
|
+
*/
|
|
61
|
+
get active(): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Log the current duration of the timer _(ignored if logging is disabled)_
|
|
64
|
+
*/
|
|
65
|
+
get log(): () => void;
|
|
66
|
+
/**
|
|
67
|
+
* Stop the timer and logs the total duration
|
|
68
|
+
*
|
|
69
|
+
* _(Will always log the total duration, even if logging is disabled)_
|
|
70
|
+
*/
|
|
71
|
+
get stop(): () => void;
|
|
72
|
+
};
|
|
73
|
+
export type TimeLoggerState = {
|
|
74
|
+
isActive(): boolean;
|
|
75
|
+
label: string;
|
|
76
|
+
started: boolean;
|
|
77
|
+
stopped: boolean;
|
|
78
|
+
};
|
|
79
|
+
export declare const LOGGER_NAME = "Logger";
|
|
80
|
+
export declare const LOGGER_NAME_TIMED = "TimedLogger";
|
|
81
|
+
export declare const LOGGER_PROPERTY = "$logger";
|
|
82
|
+
export declare const LOGGER_SYMBOL: unique symbol;
|
|
83
|
+
//#endregion
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
//#region src/models/logger.model.ts
|
|
2
|
+
const LOGGER_NAME = "Logger";
|
|
3
|
+
const LOGGER_NAME_TIMED = "TimedLogger";
|
|
4
|
+
const LOGGER_PROPERTY = "$logger";
|
|
5
|
+
const LOGGER_SYMBOL = Symbol(LOGGER_PROPERTY);
|
|
6
|
+
//#endregion
|
|
7
|
+
export { LOGGER_NAME, LOGGER_NAME_TIMED, LOGGER_PROPERTY, LOGGER_SYMBOL };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/models/math.model.d.ts
|
|
2
|
+
export type Aggregation = {
|
|
3
|
+
array: boolean;
|
|
4
|
+
count: number;
|
|
5
|
+
first: boolean;
|
|
6
|
+
items?: Record<number, unknown[]>;
|
|
7
|
+
value: number;
|
|
8
|
+
};
|
|
9
|
+
export type AggregationCallback = (aggregation: Aggregation, value: number, notNumber: boolean, item?: unknown) => number;
|
|
10
|
+
export type AggregationType = "average" | "max" | "min" | "sum";
|
|
11
|
+
export type NonAverageAggregationType = "max" | "min" | "sum";
|
|
12
|
+
export declare const AGGREGATION_AVERAGE = "average";
|
|
13
|
+
export declare const AGGREGATION_MAX = "max";
|
|
14
|
+
export declare const AGGREGATION_MIN = "min";
|
|
15
|
+
export declare const AGGREGATION_SUM = "sum";
|
|
16
|
+
//#endregion
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
//#region src/models/math.model.ts
|
|
2
|
+
const AGGREGATION_AVERAGE = "average";
|
|
3
|
+
const AGGREGATION_MAX = "max";
|
|
4
|
+
const AGGREGATION_MIN = "min";
|
|
5
|
+
const AGGREGATION_SUM = "sum";
|
|
6
|
+
//#endregion
|
|
7
|
+
export { AGGREGATION_AVERAGE, AGGREGATION_MAX, AGGREGATION_MIN, AGGREGATION_SUM };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/models/misc.model.d.ts
|
|
2
|
+
export declare const EXPRESSION_INTEGER: RegExp;
|
|
3
|
+
export declare const EXPRESSION_NUMBER_BINARY: RegExp;
|
|
4
|
+
export declare const EXPRESSION_NUMBER_OCTAL: RegExp;
|
|
5
|
+
export declare const EXPRESSION_NUMBER_ZEROISH: RegExp;
|
|
6
|
+
export declare const EXPRESSION_NUMERICAL_PREFIX: RegExp;
|
|
7
|
+
export declare const EXPRESSION_WHITESPACE_MULTIPLE: RegExp;
|
|
8
|
+
export declare const EXPRESSION_WHITESPACE_ONLY: RegExp;
|
|
9
|
+
export declare const NUMBER_OCTAL_VALUE = 8;
|
|
10
|
+
//#endregion
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/models/misc.model.ts
|
|
2
|
+
const EXPRESSION_INTEGER = /^\d+$/;
|
|
3
|
+
const EXPRESSION_NUMBER_BINARY = /^0b[01]+$/i;
|
|
4
|
+
const EXPRESSION_NUMBER_OCTAL = /^0o[0-7]+$/i;
|
|
5
|
+
const EXPRESSION_NUMBER_ZEROISH = /^\s*0+\s*$/;
|
|
6
|
+
const EXPRESSION_NUMERICAL_PREFIX = /^\d/;
|
|
7
|
+
const EXPRESSION_WHITESPACE_MULTIPLE = /\s+/g;
|
|
8
|
+
const EXPRESSION_WHITESPACE_ONLY = /^\s*$/;
|
|
9
|
+
const NUMBER_OCTAL_VALUE = 8;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { EXPRESSION_INTEGER, EXPRESSION_NUMBER_BINARY, EXPRESSION_NUMBER_OCTAL, EXPRESSION_NUMBER_ZEROISH, EXPRESSION_NUMERICAL_PREFIX, EXPRESSION_WHITESPACE_MULTIPLE, EXPRESSION_WHITESPACE_ONLY, NUMBER_OCTAL_VALUE };
|