@oscarpalmer/atoms 0.220.0 → 0.222.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 -3
- package/dist/array/difference.mjs +1 -2
- package/dist/array/exists.d.mts +1 -3
- package/dist/array/exists.mjs +1 -2
- package/dist/array/filter.d.mts +1 -3
- package/dist/array/filter.mjs +1 -2
- package/dist/array/find.d.mts +1 -3
- package/dist/array/find.mjs +1 -2
- package/dist/array/first.d.mts +1 -3
- package/dist/array/first.mjs +1 -2
- package/dist/array/flatten.d.mts +1 -3
- package/dist/array/flatten.mjs +1 -2
- package/dist/array/from.d.mts +1 -3
- package/dist/array/from.mjs +1 -2
- package/dist/array/group-by.d.mts +1 -3
- package/dist/array/group-by.mjs +1 -2
- package/dist/array/insert.d.mts +1 -3
- package/dist/array/insert.mjs +1 -2
- package/dist/array/intersection.d.mts +1 -3
- package/dist/array/intersection.mjs +1 -2
- package/dist/array/last.d.mts +1 -3
- package/dist/array/last.mjs +1 -2
- package/dist/array/move.d.mts +1 -3
- package/dist/array/move.mjs +1 -2
- package/dist/array/partition.d.mts +1 -3
- package/dist/array/partition.mjs +1 -2
- package/dist/array/push.d.mts +0 -2
- package/dist/array/push.mjs +1 -2
- package/dist/array/reverse.d.mts +1 -3
- package/dist/array/reverse.mjs +1 -2
- package/dist/array/select.d.mts +0 -2
- package/dist/array/select.mjs +1 -2
- package/dist/array/single.d.mts +1 -3
- package/dist/array/single.mjs +1 -2
- package/dist/array/slice.d.mts +1 -3
- package/dist/array/slice.mjs +1 -2
- package/dist/array/sort.d.mts +0 -2
- package/dist/array/sort.mjs +1 -2
- package/dist/array/splice.d.mts +1 -3
- package/dist/array/splice.mjs +1 -2
- package/dist/array/swap.d.mts +0 -2
- package/dist/array/swap.mjs +1 -2
- package/dist/array/to-map.d.mts +1 -3
- package/dist/array/to-map.mjs +1 -2
- package/dist/array/to-record.d.mts +1 -3
- package/dist/array/to-record.mjs +1 -2
- package/dist/array/to-set.d.mts +1 -3
- package/dist/array/to-set.mjs +1 -2
- package/dist/array/toggle.d.mts +1 -3
- package/dist/array/toggle.mjs +1 -2
- package/dist/array/union.d.mts +1 -3
- package/dist/array/union.mjs +1 -2
- package/dist/array/unique.d.mts +1 -3
- package/dist/array/unique.mjs +1 -2
- package/dist/array/update.d.mts +1 -3
- package/dist/array/update.mjs +1 -2
- package/dist/beacon.d.mts +0 -2
- package/dist/beacon.mjs +2 -3
- package/dist/color/constants.d.mts +0 -2
- package/dist/color/constants.mjs +1 -2
- package/dist/color/index.d.mts +0 -2
- package/dist/color/index.mjs +1 -2
- package/dist/color/instance.d.mts +1 -3
- package/dist/color/instance.mjs +1 -2
- package/dist/color/misc/alpha.d.mts +1 -3
- package/dist/color/misc/alpha.mjs +1 -2
- package/dist/color/misc/format.d.mts +1 -3
- package/dist/color/misc/format.mjs +1 -2
- package/dist/color/misc/get.d.mts +1 -3
- package/dist/color/misc/get.mjs +1 -2
- package/dist/color/misc/is.d.mts +1 -3
- package/dist/color/misc/is.mjs +1 -2
- package/dist/color/misc/state.d.mts +1 -3
- package/dist/color/misc/state.mjs +1 -2
- package/dist/color/space/hex.d.mts +1 -3
- package/dist/color/space/hex.mjs +1 -2
- package/dist/color/space/hsl.d.mts +1 -3
- package/dist/color/space/hsl.mjs +1 -2
- package/dist/color/space/hwb.d.mts +1 -3
- package/dist/color/space/hwb.mjs +1 -2
- package/dist/color/space/rgb.d.mts +1 -3
- package/dist/color/space/rgb.mjs +1 -2
- package/dist/function/limit.d.mts +0 -2
- package/dist/function/limit.mjs +1 -2
- package/dist/function/once.d.mts +0 -2
- package/dist/function/once.mjs +1 -2
- package/dist/function/retry.d.mts +0 -2
- package/dist/function/retry.mjs +1 -2
- package/dist/index.d.mts +8 -266
- package/dist/index.mjs +211 -370
- package/dist/internal/aborter.d.mts +1 -3
- package/dist/internal/aborter.mjs +1 -2
- package/dist/internal/array/callbacks.d.mts +1 -3
- package/dist/internal/array/callbacks.mjs +1 -2
- package/dist/internal/array/chunk.d.mts +1 -3
- package/dist/internal/array/chunk.mjs +1 -2
- package/dist/internal/array/compact.d.mts +1 -3
- package/dist/internal/array/compact.mjs +1 -2
- package/dist/internal/array/find.d.mts +1 -3
- package/dist/internal/array/find.mjs +1 -2
- package/dist/internal/array/get.d.mts +1 -3
- package/dist/internal/array/get.mjs +1 -2
- package/dist/internal/array/group.d.mts +1 -3
- package/dist/internal/array/group.mjs +1 -2
- package/dist/internal/array/index-of.d.mts +1 -3
- package/dist/internal/array/index-of.mjs +1 -2
- package/dist/internal/array/insert.d.mts +1 -3
- package/dist/internal/array/insert.mjs +1 -2
- package/dist/internal/array/match.d.mts +1 -3
- package/dist/internal/array/match.mjs +1 -2
- package/dist/internal/array/overlap.d.mts +1 -3
- package/dist/internal/array/overlap.mjs +1 -2
- package/dist/internal/array/sets.d.mts +1 -3
- package/dist/internal/array/sets.mjs +1 -2
- package/dist/internal/array/shuffle.d.mts +1 -3
- package/dist/internal/array/shuffle.mjs +1 -2
- package/dist/internal/array/update.d.mts +1 -3
- package/dist/internal/array/update.mjs +1 -2
- package/dist/internal/defaults.d.mts +1 -3
- package/dist/internal/defaults.mjs +1 -2
- package/dist/internal/function/assert.d.mts +0 -2
- package/dist/internal/function/assert.mjs +2 -5
- package/dist/internal/function/limit.d.mts +1 -3
- package/dist/internal/function/limit.mjs +1 -2
- package/dist/internal/function/memoize.d.mts +0 -2
- package/dist/internal/function/memoize.mjs +1 -2
- package/dist/internal/function/misc.d.mts +1 -2
- package/dist/internal/function/misc.mjs +7 -3
- package/dist/internal/function/work.d.mts +0 -2
- package/dist/internal/function/work.mjs +5 -13
- package/dist/internal/herald.d.mts +1 -3
- package/dist/internal/herald.mjs +1 -2
- package/dist/internal/is.d.mts +1 -3
- package/dist/internal/is.mjs +1 -2
- package/dist/internal/math/aggregate.d.mts +1 -3
- package/dist/internal/math/aggregate.mjs +1 -2
- package/dist/internal/math/misc.d.mts +1 -3
- package/dist/internal/math/misc.mjs +1 -2
- package/dist/internal/number.d.mts +1 -3
- package/dist/internal/number.mjs +1 -2
- package/dist/internal/plan/index.d.mts +1 -3
- package/dist/internal/plan/index.mjs +1 -2
- package/dist/internal/plan/plan.generate.d.mts +1 -3
- package/dist/internal/plan/plan.generate.mjs +2 -3
- package/dist/internal/random.d.mts +1 -3
- package/dist/internal/random.mjs +1 -2
- package/dist/internal/result/attempt.d.mts +1 -3
- package/dist/internal/result/attempt.mjs +1 -2
- package/dist/internal/result/misc.d.mts +1 -3
- package/dist/internal/result/misc.mjs +1 -2
- package/dist/internal/sized/map.d.mts +1 -3
- package/dist/internal/sized/map.mjs +1 -2
- package/dist/internal/sized/misc.d.mts +1 -3
- package/dist/internal/sized/misc.mjs +1 -2
- package/dist/internal/string/case.d.mts +3 -3
- package/dist/internal/string/case.mjs +37 -31
- package/dist/internal/string/misc.d.mts +1 -3
- package/dist/internal/string/misc.mjs +2 -3
- package/dist/internal/subscription.d.mts +1 -3
- package/dist/internal/subscription.mjs +3 -8
- package/dist/internal/value/compare.d.mts +1 -3
- package/dist/internal/value/compare.mjs +1 -2
- package/dist/internal/value/equal.d.mts +0 -2
- package/dist/internal/value/equal.mjs +1 -2
- package/dist/internal/value/get.d.mts +1 -3
- package/dist/internal/value/get.mjs +1 -2
- package/dist/internal/value/handlers.d.mts +1 -3
- package/dist/internal/value/handlers.mjs +1 -2
- package/dist/internal/value/has.d.mts +1 -3
- package/dist/internal/value/has.mjs +1 -2
- package/dist/internal/value/misc.d.mts +1 -3
- package/dist/internal/value/misc.mjs +2 -3
- package/dist/internal/value/partial.d.mts +1 -3
- package/dist/internal/value/partial.mjs +1 -2
- package/dist/internal/value/set.d.mts +1 -3
- package/dist/internal/value/set.mjs +1 -2
- package/dist/is.d.mts +0 -2
- package/dist/is.mjs +1 -2
- package/dist/logger.d.mts +0 -2
- package/dist/logger.mjs +1 -2
- package/dist/math.d.mts +0 -2
- package/dist/math.mjs +1 -2
- package/dist/models/aborter.model.d.mts +1 -3
- package/dist/models/aborter.model.mjs +1 -2
- package/dist/models/array/array.find.model.d.mts +1 -3
- package/dist/models/array/array.find.model.mjs +1 -2
- package/dist/models/array/array.match.model.d.mts +1 -3
- package/dist/models/array/array.match.model.mjs +1 -2
- package/dist/models/array/array.misc.model.d.mts +1 -3
- package/dist/models/array/array.misc.model.mjs +1 -2
- package/dist/models/array/array.sort.model.d.mts +1 -3
- package/dist/models/array/array.sort.model.mjs +1 -2
- package/dist/models/beacon.model.d.mts +1 -3
- package/dist/models/beacon.model.mjs +1 -2
- package/dist/models/color.model.d.mts +0 -2
- package/dist/models/function/assert.model.d.mts +1 -3
- package/dist/models/function/assert.model.mjs +1 -2
- package/dist/models/function/limiter.model.d.mts +1 -3
- package/dist/models/function/limiter.model.mjs +1 -2
- package/dist/models/function/memoize.model.d.mts +1 -3
- package/dist/models/function/memoize.model.mjs +1 -2
- package/dist/models/function/once.model.d.mts +0 -2
- package/dist/models/function/once.model.mjs +1 -2
- package/dist/models/function/retry.model.d.mts +1 -3
- package/dist/models/function/retry.model.mjs +1 -2
- package/dist/models/function/work.model.d.mts +1 -3
- package/dist/models/function/work.model.mjs +1 -2
- package/dist/models/herald.model.d.mts +1 -3
- package/dist/models/herald.model.mjs +1 -2
- package/dist/models/index.d.mts +0 -2
- package/dist/models/logger.model.d.mts +1 -3
- package/dist/models/logger.model.mjs +1 -2
- package/dist/models/math.model.d.mts +1 -3
- package/dist/models/math.model.mjs +1 -2
- package/dist/models/misc.model.d.mts +1 -3
- package/dist/models/misc.model.mjs +1 -2
- package/dist/models/plan.model.d.mts +0 -2
- package/dist/models/plan.model.mjs +1 -2
- package/dist/models/promise.model.d.mts +1 -3
- package/dist/models/promise.model.mjs +1 -2
- package/dist/models/query.model.d.mts +1 -3
- package/dist/models/query.model.mjs +1 -2
- package/dist/models/queue.model.d.mts +0 -2
- package/dist/models/queue.model.mjs +1 -2
- package/dist/models/random.model.d.mts +1 -3
- package/dist/models/random.model.mjs +1 -2
- package/dist/models/result.model.d.mts +0 -2
- package/dist/models/string/string.case.model.d.mts +8 -5
- package/dist/models/string/string.case.model.mjs +10 -6
- package/dist/models/string/string.fuzzy.model.d.mts +0 -2
- package/dist/models/string/string.fuzzy.model.mjs +1 -2
- package/dist/models/string/string.misc.model.d.mts +1 -3
- package/dist/models/string/string.misc.model.mjs +2 -3
- package/dist/models/string/string.normalize.model.d.mts +1 -3
- package/dist/models/string/string.normalize.model.mjs +1 -2
- package/dist/models/string/string.template.model.d.mts +1 -3
- package/dist/models/string/string.template.model.mjs +2 -3
- package/dist/models/subscription.model.d.mts +1 -3
- package/dist/models/subscription.model.mjs +1 -2
- package/dist/models/value/value.clone.model.d.mts +1 -3
- package/dist/models/value/value.clone.model.mjs +1 -2
- package/dist/models/value/value.diff.model.d.mts +1 -3
- package/dist/models/value/value.diff.model.mjs +1 -2
- package/dist/models/value/value.equal.model.d.mts +0 -2
- package/dist/models/value/value.equal.model.mjs +1 -2
- package/dist/models/value/value.handler.model.d.mts +1 -3
- package/dist/models/value/value.merge.model.d.mts +0 -2
- package/dist/models/value/value.merge.model.mjs +1 -2
- package/dist/models/value/value.misc.model.d.mts +0 -2
- package/dist/models/value/value.misc.model.mjs +1 -2
- package/dist/models/value/value.transform.model.d.mts +1 -3
- package/dist/models/value/value.transform.model.mjs +1 -2
- package/dist/plan/index.d.mts +1 -3
- package/dist/plan/index.mjs +1 -2
- package/dist/plan/is.d.mts +1 -3
- package/dist/plan/is.mjs +1 -2
- package/dist/plan/misc.d.mts +1 -3
- package/dist/plan/misc.mjs +1 -2
- package/dist/plan/result.d.mts +1 -3
- package/dist/plan/result.mjs +1 -2
- package/dist/plan/run.d.mts +1 -3
- package/dist/plan/run.mjs +1 -2
- package/dist/plan/use.d.mts +1 -3
- package/dist/plan/use.mjs +1 -2
- package/dist/promise/delay.d.mts +1 -3
- package/dist/promise/delay.mjs +1 -2
- package/dist/promise/helpers.d.mts +1 -3
- package/dist/promise/helpers.mjs +1 -2
- package/dist/promise/index.d.mts +0 -2
- package/dist/promise/index.mjs +1 -2
- package/dist/promise/misc.d.mts +0 -2
- package/dist/promise/misc.mjs +1 -2
- package/dist/promise/timed.d.mts +1 -3
- package/dist/promise/timed.mjs +1 -2
- package/dist/query.d.mts +1 -3
- package/dist/query.mjs +1 -2
- package/dist/queue.d.mts +0 -2
- package/dist/queue.mjs +1 -2
- package/dist/random.d.mts +0 -2
- package/dist/random.mjs +1 -2
- package/dist/result/match.d.mts +1 -3
- package/dist/result/match.mjs +1 -2
- package/dist/result/misc.d.mts +0 -2
- package/dist/result/misc.mjs +1 -2
- package/dist/result/work/flow.d.mts +1 -3
- package/dist/result/work/flow.mjs +4 -11
- package/dist/result/work/pipe.d.mts +0 -2
- package/dist/result/work/pipe.mjs +1 -2
- package/dist/sized/set.d.mts +1 -3
- package/dist/sized/set.mjs +1 -2
- package/dist/string/fuzzy.d.mts +0 -2
- package/dist/string/fuzzy.mjs +1 -2
- package/dist/string/index.d.mts +0 -2
- package/dist/string/index.mjs +1 -2
- package/dist/string/match.d.mts +1 -3
- package/dist/string/match.mjs +1 -2
- package/dist/string/normalize.d.mts +0 -2
- package/dist/string/normalize.mjs +1 -2
- package/dist/string/template.d.mts +0 -2
- package/dist/string/template.mjs +1 -2
- package/dist/value/clone.d.mts +0 -2
- package/dist/value/clone.mjs +1 -2
- package/dist/value/collection.d.mts +1 -3
- package/dist/value/collection.mjs +1 -2
- package/dist/value/diff.d.mts +0 -2
- package/dist/value/diff.mjs +1 -2
- package/dist/value/freeze.d.mts +1 -3
- package/dist/value/freeze.mjs +2 -3
- package/dist/value/merge.d.mts +0 -2
- package/dist/value/merge.mjs +1 -2
- package/dist/value/omit.d.mts +1 -3
- package/dist/value/omit.mjs +1 -2
- package/dist/value/pick.d.mts +1 -3
- package/dist/value/pick.mjs +1 -2
- package/dist/value/shake.d.mts +0 -2
- package/dist/value/shake.mjs +1 -2
- package/dist/value/smush.d.mts +0 -2
- package/dist/value/smush.mjs +1 -2
- package/dist/value/transform.d.mts +0 -2
- package/dist/value/transform.mjs +1 -2
- package/dist/value/unsmush.d.mts +0 -2
- package/dist/value/unsmush.mjs +1 -2
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/internal/math/misc.ts
|
|
2
2
|
/**
|
|
3
3
|
* Round a number down
|
|
4
4
|
*
|
|
@@ -39,5 +39,4 @@ function roundNumber(callback, value, decimals) {
|
|
|
39
39
|
const mod = 10 ** decimals;
|
|
40
40
|
return callback((value + Number.EPSILON) * mod) / mod;
|
|
41
41
|
}
|
|
42
|
-
//#endregion
|
|
43
42
|
export { floor, round, roundNumber };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/internal/number.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Is the number between a minimum and maximum value?
|
|
4
3
|
*
|
|
@@ -50,5 +49,4 @@ export declare function clamp(value: number, minimum: number, maximum: number, l
|
|
|
50
49
|
* getNumber(() => 123) // => 123
|
|
51
50
|
* ```
|
|
52
51
|
*/
|
|
53
|
-
export declare function getNumber(value: unknown): number;
|
|
54
|
-
//#endregion
|
|
52
|
+
export declare function getNumber(value: unknown): number;
|
package/dist/internal/number.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isNumber } from "./is.mjs";
|
|
2
2
|
import { max, min } from "./math/aggregate.mjs";
|
|
3
3
|
import { EXPRESSION_NUMBER_BINARY, EXPRESSION_NUMBER_OCTAL, EXPRESSION_NUMBER_ZEROISH } from "../models/misc.model.mjs";
|
|
4
|
-
|
|
4
|
+
// src/internal/number.ts
|
|
5
5
|
/**
|
|
6
6
|
* Is the number between a minimum and maximum value?
|
|
7
7
|
*
|
|
@@ -85,5 +85,4 @@ function getNumber(value) {
|
|
|
85
85
|
if (isBinary || EXPRESSION_NUMBER_OCTAL.test(trimmed)) return Number.parseInt(trimmed.slice(2), isBinary ? 2 : 8);
|
|
86
86
|
return Number(trimmed);
|
|
87
87
|
}
|
|
88
|
-
//#endregion
|
|
89
88
|
export { between, clamp, getNumber };
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { GenericPlanItem, InternalAsyncPlan, InternalPlan } from "../../models/plan.model.mjs";
|
|
2
|
-
//#region src/internal/plan/index.d.ts
|
|
3
2
|
export declare function attemptRunPlan(this: InternalPlan, ...parameters: unknown[]): unknown;
|
|
4
3
|
export declare function getGenerator(this: GenericPlanItem): AsyncGenerator | Generator;
|
|
5
4
|
export declare function runAsyncPlan(this: InternalAsyncPlan, first: never, second: never): Promise<unknown>;
|
|
6
|
-
export declare function runPlan(this: InternalPlan, ...parameters: unknown[]): unknown;
|
|
7
|
-
//#endregion
|
|
5
|
+
export declare function runPlan(this: InternalPlan, ...parameters: unknown[]): unknown;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { attempt } from "../result/attempt.mjs";
|
|
2
2
|
import { PLAN_SYMBOL } from "../../models/plan.model.mjs";
|
|
3
3
|
import { asyncGenerate, generate } from "./plan.generate.mjs";
|
|
4
|
-
|
|
4
|
+
// src/internal/plan/index.ts
|
|
5
5
|
function attemptRunPlan(...parameters) {
|
|
6
6
|
return attempt(() => generate(this[PLAN_SYMBOL], parameters, true));
|
|
7
7
|
}
|
|
@@ -14,5 +14,4 @@ function runAsyncPlan(first, second) {
|
|
|
14
14
|
function runPlan(...parameters) {
|
|
15
15
|
return generate(this[PLAN_SYMBOL], parameters, false);
|
|
16
16
|
}
|
|
17
|
-
//#endregion
|
|
18
17
|
export { attemptRunPlan, getGenerator, runAsyncPlan, runPlan };
|
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import { AsyncPlanState, PlanState } from "../../models/plan.model.mjs";
|
|
2
|
-
//#region src/internal/plan/plan.generate.d.ts
|
|
3
2
|
export declare function asyncGenerate(input: AsyncPlanState | ((...args: unknown[]) => AsyncGenerator), unwrap: boolean, first?: unknown, second?: unknown): Promise<unknown>;
|
|
4
|
-
export declare function generate(input: PlanState | ((...parameters: unknown[]) => Generator), parameters: unknown[], unwrap: boolean): unknown;
|
|
5
|
-
//#endregion
|
|
3
|
+
export declare function generate(input: PlanState | ((...parameters: unknown[]) => Generator), parameters: unknown[], unwrap: boolean): unknown;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { isError, isOk } from "../result/misc.mjs";
|
|
1
2
|
import { noop } from "../function/misc.mjs";
|
|
2
3
|
import { createAborter } from "../aborter.mjs";
|
|
3
|
-
|
|
4
|
-
//#region src/internal/plan/plan.generate.ts
|
|
4
|
+
// src/internal/plan/plan.generate.ts
|
|
5
5
|
async function asyncGenerate(input, unwrap, first, second) {
|
|
6
6
|
const aborter = createAborter(second ?? first, noop);
|
|
7
7
|
if (aborter?.signal.aborted) throw aborter.signal.reason;
|
|
@@ -58,5 +58,4 @@ function generate(input, parameters, unwrap) {
|
|
|
58
58
|
if (success) return unwrap && isOk(lastValue) ? lastValue.value : lastValue;
|
|
59
59
|
throw lastValue;
|
|
60
60
|
}
|
|
61
|
-
//#endregion
|
|
62
61
|
export { asyncGenerate, generate };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/internal/random.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Get a random number between 0 _(inclusive)_ and 1 _(exclusive)_
|
|
4
3
|
*
|
|
@@ -20,5 +19,4 @@ export declare function getRandomFloatingNumber(minimum?: number, maximum?: numb
|
|
|
20
19
|
* @param maximum Maximum value
|
|
21
20
|
* @returns Random integer
|
|
22
21
|
*/
|
|
23
|
-
export declare function getRandomInteger(minimum?: number, maximum?: number): number;
|
|
24
|
-
//#endregion
|
|
22
|
+
export declare function getRandomInteger(minimum?: number, maximum?: number): number;
|
package/dist/internal/random.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isNumber } from "./is.mjs";
|
|
2
2
|
import { floor } from "./math/misc.mjs";
|
|
3
|
-
|
|
3
|
+
// src/internal/random.ts
|
|
4
4
|
/**
|
|
5
5
|
* Get a random number between 0 _(inclusive)_ and 1 _(exclusive)_
|
|
6
6
|
*
|
|
@@ -39,5 +39,4 @@ function getRandomInteger(minimum, maximum) {
|
|
|
39
39
|
return floor(getRandomFloatingNumberValue(true, minimum, maximum));
|
|
40
40
|
}
|
|
41
41
|
const RANDOM_DIVISOR = 2 ** 32;
|
|
42
|
-
//#endregion
|
|
43
42
|
export { getRandom, getRandomFloatingNumber, getRandomInteger };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ExtendedResult, Result } from "../../models/result.model.mjs";
|
|
2
|
-
//#region src/internal/result/attempt.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Executes a _Promise_, catching any errors, and returns a result
|
|
5
4
|
*
|
|
@@ -55,5 +54,4 @@ export declare function attempt<Value, E>(callback: () => Value, error: E): Exte
|
|
|
55
54
|
export declare function attempt<Value>(callback: () => Value): Result<Value, Error>;
|
|
56
55
|
export declare namespace attempt {
|
|
57
56
|
export var async: typeof asyncAttempt;
|
|
58
|
-
}
|
|
59
|
-
//#endregion
|
|
57
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getError, ok } from "./misc.mjs";
|
|
2
|
-
|
|
2
|
+
// src/internal/result/attempt.ts
|
|
3
3
|
async function asyncAttempt(value, err) {
|
|
4
4
|
try {
|
|
5
5
|
let result;
|
|
@@ -20,5 +20,4 @@ function attempt(callback, err) {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
attempt.async = asyncAttempt;
|
|
23
|
-
//#endregion
|
|
24
23
|
export { asyncAttempt, attempt };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Err, ExtendedErr, Ok, Result } from "../../models/result.model.mjs";
|
|
2
|
-
//#region src/internal/result/misc.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Creates an extended error result
|
|
5
4
|
*
|
|
@@ -96,5 +95,4 @@ export declare namespace error {
|
|
|
96
95
|
}
|
|
97
96
|
export declare namespace ok {
|
|
98
97
|
export var is: typeof isOk;
|
|
99
|
-
}
|
|
100
|
-
//#endregion
|
|
98
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isPlainObject } from "../is.mjs";
|
|
2
|
-
|
|
2
|
+
// src/internal/result/misc.ts
|
|
3
3
|
function error(value, original) {
|
|
4
4
|
return getError(value, original);
|
|
5
5
|
}
|
|
@@ -48,5 +48,4 @@ const RESULT_PROPERTY_ERROR = "error";
|
|
|
48
48
|
const RESULT_PROPERTY_VALUE = "value";
|
|
49
49
|
error.is = isError;
|
|
50
50
|
ok.is = isOk;
|
|
51
|
-
//#endregion
|
|
52
51
|
export { error, getError, isError, isOk, isResult, ok, unwrap };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/internal/sized/map.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* A _Map_ with a maximum size
|
|
4
3
|
*
|
|
@@ -44,5 +43,4 @@ export declare class SizedMap<SizedKey = unknown, SizedValue = unknown> extends
|
|
|
44
43
|
* @inheritdoc
|
|
45
44
|
*/
|
|
46
45
|
override set(key: SizedKey, value: SizedValue): this;
|
|
47
|
-
}
|
|
48
|
-
//#endregion
|
|
46
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getSizedMaximum } from "./misc.mjs";
|
|
2
|
-
|
|
2
|
+
// src/internal/sized/map.ts
|
|
3
3
|
/**
|
|
4
4
|
* A _Map_ with a maximum size
|
|
5
5
|
*
|
|
@@ -53,5 +53,4 @@ var SizedMap = class extends Map {
|
|
|
53
53
|
return this;
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
|
-
//#endregion
|
|
57
56
|
export { SizedMap };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { clamp } from "../number.mjs";
|
|
2
|
-
|
|
2
|
+
// src/internal/sized/misc.ts
|
|
3
3
|
function getSizedMaximum(first, second) {
|
|
4
4
|
let actual;
|
|
5
5
|
if (typeof first === "number") actual = first;
|
|
@@ -8,5 +8,4 @@ function getSizedMaximum(first, second) {
|
|
|
8
8
|
}
|
|
9
9
|
const SIZED_MAXIMUM_ABSOLUTE = 16777216;
|
|
10
10
|
const SIZED_MAXIMUM_DEFAULT = 1048576;
|
|
11
|
-
//#endregion
|
|
12
11
|
export { getSizedMaximum };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { StringCaseOptions } from "../../models/string/string.case.model.mjs";
|
|
2
2
|
/**
|
|
3
3
|
* Convert a string to camel case _(thisIsCamelCase)_
|
|
4
4
|
*
|
|
@@ -103,6 +103,7 @@ export declare function snakeCase(value: string): string;
|
|
|
103
103
|
* ```
|
|
104
104
|
*/
|
|
105
105
|
export declare function titleCase(value: string): string;
|
|
106
|
+
export declare function toCaseCallback(this: StringCaseOptions, value: string): string;
|
|
106
107
|
/**
|
|
107
108
|
* Convert a string to upper case
|
|
108
109
|
*
|
|
@@ -117,5 +118,4 @@ export declare function titleCase(value: string): string;
|
|
|
117
118
|
* upperCase(''); // => ''
|
|
118
119
|
* ```
|
|
119
120
|
*/
|
|
120
|
-
export declare function upperCase(value: string): string;
|
|
121
|
-
//#endregion
|
|
121
|
+
export declare function upperCase(value: string): string;
|
|
@@ -1,7 +1,7 @@
|
|
|
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";
|
|
4
|
-
|
|
3
|
+
import { STRING_CASE_CAMEL, STRING_CASE_CAPITALIZE, STRING_CASE_KEBAB, STRING_CASE_LOWER, STRING_CASE_PASCAL, STRING_CASE_SNAKE, STRING_CASE_TITLE, STRING_CASE_UPPER, STRING_EXPRESSION_ACRONYM, STRING_EXPRESSION_CAMEL_CASE, STRING_REPLACEMENT_CAMEL_CASE, ignoreCachingCases } from "../../models/string/string.case.model.mjs";
|
|
4
|
+
// src/internal/string/case.ts
|
|
5
5
|
/**
|
|
6
6
|
* Convert a string to camel case _(thisIsCamelCase)_
|
|
7
7
|
*
|
|
@@ -34,9 +34,11 @@ function camelCase(value) {
|
|
|
34
34
|
* ```
|
|
35
35
|
*/
|
|
36
36
|
function capitalize(value) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
return toCase(STRING_CASE_CAPITALIZE, value, true, true, capitalizeHandler);
|
|
38
|
+
}
|
|
39
|
+
function capitalizeHandler(value) {
|
|
40
|
+
if (value.length === 1) return value.toLocaleUpperCase();
|
|
41
|
+
return `${value.charAt(0).toLocaleUpperCase()}${value.slice(1).toLocaleLowerCase()}`;
|
|
40
42
|
}
|
|
41
43
|
/**
|
|
42
44
|
* Convert a string to kebab case _(this-is-kebab-case)_
|
|
@@ -69,9 +71,10 @@ function kebabCase(value) {
|
|
|
69
71
|
* ```
|
|
70
72
|
*/
|
|
71
73
|
function lowerCase(value) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
return toCase(STRING_CASE_LOWER, value, false, false, lowerCaseHandler);
|
|
75
|
+
}
|
|
76
|
+
function lowerCaseHandler(value) {
|
|
77
|
+
return value.toLocaleLowerCase();
|
|
75
78
|
}
|
|
76
79
|
/**
|
|
77
80
|
* Convert a string to pascal case _(ThisIsPascalCase)_
|
|
@@ -122,33 +125,39 @@ function snakeCase(value) {
|
|
|
122
125
|
* ```
|
|
123
126
|
*/
|
|
124
127
|
function titleCase(value) {
|
|
125
|
-
|
|
126
|
-
memoizedTitleCase ??= memoize((v) => v.length < 2 ? capitalize(v) : join(words(v).map(capitalize), " "));
|
|
127
|
-
return memoizedTitleCase.run(value);
|
|
128
|
+
return toCase(STRING_CASE_TITLE, value, true, true, titleCaseHandler);
|
|
128
129
|
}
|
|
129
|
-
function
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
capitalizeAny,
|
|
133
|
-
capitalizeFirst
|
|
134
|
-
}));
|
|
135
|
-
return caseMemoizers[type].run(value);
|
|
130
|
+
function titleCaseHandler(value) {
|
|
131
|
+
if (value.length < 2) return capitalize(value);
|
|
132
|
+
return join(words(value).map(capitalize), " ");
|
|
136
133
|
}
|
|
137
|
-
function
|
|
134
|
+
function toCase(type, value, capitalizeAny, capitalizeFirst, handler) {
|
|
138
135
|
if (typeof value !== "string") return "";
|
|
139
|
-
if (value.length
|
|
136
|
+
if (value.trim().length === 0) return value;
|
|
137
|
+
if (handler == null) {
|
|
138
|
+
caseMemoizers[type] ??= memoize(toCaseCallback.bind({
|
|
139
|
+
type,
|
|
140
|
+
capitalizeAny,
|
|
141
|
+
capitalizeFirst
|
|
142
|
+
}));
|
|
143
|
+
return caseMemoizers[type].run(value);
|
|
144
|
+
}
|
|
145
|
+
if (ignoreCachingCases.has(type)) return handler(value);
|
|
146
|
+
simpleMemoizers[type] ??= memoize(handler);
|
|
147
|
+
return simpleMemoizers[type].run(value);
|
|
148
|
+
}
|
|
149
|
+
function toCaseCallback(value) {
|
|
140
150
|
const { capitalizeAny, capitalizeFirst, type } = this;
|
|
141
151
|
const parts = words(value);
|
|
142
152
|
const partsLength = parts.length;
|
|
143
153
|
const cased = [];
|
|
144
154
|
for (let partIndex = 0; partIndex < partsLength; partIndex += 1) {
|
|
145
|
-
const items = parts[partIndex].replace(STRING_EXPRESSION_ACRONYM,
|
|
155
|
+
const items = parts[partIndex].replace(STRING_EXPRESSION_ACRONYM, "-").replace(STRING_EXPRESSION_CAMEL_CASE, STRING_REPLACEMENT_CAMEL_CASE).split("-");
|
|
146
156
|
const itemsLength = items.length;
|
|
147
157
|
const partResult = [];
|
|
148
158
|
let itemCount = 0;
|
|
149
159
|
for (let itemIndex = 0; itemIndex < itemsLength; itemIndex += 1) {
|
|
150
160
|
const item = items[itemIndex];
|
|
151
|
-
if (item.length === 0) continue;
|
|
152
161
|
if (!capitalizeAny || itemCount === 0 && partIndex === 0 && !capitalizeFirst) partResult.push(item.toLocaleLowerCase());
|
|
153
162
|
else partResult.push(capitalize(item));
|
|
154
163
|
itemCount += 1;
|
|
@@ -172,9 +181,10 @@ function toCaseCallback(value) {
|
|
|
172
181
|
* ```
|
|
173
182
|
*/
|
|
174
183
|
function upperCase(value) {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
184
|
+
return toCase(STRING_CASE_UPPER, value, false, false, upperCaseHandler);
|
|
185
|
+
}
|
|
186
|
+
function upperCaseHandler(value) {
|
|
187
|
+
return value.toLocaleUpperCase();
|
|
178
188
|
}
|
|
179
189
|
const caseMemoizers = {};
|
|
180
190
|
const delimiters = {
|
|
@@ -183,9 +193,5 @@ const delimiters = {
|
|
|
183
193
|
[STRING_CASE_PASCAL]: "",
|
|
184
194
|
[STRING_CASE_SNAKE]: "_"
|
|
185
195
|
};
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
let memoizedTitleCase;
|
|
189
|
-
let memoizedUpperCase;
|
|
190
|
-
//#endregion
|
|
191
|
-
export { camelCase, capitalize, kebabCase, lowerCase, pascalCase, snakeCase, titleCase, upperCase };
|
|
196
|
+
const simpleMemoizers = {};
|
|
197
|
+
export { camelCase, capitalize, kebabCase, lowerCase, pascalCase, snakeCase, titleCase, toCaseCallback, upperCase };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/internal/string/misc.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Get the string value from any value
|
|
4
3
|
*
|
|
@@ -57,5 +56,4 @@ export declare function tryEncode(value: boolean | number | string): unknown;
|
|
|
57
56
|
* @param value Original string
|
|
58
57
|
* @returns Array of words found in the string
|
|
59
58
|
*/
|
|
60
|
-
export declare function words(value: string): string[];
|
|
61
|
-
//#endregion
|
|
59
|
+
export declare function words(value: string): string[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { STRING_EXPRESSION_IGNORED, STRING_EXPRESSION_WORDS } from "../../models/string/string.misc.model.mjs";
|
|
2
1
|
import { unwrap } from "../result/misc.mjs";
|
|
2
|
+
import { STRING_EXPRESSION_IGNORED, STRING_EXPRESSION_WORDS } from "../../models/string/string.misc.model.mjs";
|
|
3
3
|
import { attempt } from "../result/attempt.mjs";
|
|
4
|
-
|
|
4
|
+
// src/internal/string/misc.ts
|
|
5
5
|
/**
|
|
6
6
|
* Get the string value from any value
|
|
7
7
|
*
|
|
@@ -98,5 +98,4 @@ function words(value) {
|
|
|
98
98
|
if (typeof value === "string") return value.match(STRING_EXPRESSION_WORDS) ?? [];
|
|
99
99
|
return [];
|
|
100
100
|
}
|
|
101
|
-
//#endregion
|
|
102
101
|
export { getString, ignoreKey, interpolate, join, tryDecode, tryEncode, words };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Subscription, Subscriptions, SubscriptionsParameters } from "../models/subscription.model.mjs";
|
|
2
|
-
//#region src/internal/subscription.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Is the value a subscription?
|
|
5
4
|
*
|
|
@@ -20,5 +19,4 @@ export declare function isSubscriptions(value: unknown): value is Subscriptions;
|
|
|
20
19
|
* @param parameters Store parameters
|
|
21
20
|
* @returns Subscription store
|
|
22
21
|
*/
|
|
23
|
-
export declare function subscriptions<Value = unknown>(parameters?: SubscriptionsParameters): Subscriptions<Value>;
|
|
24
|
-
//#endregion
|
|
22
|
+
export declare function subscriptions<Value = unknown>(parameters?: SubscriptionsParameters): Subscriptions<Value>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isKey, isPlainObject } from "./is.mjs";
|
|
2
2
|
import { SUBSCRIPTION_DISALLOWED_KEY, SUBSCRIPTION_INVALID_KEY, SUBSCRIPTION_INVALID_VALUE, SUBSCRIPTION_NAME, SUBSCRIPTION_PROPERTY, SUBSCRIPTION_STORE, SUBSCRIPTION_SYMBOL } from "../models/subscription.model.mjs";
|
|
3
3
|
import { createAborter } from "./aborter.mjs";
|
|
4
|
-
|
|
4
|
+
// src/internal/subscription.ts
|
|
5
5
|
function Subscription(state, property, parameters) {
|
|
6
6
|
this[SUBSCRIPTION_SYMBOL] = state;
|
|
7
7
|
this[property.key] = property.value;
|
|
@@ -42,9 +42,7 @@ function addSubscription(instance) {
|
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
44
|
/* istanbul ignore if */
|
|
45
|
-
if (items.keyed == null || values.from.keyed == null || values.to.keyed == null)
|
|
46
|
-
// istanbul ignore next
|
|
47
|
-
return;
|
|
45
|
+
if (items.keyed == null || values.from.keyed == null || values.to.keyed == null) return;
|
|
48
46
|
let keyedItems = items.keyed.get(key);
|
|
49
47
|
if (keyedItems == null) {
|
|
50
48
|
keyedItems = /* @__PURE__ */ new Set();
|
|
@@ -194,9 +192,7 @@ function removeSubscription() {
|
|
|
194
192
|
}
|
|
195
193
|
const keyed = items.keyed?.get(key);
|
|
196
194
|
/* istanbul ignore if */
|
|
197
|
-
if (items.keyed == null || keyed == null)
|
|
198
|
-
// istanbul ignore next
|
|
199
|
-
return;
|
|
195
|
+
if (items.keyed == null || keyed == null) return;
|
|
200
196
|
removeFromStore(keyed, values, this, value, key);
|
|
201
197
|
if (keyed.size === 0) items.keyed.delete(key);
|
|
202
198
|
}
|
|
@@ -209,5 +205,4 @@ function removeSubscription() {
|
|
|
209
205
|
function subscriptions(parameters) {
|
|
210
206
|
return new Subscriptions(parameters);
|
|
211
207
|
}
|
|
212
|
-
//#endregion
|
|
213
208
|
export { isSubscription, isSubscriptions, subscriptions };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Constructor } from "../../models/index.mjs";
|
|
2
2
|
import { CompareHandler } from "../../models/value/value.handler.model.mjs";
|
|
3
3
|
import { ComparisonHandler } from "../../models/value/value.misc.model.mjs";
|
|
4
|
-
//#region src/internal/value/compare.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Compare two values _(for sorting purposes)_
|
|
7
6
|
*
|
|
@@ -31,5 +30,4 @@ export declare namespace compare {
|
|
|
31
30
|
export var deregister: typeof deregisterComparator;
|
|
32
31
|
export var handler: CompareHandler<number>;
|
|
33
32
|
export var register: typeof registerComparator;
|
|
34
|
-
}
|
|
35
|
-
//#endregion
|
|
33
|
+
}
|
|
@@ -2,7 +2,7 @@ import { max } from "../math/aggregate.mjs";
|
|
|
2
2
|
import { COMPARE_NAME } from "../../models/value/value.misc.model.mjs";
|
|
3
3
|
import { getString, words } from "../string/misc.mjs";
|
|
4
4
|
import { createCompareHandler } from "./handlers.mjs";
|
|
5
|
-
|
|
5
|
+
// src/internal/value/compare.ts
|
|
6
6
|
/**
|
|
7
7
|
* Compare two values _(for sorting purposes)_
|
|
8
8
|
*
|
|
@@ -85,5 +85,4 @@ const compareHandler = createCompareHandler(compare, {
|
|
|
85
85
|
compare.deregister = deregisterComparator;
|
|
86
86
|
compare.handler = compareHandler;
|
|
87
87
|
compare.register = registerComparator;
|
|
88
|
-
//#endregion
|
|
89
88
|
export { compare, deregisterComparator, registerComparator };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Constructor } from "../../models/index.mjs";
|
|
2
2
|
import { CompareHandler } from "../../models/value/value.handler.model.mjs";
|
|
3
3
|
import { EqualOptions, Equalizer, EqualizerOptions } from "../../models/value/value.equal.model.mjs";
|
|
4
|
-
//#region src/internal/value/equal.d.ts
|
|
5
4
|
declare function Equalizer(this: any, options: EqualizerOptions): void;
|
|
6
5
|
/**
|
|
7
6
|
* Deregister a equality comparison handler for a specific class
|
|
@@ -53,5 +52,4 @@ export declare namespace equal {
|
|
|
53
52
|
export var initialize: typeof initializeEqualizer;
|
|
54
53
|
export var register: typeof registerEqualizer;
|
|
55
54
|
}
|
|
56
|
-
//#endregion
|
|
57
55
|
export type { EqualOptions, Equalizer };
|
|
@@ -3,7 +3,7 @@ import { round } from "../math/misc.mjs";
|
|
|
3
3
|
import { min } from "../math/aggregate.mjs";
|
|
4
4
|
import { createCompareHandler } from "./handlers.mjs";
|
|
5
5
|
import { EQUAL_ERROR_PROPERTIES, EQUAL_EXPRESSION_PROPERTIES, EQUAL_SYMBOL } from "../../models/value/value.equal.model.mjs";
|
|
6
|
-
|
|
6
|
+
// src/internal/value/equal.ts
|
|
7
7
|
function Equalizer(options) {
|
|
8
8
|
this[EQUAL_SYMBOL] = options;
|
|
9
9
|
}
|
|
@@ -176,5 +176,4 @@ equal.deregister = deregisterEqualizer;
|
|
|
176
176
|
equal.handler = equalHandler;
|
|
177
177
|
equal.initialize = initializeEqualizer;
|
|
178
178
|
equal.register = registerEqualizer;
|
|
179
|
-
//#endregion
|
|
180
179
|
export { deregisterEqualizer, equal, initializeEqualizer, registerEqualizer };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { NestedKeys, NestedValue, PlainObject } from "../../models/index.mjs";
|
|
2
|
-
//#region src/internal/value/get.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Get the value from an object using a known path
|
|
5
4
|
*
|
|
@@ -36,5 +35,4 @@ export declare function getValue<Data extends PlainObject, Path extends NestedKe
|
|
|
36
35
|
* getValue(data, 'foo.nope'); // => undefined
|
|
37
36
|
* ```
|
|
38
37
|
*/
|
|
39
|
-
export declare function getValue<Data extends PlainObject>(data: Data, path: string, ignoreCase?: boolean): unknown;
|
|
40
|
-
//#endregion
|
|
38
|
+
export declare function getValue<Data extends PlainObject>(data: Data, path: string, ignoreCase?: boolean): unknown;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { GenericCallback } from "../../models/index.mjs";
|
|
2
2
|
import { BaseHandlerOptions, CompareHandler, ValueHandler } from "../../models/value/value.handler.model.mjs";
|
|
3
|
-
//#region src/internal/value/handlers.d.ts
|
|
4
3
|
export declare function createCompareHandler<Value>(owner: GenericCallback, options: BaseHandlerOptions): CompareHandler<Value>;
|
|
5
|
-
export declare function createValueHandler(owner: GenericCallback, options: BaseHandlerOptions): ValueHandler;
|
|
6
|
-
//#endregion
|
|
4
|
+
export declare function createValueHandler(owner: GenericCallback, options: BaseHandlerOptions): ValueHandler;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isNonConstructor } from "../is.mjs";
|
|
2
|
-
|
|
2
|
+
// src/internal/value/handlers.ts
|
|
3
3
|
function BaseHandler(owner, options) {
|
|
4
4
|
this.handlers = /* @__PURE__ */ new WeakMap();
|
|
5
5
|
this.owner = owner;
|
|
@@ -51,5 +51,4 @@ function handleValue(value, ...parameters) {
|
|
|
51
51
|
if (handler == null) return this.base.options.callback(value, ...parameters);
|
|
52
52
|
return typeof handler === "function" ? handler(value) : value[handler]();
|
|
53
53
|
}
|
|
54
|
-
//#endregion
|
|
55
54
|
export { createCompareHandler, createValueHandler };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { NestedKeys, NestedValue, PlainObject, ToString } from "../../models/index.mjs";
|
|
2
2
|
import { Result } from "../../models/result.model.mjs";
|
|
3
|
-
//#region src/internal/value/has.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Check if a property is defined in an object
|
|
6
5
|
*
|
|
@@ -82,5 +81,4 @@ export declare function hasValueResult<Data extends PlainObject, Path extends Ne
|
|
|
82
81
|
export declare function hasValueResult<Data extends PlainObject>(data: Data, path: string, ignoreCase?: boolean): Result<unknown, string>;
|
|
83
82
|
export declare namespace hasValue {
|
|
84
83
|
export var get: typeof hasValueResult;
|
|
85
|
-
}
|
|
86
|
-
//#endregion
|
|
84
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getNestedValue } from "./misc.mjs";
|
|
2
|
-
|
|
2
|
+
// src/internal/value/has.ts
|
|
3
3
|
function hasValue(data, path, ignoreCase) {
|
|
4
4
|
return getNestedValue(data, path, ignoreCase === true).ok;
|
|
5
5
|
}
|
|
@@ -7,5 +7,4 @@ function hasValueResult(data, path, ignoreCase) {
|
|
|
7
7
|
return getNestedValue(data, path, ignoreCase === true);
|
|
8
8
|
}
|
|
9
9
|
hasValue.get = hasValueResult;
|
|
10
|
-
//#endregion
|
|
11
10
|
export { hasValue, hasValueResult };
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { Result } from "../../models/result.model.mjs";
|
|
2
|
-
//#region src/internal/value/misc.d.ts
|
|
3
2
|
export declare function findKey(needle: string, haystack: object): string;
|
|
4
3
|
export declare function getNestedValue(data: object, path: string, ignoreCase: boolean): Result<unknown, string>;
|
|
5
4
|
export declare function getPaths(path: string, lowercase: boolean): string | string[];
|
|
6
5
|
export declare function handleValue(data: object, path: string, value: unknown, get: true, ignoreCase: boolean): Result<object, string>;
|
|
7
|
-
export declare function handleValue(data: object, path: string, value: unknown, get: false, ignoreCase: boolean): void;
|
|
8
|
-
//#endregion
|
|
6
|
+
export declare function handleValue(data: object, path: string, value: unknown, get: false, ignoreCase: boolean): void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { VALUE_MISC_EXPRESSION_BRACKET, VALUE_MISC_EXPRESSION_DOTS, VALUE_MISC_EXPRESSION_NESTED, VALUE_MISC_NESTED_MESSAGE_INPUT, VALUE_MISC_NESTED_MESSAGE_MISSING, VALUE_MISC_NESTED_MESSAGE_PATH, VALUE_MISC_NESTED_MESSAGE_UNSAFE } from "../../models/value/value.misc.model.mjs";
|
|
2
1
|
import { error, ok } from "../result/misc.mjs";
|
|
2
|
+
import { VALUE_MISC_EXPRESSION_BRACKET, VALUE_MISC_EXPRESSION_DOTS, VALUE_MISC_EXPRESSION_NESTED, VALUE_MISC_NESTED_MESSAGE_INPUT, VALUE_MISC_NESTED_MESSAGE_MISSING, VALUE_MISC_NESTED_MESSAGE_PATH, VALUE_MISC_NESTED_MESSAGE_UNSAFE } from "../../models/value/value.misc.model.mjs";
|
|
3
3
|
import { ignoreKey } from "../string/misc.mjs";
|
|
4
|
-
|
|
4
|
+
// src/internal/value/misc.ts
|
|
5
5
|
function findKey(needle, haystack) {
|
|
6
6
|
const keys = Object.keys(haystack);
|
|
7
7
|
const index = keys.map((key) => key.toLowerCase()).indexOf(needle.toLowerCase());
|
|
@@ -38,5 +38,4 @@ function handleValue(data, path, value, get, ignoreCase) {
|
|
|
38
38
|
}
|
|
39
39
|
if (get) return error(VALUE_MISC_NESTED_MESSAGE_MISSING);
|
|
40
40
|
}
|
|
41
|
-
//#endregion
|
|
42
41
|
export { findKey, getNestedValue, getPaths, handleValue };
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
//#region src/internal/value/partial.d.ts
|
|
2
1
|
export declare function partial<Value extends object, ValueKey extends keyof Value>(value: unknown, keys: ValueKey[], omit: true): Omit<Value, ValueKey>;
|
|
3
|
-
export declare function partial<Value extends object, ValueKey extends keyof Value>(value: unknown, keys: ValueKey[], omit: false): Pick<Value, ValueKey>;
|
|
4
|
-
//#endregion
|
|
2
|
+
export declare function partial<Value extends object, ValueKey extends keyof Value>(value: unknown, keys: ValueKey[], omit: false): Pick<Value, ValueKey>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isPlainObject } from "../is.mjs";
|
|
2
|
-
|
|
2
|
+
// src/internal/value/partial.ts
|
|
3
3
|
function partial(value, providedKeys, omit) {
|
|
4
4
|
if (!isPlainObject(value)) return {};
|
|
5
5
|
let keys;
|
|
@@ -15,5 +15,4 @@ function partial(value, providedKeys, omit) {
|
|
|
15
15
|
}
|
|
16
16
|
return partials;
|
|
17
17
|
}
|
|
18
|
-
//#endregion
|
|
19
18
|
export { partial };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { NestedKeys, NestedValue, PlainObject } from "../../models/index.mjs";
|
|
2
|
-
//#region src/internal/value/set.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Update the value in an object using a known path
|
|
5
4
|
*
|
|
@@ -48,5 +47,4 @@ export declare function setValue<Data extends PlainObject, Path extends NestedKe
|
|
|
48
47
|
* setValue(data, 'Foo.Bar.Baz', 99, true); // => {foo: {bar: {baz: 99}}}
|
|
49
48
|
* ```
|
|
50
49
|
*/
|
|
51
|
-
export declare function setValue<Data extends PlainObject>(data: Data, path: string, value: unknown, ignoreCase?: boolean): Data;
|
|
52
|
-
//#endregion
|
|
50
|
+
export declare function setValue<Data extends PlainObject>(data: Data, path: string, value: unknown, ignoreCase?: boolean): Data;
|