vest-utils 1.5.0 → 2.0.1
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/README.md +7 -2
- package/dist/chunk-CLMFDpHK.mjs +18 -0
- package/dist/exports/minifyObject.cjs +114 -0
- package/dist/exports/minifyObject.cjs.map +1 -0
- package/dist/exports/minifyObject.mjs +113 -0
- package/dist/exports/minifyObject.mjs.map +1 -0
- package/dist/exports/standardSchemaSpec.cjs +0 -0
- package/dist/exports/standardSchemaSpec.mjs +1 -0
- package/dist/isEmpty-BBxAFjjm.mjs +103 -0
- package/dist/isEmpty-BBxAFjjm.mjs.map +1 -0
- package/dist/isEmpty-BuEa-96Q.cjs +235 -0
- package/dist/isEmpty-BuEa-96Q.cjs.map +1 -0
- package/dist/vest-utils.cjs +510 -0
- package/dist/vest-utils.cjs.map +1 -0
- package/dist/vest-utils.mjs +421 -0
- package/dist/vest-utils.mjs.map +1 -0
- package/minifyObject/package.json +12 -8
- package/package.json +43 -58
- package/src/Brand.ts +9 -0
- package/src/IO.ts +2 -0
- package/src/Predicates.ts +13 -0
- package/src/Result.ts +121 -0
- package/src/SimpleStateMachine.ts +157 -0
- package/src/StringObject.ts +6 -0
- package/src/__tests__/Architecture.test.ts +69 -0
- package/src/__tests__/Predicates.test.ts +118 -0
- package/src/__tests__/Result.test.ts +284 -0
- package/src/__tests__/SimpleStateMachine.test.ts +425 -0
- package/src/__tests__/StringObject.test.ts +18 -0
- package/src/__tests__/asArray.test.ts +14 -0
- package/src/__tests__/bindNot.test.ts +39 -0
- package/src/__tests__/bus.test.ts +135 -0
- package/src/__tests__/cache.test.ts +139 -0
- package/src/__tests__/callEach.test.ts +20 -0
- package/src/__tests__/defaultTo.test.ts +52 -0
- package/src/__tests__/deferThrow.test.ts +26 -0
- package/src/__tests__/either.test.ts +17 -0
- package/src/__tests__/freezeAssign.test.ts +24 -0
- package/src/__tests__/greaterThan.test.ts +68 -0
- package/src/__tests__/invariant.test.ts +47 -0
- package/src/__tests__/isArray.test.ts +16 -0
- package/src/__tests__/isBoolean.test.ts +16 -0
- package/src/__tests__/isEmpty.test.ts +55 -0
- package/src/__tests__/isEmptySet.test.ts +22 -0
- package/src/__tests__/isNull.test.ts +26 -0
- package/src/__tests__/isNumeric.test.ts +27 -0
- package/src/__tests__/isPositive.test.ts +38 -0
- package/src/__tests__/isPromise.test.ts +17 -0
- package/src/__tests__/isString.test.ts +13 -0
- package/src/__tests__/isUndefined.test.ts +27 -0
- package/src/__tests__/isUnsafeKey.test.ts +22 -0
- package/src/__tests__/lengthEquals.test.ts +58 -0
- package/src/__tests__/longerThan.test.ts +58 -0
- package/src/__tests__/mapFirst.test.ts +31 -0
- package/src/__tests__/nonnullish.test.ts +25 -0
- package/src/__tests__/noop.test.ts +12 -0
- package/src/__tests__/numberEquals.test.ts +67 -0
- package/src/__tests__/optionalFunctionValue.test.ts +29 -0
- package/src/__tests__/seq.test.ts +29 -0
- package/src/__tests__/text.test.ts +41 -0
- package/src/__tests__/tinyState.test.ts +68 -0
- package/src/__tests__/toNumber.test.ts +39 -0
- package/src/__tests__/vest-utils.test.ts +13 -0
- package/src/__tests__/withCatch.test.ts +17 -0
- package/src/__tests__/withResolvers.test.ts +45 -0
- package/src/asArray.ts +3 -0
- package/src/assign.ts +1 -0
- package/src/bindNot.ts +3 -0
- package/src/bus.ts +52 -0
- package/src/cache.ts +68 -0
- package/src/callEach.ts +5 -0
- package/src/defaultTo.ts +9 -0
- package/src/deferThrow.ts +7 -0
- package/src/dynamicValue.ts +9 -0
- package/src/either.ts +3 -0
- package/src/exports/__tests__/minifyObject.security.test.ts +65 -0
- package/src/exports/__tests__/minifyObject.test.ts +281 -0
- package/src/exports/minifyObject.ts +198 -0
- package/src/exports/standardSchemaSpec.ts +70 -0
- package/src/freezeAssign.ts +5 -0
- package/src/globals.d.ts +3 -0
- package/src/greaterThan.ts +8 -0
- package/src/hasOwnProperty.ts +9 -0
- package/src/invariant.ts +19 -0
- package/src/isArrayValue.ts +11 -0
- package/src/isBooleanValue.ts +3 -0
- package/src/isEmpty.ts +18 -0
- package/src/isEmptySet.ts +15 -0
- package/src/isFunction.ts +5 -0
- package/src/isNull.ts +7 -0
- package/src/isNullish.ts +10 -0
- package/src/isNumeric.ts +11 -0
- package/src/isPositive.ts +5 -0
- package/src/isPromise.ts +5 -0
- package/src/isStringValue.ts +3 -0
- package/src/isUndefined.ts +7 -0
- package/src/isUnsafeKey.ts +3 -0
- package/src/lengthEquals.ts +11 -0
- package/src/longerThan.ts +8 -0
- package/src/mapFirst.ts +25 -0
- package/src/nonnullish.ts +9 -0
- package/src/noop.ts +1 -0
- package/src/numberEquals.ts +11 -0
- package/src/seq.ts +16 -0
- package/src/text.ts +20 -0
- package/src/tinyState.ts +28 -0
- package/src/toNumber.ts +11 -0
- package/src/utilityTypes.ts +25 -0
- package/src/valueIsObject.ts +5 -0
- package/src/vest-utils.ts +73 -0
- package/src/withCatch.ts +11 -0
- package/src/withResolvers.ts +33 -0
- package/standardSchemaSpec/package.json +14 -0
- package/types/{minifyObject.d.ts → exports/minifyObject.d.cts} +4 -2
- package/types/exports/minifyObject.d.cts.map +1 -0
- package/types/exports/minifyObject.d.mts +7 -0
- package/types/exports/minifyObject.d.mts.map +1 -0
- package/types/exports/standardSchemaSpec.d.cts +59 -0
- package/types/exports/standardSchemaSpec.d.cts.map +1 -0
- package/types/exports/standardSchemaSpec.d.mts +59 -0
- package/types/exports/standardSchemaSpec.d.mts.map +1 -0
- package/types/vest-utils.d.cts +296 -0
- package/types/vest-utils.d.cts.map +1 -0
- package/types/vest-utils.d.mts +295 -0
- package/types/vest-utils.d.mts.map +1 -0
- package/types/vest-utils.d.ts +245 -143
- package/vitest.config.ts +9 -45
- package/dist/cjs/minifyObject.development.js +0 -217
- package/dist/cjs/minifyObject.development.js.map +0 -1
- package/dist/cjs/minifyObject.js +0 -6
- package/dist/cjs/minifyObject.production.js +0 -2
- package/dist/cjs/minifyObject.production.js.map +0 -1
- package/dist/cjs/package.json +0 -1
- package/dist/cjs/vest-utils.development.js +0 -378
- package/dist/cjs/vest-utils.development.js.map +0 -1
- package/dist/cjs/vest-utils.js +0 -6
- package/dist/cjs/vest-utils.production.js +0 -2
- package/dist/cjs/vest-utils.production.js.map +0 -1
- package/dist/es/minifyObject.development.js +0 -214
- package/dist/es/minifyObject.development.js.map +0 -1
- package/dist/es/minifyObject.production.js +0 -2
- package/dist/es/minifyObject.production.js.map +0 -1
- package/dist/es/package.json +0 -1
- package/dist/es/vest-utils.development.js +0 -330
- package/dist/es/vest-utils.development.js.map +0 -1
- package/dist/es/vest-utils.production.js +0 -2
- package/dist/es/vest-utils.production.js.map +0 -1
- package/dist/umd/minifyObject.development.js +0 -223
- package/dist/umd/minifyObject.development.js.map +0 -1
- package/dist/umd/minifyObject.production.js +0 -2
- package/dist/umd/minifyObject.production.js.map +0 -1
- package/dist/umd/vest-utils.development.js +0 -384
- package/dist/umd/vest-utils.development.js.map +0 -1
- package/dist/umd/vest-utils.production.js +0 -2
- package/dist/umd/vest-utils.production.js.map +0 -1
- package/types/minifyObject.d.ts.map +0 -1
- package/types/vest-utils.d.ts.map +0 -1
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
export { withResolvers } from './withResolvers';
|
|
2
|
+
export { default as cache } from './cache';
|
|
3
|
+
export type { CacheApi } from './cache';
|
|
4
|
+
export type { BusType } from './bus';
|
|
5
|
+
export type { TinyState } from './tinyState';
|
|
6
|
+
export { isNullish, isNotNullish } from './isNullish';
|
|
7
|
+
export { default as asArray } from './asArray';
|
|
8
|
+
export { default as callEach } from './callEach';
|
|
9
|
+
export { default as hasOwnProperty } from './hasOwnProperty';
|
|
10
|
+
export { default as isPromise } from './isPromise';
|
|
11
|
+
export { default as dynamicValue } from './dynamicValue';
|
|
12
|
+
export { default as assign } from './assign';
|
|
13
|
+
export { default as defaultTo } from './defaultTo';
|
|
14
|
+
export { default as invariant } from './invariant';
|
|
15
|
+
export { default as isStringValue } from './isStringValue';
|
|
16
|
+
export { default as isUnsafeKey } from './isUnsafeKey';
|
|
17
|
+
export { default as bindNot } from './bindNot';
|
|
18
|
+
export { default as either } from './either';
|
|
19
|
+
export { default as isBoolean } from './isBooleanValue';
|
|
20
|
+
export { default as deferThrow } from './deferThrow';
|
|
21
|
+
export * as bus from './bus';
|
|
22
|
+
export { default as seq, genSeq } from './seq';
|
|
23
|
+
export { default as isFunction } from './isFunction';
|
|
24
|
+
export { default as mapFirst } from './mapFirst';
|
|
25
|
+
export { greaterThan } from './greaterThan';
|
|
26
|
+
export { longerThan } from './longerThan';
|
|
27
|
+
export { isNumeric, isNotNumeric } from './isNumeric';
|
|
28
|
+
export { isObject } from './valueIsObject';
|
|
29
|
+
export { lengthEquals, lengthNotEquals } from './lengthEquals';
|
|
30
|
+
export { numberEquals, numberNotEquals } from './numberEquals';
|
|
31
|
+
export { isNull, isNotNull } from './isNull';
|
|
32
|
+
export { isUndefined, isNotUndefined } from './isUndefined';
|
|
33
|
+
export { isArray, isNotArray } from './isArrayValue';
|
|
34
|
+
export { isEmpty, isNotEmpty } from './isEmpty';
|
|
35
|
+
export { isEmptySet, isNotEmptySet } from './isEmptySet';
|
|
36
|
+
export { isPositive } from './isPositive';
|
|
37
|
+
export { text } from './text';
|
|
38
|
+
export { StateMachine } from './SimpleStateMachine';
|
|
39
|
+
export type { TStateMachine, TStateMachineApi } from './SimpleStateMachine';
|
|
40
|
+
export { nonnullish } from './nonnullish';
|
|
41
|
+
export * as tinyState from './tinyState';
|
|
42
|
+
export { StringObject } from './StringObject';
|
|
43
|
+
export { noop } from './noop';
|
|
44
|
+
export * as Predicates from './Predicates';
|
|
45
|
+
export { freezeAssign } from './freezeAssign';
|
|
46
|
+
export { withCatch } from './withCatch';
|
|
47
|
+
export { makeBrand } from './Brand';
|
|
48
|
+
export type { Brand } from './Brand';
|
|
49
|
+
export { toNumber } from './toNumber';
|
|
50
|
+
export type { IO } from './IO';
|
|
51
|
+
export {
|
|
52
|
+
makeResult,
|
|
53
|
+
isResult,
|
|
54
|
+
isSuccess,
|
|
55
|
+
isFailure,
|
|
56
|
+
unwrap,
|
|
57
|
+
type Result,
|
|
58
|
+
type Failure,
|
|
59
|
+
} from './Result';
|
|
60
|
+
|
|
61
|
+
export type {
|
|
62
|
+
DropFirst,
|
|
63
|
+
Stringable,
|
|
64
|
+
CB,
|
|
65
|
+
ValueOf,
|
|
66
|
+
Nullish,
|
|
67
|
+
Nullable,
|
|
68
|
+
Maybe,
|
|
69
|
+
OneOrMoreOf,
|
|
70
|
+
DynamicValue,
|
|
71
|
+
BlankValue,
|
|
72
|
+
Predicate,
|
|
73
|
+
} from './utilityTypes';
|
package/src/withCatch.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import isFunction from './isFunction';
|
|
2
|
+
import { noop } from './noop';
|
|
3
|
+
|
|
4
|
+
// Type declaration for Promise.withResolvers (ES2024 feature)
|
|
5
|
+
declare global {
|
|
6
|
+
interface PromiseConstructor {
|
|
7
|
+
withResolvers<T>(): {
|
|
8
|
+
promise: Promise<T>;
|
|
9
|
+
resolve: (value: T | PromiseLike<T>) => void;
|
|
10
|
+
reject: (reason?: any) => void;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function withResolvers<T>() {
|
|
16
|
+
if (isFunction(Promise.withResolvers)) {
|
|
17
|
+
return Promise.withResolvers<T>();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let resolve: (value: T | PromiseLike<T>) => void = noop,
|
|
21
|
+
reject: (reason?: any) => void = noop;
|
|
22
|
+
|
|
23
|
+
const promise = new Promise<T>((res, rej) => {
|
|
24
|
+
resolve = res;
|
|
25
|
+
reject = rej;
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
promise,
|
|
30
|
+
resolve,
|
|
31
|
+
reject,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"exports": {
|
|
3
|
+
".": {
|
|
4
|
+
"default": "../dist/exports/standardSchemaSpec.mjs",
|
|
5
|
+
"import": "../dist/exports/standardSchemaSpec.mjs",
|
|
6
|
+
"require": "../dist/exports/standardSchemaSpec.cjs",
|
|
7
|
+
"types": "../types/exports/standardSchemaSpec.d.mts"
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
"main": "../dist/exports/standardSchemaSpec.cjs",
|
|
11
|
+
"module": "../dist/exports/standardSchemaSpec.mjs",
|
|
12
|
+
"type": "module",
|
|
13
|
+
"types": "../types/exports/standardSchemaSpec.d.mts"
|
|
14
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
//#region src/exports/minifyObject.d.ts
|
|
1
2
|
declare function minifyObject(obj: any, replacer?: MinifyObjectReplacer): [any, any];
|
|
2
3
|
declare function expandObject(minifiedObj: any, map: Record<string, any>): any;
|
|
3
4
|
type MinifyObjectReplacer = (value: any, key: string) => any;
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
//#endregion
|
|
6
|
+
export { MinifyObjectReplacer, expandObject, minifyObject };
|
|
7
|
+
//# sourceMappingURL=minifyObject.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"minifyObject.d.cts","names":["minifyObject","MinifyObjectReplacer","expandObject","Record"],"sources":["../../src/exports/minifyObject.d.ts"],"sourcesContent":["export declare function minifyObject(obj: any, replacer?: MinifyObjectReplacer): [any, any];\nexport declare function expandObject(minifiedObj: any, map: Record<string, any>): any;\nexport type MinifyObjectReplacer = (value: any, key: string) => any;\n"],"mappings":";iBAAwBA,YAAAA,sBAAkCC;AAAlCD,iBACAE,YAAAA,CADkCD,WAAAA,EAAAA,GAAoB,EAAA,GAAA,EAClBE,MADkB,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,EAAA,GAAA;AACtDD,KACZD,oBAAAA,GADgDE,CAAAA,KAAM,EAAA,GAAA,EAAA,GAAA,EAAA,MAAA,EAAA,GAAA,GAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
//#region src/exports/minifyObject.d.ts
|
|
2
|
+
declare function minifyObject(obj: any, replacer?: MinifyObjectReplacer): [any, any];
|
|
3
|
+
declare function expandObject(minifiedObj: any, map: Record<string, any>): any;
|
|
4
|
+
type MinifyObjectReplacer = (value: any, key: string) => any;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { MinifyObjectReplacer, expandObject, minifyObject };
|
|
7
|
+
//# sourceMappingURL=minifyObject.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"minifyObject.d.mts","names":["minifyObject","MinifyObjectReplacer","expandObject","Record"],"sources":["../../src/exports/minifyObject.d.ts"],"sourcesContent":["export declare function minifyObject(obj: any, replacer?: MinifyObjectReplacer): [any, any];\nexport declare function expandObject(minifiedObj: any, map: Record<string, any>): any;\nexport type MinifyObjectReplacer = (value: any, key: string) => any;\n"],"mappings":";iBAAwBA,YAAAA,sBAAkCC;AAAlCD,iBACAE,YAAAA,CADkCD,WAAAA,EAAAA,GAAoB,EAAA,GAAA,EAClBE,MADkB,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,EAAA,GAAA;AACtDD,KACZD,oBAAAA,GADgDE,CAAAA,KAAM,EAAA,GAAA,EAAA,GAAA,EAAA,MAAA,EAAA,GAAA,GAAA"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
//#region src/exports/standardSchemaSpec.d.ts
|
|
2
|
+
/** The Standard Schema interface. */
|
|
3
|
+
interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
4
|
+
/** The Standard Schema properties. */
|
|
5
|
+
readonly '~standard': StandardSchemaV1.Props<Input, Output>;
|
|
6
|
+
}
|
|
7
|
+
declare namespace StandardSchemaV1 {
|
|
8
|
+
/** The Standard Schema properties interface. */
|
|
9
|
+
interface Props<Input = unknown, Output = Input> {
|
|
10
|
+
/** The version number of the standard. */
|
|
11
|
+
readonly version: 1;
|
|
12
|
+
/** The vendor name of the schema library. */
|
|
13
|
+
readonly vendor: string;
|
|
14
|
+
/** Validates unknown input values. */
|
|
15
|
+
readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
|
|
16
|
+
/** Inferred types associated with the schema. */
|
|
17
|
+
readonly types?: Types<Input, Output> | undefined;
|
|
18
|
+
}
|
|
19
|
+
/** The result interface of the validate function. */
|
|
20
|
+
type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
21
|
+
/** The result interface if validation succeeds. */
|
|
22
|
+
interface SuccessResult<Output> {
|
|
23
|
+
/** The typed output value. */
|
|
24
|
+
readonly value: Output;
|
|
25
|
+
/** The non-existent issues. */
|
|
26
|
+
readonly issues?: undefined;
|
|
27
|
+
}
|
|
28
|
+
/** The result interface if validation fails. */
|
|
29
|
+
interface FailureResult {
|
|
30
|
+
/** The issues of failed validation. */
|
|
31
|
+
readonly issues: ReadonlyArray<Issue>;
|
|
32
|
+
}
|
|
33
|
+
/** The issue interface of the failure output. */
|
|
34
|
+
interface Issue {
|
|
35
|
+
/** The error message of the issue. */
|
|
36
|
+
readonly message: string;
|
|
37
|
+
/** The path of the issue, if any. */
|
|
38
|
+
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
|
39
|
+
}
|
|
40
|
+
/** The path segment interface of the issue. */
|
|
41
|
+
interface PathSegment {
|
|
42
|
+
/** The key representing a path segment. */
|
|
43
|
+
readonly key: PropertyKey;
|
|
44
|
+
}
|
|
45
|
+
/** The Standard Schema types interface. */
|
|
46
|
+
interface Types<Input = unknown, Output = Input> {
|
|
47
|
+
/** The input type of the schema. */
|
|
48
|
+
readonly input: Input;
|
|
49
|
+
/** The output type of the schema. */
|
|
50
|
+
readonly output: Output;
|
|
51
|
+
}
|
|
52
|
+
/** Infers the input type of a Standard Schema. */
|
|
53
|
+
type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['input'];
|
|
54
|
+
/** Infers the output type of a Standard Schema. */
|
|
55
|
+
type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['output'];
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
export { StandardSchemaV1 };
|
|
59
|
+
//# sourceMappingURL=standardSchemaSpec.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"standardSchemaSpec.d.cts","names":["StandardSchemaV1","Input","Output","Props","Schema","Result","Promise","Types","SuccessResult","FailureResult","Issue","ReadonlyArray","PropertyKey","PathSegment","NonNullable"],"sources":["../../src/exports/standardSchemaSpec.d.ts"],"sourcesContent":["/** The Standard Schema interface. */\nexport interface StandardSchemaV1<Input = unknown, Output = Input> {\n /** The Standard Schema properties. */\n readonly '~standard': StandardSchemaV1.Props<Input, Output>;\n}\nexport declare namespace StandardSchemaV1 {\n /** The Standard Schema properties interface. */\n interface Props<Input = unknown, Output = Input> {\n /** The version number of the standard. */\n readonly version: 1;\n /** The vendor name of the schema library. */\n readonly vendor: string;\n /** Validates unknown input values. */\n readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;\n /** Inferred types associated with the schema. */\n readonly types?: Types<Input, Output> | undefined;\n }\n /** The result interface of the validate function. */\n type Result<Output> = SuccessResult<Output> | FailureResult;\n /** The result interface if validation succeeds. */\n interface SuccessResult<Output> {\n /** The typed output value. */\n readonly value: Output;\n /** The non-existent issues. */\n readonly issues?: undefined;\n }\n /** The result interface if validation fails. */\n interface FailureResult {\n /** The issues of failed validation. */\n readonly issues: ReadonlyArray<Issue>;\n }\n /** The issue interface of the failure output. */\n interface Issue {\n /** The error message of the issue. */\n readonly message: string;\n /** The path of the issue, if any. */\n readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;\n }\n /** The path segment interface of the issue. */\n interface PathSegment {\n /** The key representing a path segment. */\n readonly key: PropertyKey;\n }\n /** The Standard Schema types interface. */\n interface Types<Input = unknown, Output = Input> {\n /** The input type of the schema. */\n readonly input: Input;\n /** The output type of the schema. */\n readonly output: Output;\n }\n /** Infers the input type of a Standard Schema. */\n type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['input'];\n /** Infers the output type of a Standard Schema. */\n type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['output'];\n}\n"],"mappings":";;AACiBA,UAAAA,gBAAgBC,CAAAA,QAAAC,OAAA,EAAA,SAA2BD,KAA3B,CAAA,CAAA;EAA2BA;EAEXA,SAAAA,WAAAA,EAAvBD,gBAAAA,CAAiBG,KAAMF,CAAAA,KAAAA,EAAOC,MAAPD,CAAAA;;AAAvBD,kBAEDA,gBAAAA,CAFkBG;EAAK;EAEvBH,UAAAA,KAAAA,CAAAA,QAAgBC,OAAAC,EAAAA,SAEKD,KAFLG,CAAAA,CAAAA;IAEKH;IAMQC,SAAAA,OAAAA,EAAAA,CAAAA;IAAPG;IAAgCH,SAAAA,MAAAA,EAAAA,MAAAA;IAAPG;IAARC,SAAAA,QAAAA,EAAAA,CAAAA,KAAAA,EAAAA,OAAAA,EAAAA,GAAjBD,MAAiBC,CAAVJ,MAAUI,CAAAA,GAAAA,OAAAA,CAAQD,MAARC,CAAeJ,MAAfI,CAAAA,CAAAA;IAEjCL;IAAOC,SAAAA,KAAAA,CAAAA,EAAbK,KAAaL,CAAPD,KAAOC,EAAAA,MAAAA,CAAAA,GAAAA,SAAAA;EAAbK;EAGeL;EAAdM,KAAAA,MAAAA,CAAAA,MAAAA,CAAAA,GAAAA,aAAAA,CAAcN,MAAdM,CAAAA,GAAwBC,aAAxBD;EAAwBC;EAI1BP,UAAAA,aAAAA,CAAAA,MAAAA,CAAAA,CAAAA;IAOeQ;IAAdC,SAAAA,KAAAA,EAPDT,MAOCS;IAOaC;IAAcC,SAAAA,MAAAA,CAAAA,EAAAA,SAAAA;EAA5BF;EAKFC;EAGwBX,UAAAA,aAAAA,CAAAA;IAEtBA;IAECC,SAAAA,MAAAA,EAnBAS,aAmBAT,CAnBcQ,KAmBdR,CAAAA;EAGUF;EAAgCI;EAAZU,UAAAA,KAAAA,CAAAA;IAEnBd;IAAgCI,SAAAA,OAAAA,EAAAA,MAAAA;IAAZU;IAAW,SAAA,IAAA,CAAA,EAjB3CH,aAiB2C,CAjB7BC,WAiB6B,GAjBfC,WAiBe,CAAA,GAAA,SAAA;;;;;kBAZ7CD;;;4CAGwBX;;oBAEtBA;;qBAECC;;;iCAGUF,oBAAoBc,YAAYV;;kCAE/BJ,oBAAoBc,YAAYV"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
//#region src/exports/standardSchemaSpec.d.ts
|
|
2
|
+
/** The Standard Schema interface. */
|
|
3
|
+
interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
4
|
+
/** The Standard Schema properties. */
|
|
5
|
+
readonly '~standard': StandardSchemaV1.Props<Input, Output>;
|
|
6
|
+
}
|
|
7
|
+
declare namespace StandardSchemaV1 {
|
|
8
|
+
/** The Standard Schema properties interface. */
|
|
9
|
+
interface Props<Input = unknown, Output = Input> {
|
|
10
|
+
/** The version number of the standard. */
|
|
11
|
+
readonly version: 1;
|
|
12
|
+
/** The vendor name of the schema library. */
|
|
13
|
+
readonly vendor: string;
|
|
14
|
+
/** Validates unknown input values. */
|
|
15
|
+
readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
|
|
16
|
+
/** Inferred types associated with the schema. */
|
|
17
|
+
readonly types?: Types<Input, Output> | undefined;
|
|
18
|
+
}
|
|
19
|
+
/** The result interface of the validate function. */
|
|
20
|
+
type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
21
|
+
/** The result interface if validation succeeds. */
|
|
22
|
+
interface SuccessResult<Output> {
|
|
23
|
+
/** The typed output value. */
|
|
24
|
+
readonly value: Output;
|
|
25
|
+
/** The non-existent issues. */
|
|
26
|
+
readonly issues?: undefined;
|
|
27
|
+
}
|
|
28
|
+
/** The result interface if validation fails. */
|
|
29
|
+
interface FailureResult {
|
|
30
|
+
/** The issues of failed validation. */
|
|
31
|
+
readonly issues: ReadonlyArray<Issue>;
|
|
32
|
+
}
|
|
33
|
+
/** The issue interface of the failure output. */
|
|
34
|
+
interface Issue {
|
|
35
|
+
/** The error message of the issue. */
|
|
36
|
+
readonly message: string;
|
|
37
|
+
/** The path of the issue, if any. */
|
|
38
|
+
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
|
39
|
+
}
|
|
40
|
+
/** The path segment interface of the issue. */
|
|
41
|
+
interface PathSegment {
|
|
42
|
+
/** The key representing a path segment. */
|
|
43
|
+
readonly key: PropertyKey;
|
|
44
|
+
}
|
|
45
|
+
/** The Standard Schema types interface. */
|
|
46
|
+
interface Types<Input = unknown, Output = Input> {
|
|
47
|
+
/** The input type of the schema. */
|
|
48
|
+
readonly input: Input;
|
|
49
|
+
/** The output type of the schema. */
|
|
50
|
+
readonly output: Output;
|
|
51
|
+
}
|
|
52
|
+
/** Infers the input type of a Standard Schema. */
|
|
53
|
+
type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['input'];
|
|
54
|
+
/** Infers the output type of a Standard Schema. */
|
|
55
|
+
type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['output'];
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
export { StandardSchemaV1 };
|
|
59
|
+
//# sourceMappingURL=standardSchemaSpec.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"standardSchemaSpec.d.mts","names":["StandardSchemaV1","Input","Output","Props","Schema","Result","Promise","Types","SuccessResult","FailureResult","Issue","ReadonlyArray","PropertyKey","PathSegment","NonNullable"],"sources":["../../src/exports/standardSchemaSpec.d.ts"],"sourcesContent":["/** The Standard Schema interface. */\nexport interface StandardSchemaV1<Input = unknown, Output = Input> {\n /** The Standard Schema properties. */\n readonly '~standard': StandardSchemaV1.Props<Input, Output>;\n}\nexport declare namespace StandardSchemaV1 {\n /** The Standard Schema properties interface. */\n interface Props<Input = unknown, Output = Input> {\n /** The version number of the standard. */\n readonly version: 1;\n /** The vendor name of the schema library. */\n readonly vendor: string;\n /** Validates unknown input values. */\n readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;\n /** Inferred types associated with the schema. */\n readonly types?: Types<Input, Output> | undefined;\n }\n /** The result interface of the validate function. */\n type Result<Output> = SuccessResult<Output> | FailureResult;\n /** The result interface if validation succeeds. */\n interface SuccessResult<Output> {\n /** The typed output value. */\n readonly value: Output;\n /** The non-existent issues. */\n readonly issues?: undefined;\n }\n /** The result interface if validation fails. */\n interface FailureResult {\n /** The issues of failed validation. */\n readonly issues: ReadonlyArray<Issue>;\n }\n /** The issue interface of the failure output. */\n interface Issue {\n /** The error message of the issue. */\n readonly message: string;\n /** The path of the issue, if any. */\n readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;\n }\n /** The path segment interface of the issue. */\n interface PathSegment {\n /** The key representing a path segment. */\n readonly key: PropertyKey;\n }\n /** The Standard Schema types interface. */\n interface Types<Input = unknown, Output = Input> {\n /** The input type of the schema. */\n readonly input: Input;\n /** The output type of the schema. */\n readonly output: Output;\n }\n /** Infers the input type of a Standard Schema. */\n type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['input'];\n /** Infers the output type of a Standard Schema. */\n type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['output'];\n}\n"],"mappings":";;AACiBA,UAAAA,gBAAgBC,CAAAA,QAAAC,OAAA,EAAA,SAA2BD,KAA3B,CAAA,CAAA;EAA2BA;EAEXA,SAAAA,WAAAA,EAAvBD,gBAAAA,CAAiBG,KAAMF,CAAAA,KAAAA,EAAOC,MAAPD,CAAAA;;AAAvBD,kBAEDA,gBAAAA,CAFkBG;EAAK;EAEvBH,UAAAA,KAAAA,CAAAA,QAAgBC,OAAAC,EAAAA,SAEKD,KAFLG,CAAAA,CAAAA;IAEKH;IAMQC,SAAAA,OAAAA,EAAAA,CAAAA;IAAPG;IAAgCH,SAAAA,MAAAA,EAAAA,MAAAA;IAAPG;IAARC,SAAAA,QAAAA,EAAAA,CAAAA,KAAAA,EAAAA,OAAAA,EAAAA,GAAjBD,MAAiBC,CAAVJ,MAAUI,CAAAA,GAAAA,OAAAA,CAAQD,MAARC,CAAeJ,MAAfI,CAAAA,CAAAA;IAEjCL;IAAOC,SAAAA,KAAAA,CAAAA,EAAbK,KAAaL,CAAPD,KAAOC,EAAAA,MAAAA,CAAAA,GAAAA,SAAAA;EAAbK;EAGeL;EAAdM,KAAAA,MAAAA,CAAAA,MAAAA,CAAAA,GAAAA,aAAAA,CAAcN,MAAdM,CAAAA,GAAwBC,aAAxBD;EAAwBC;EAI1BP,UAAAA,aAAAA,CAAAA,MAAAA,CAAAA,CAAAA;IAOeQ;IAAdC,SAAAA,KAAAA,EAPDT,MAOCS;IAOaC;IAAcC,SAAAA,MAAAA,CAAAA,EAAAA,SAAAA;EAA5BF;EAKFC;EAGwBX,UAAAA,aAAAA,CAAAA;IAEtBA;IAECC,SAAAA,MAAAA,EAnBAS,aAmBAT,CAnBcQ,KAmBdR,CAAAA;EAGUF;EAAgCI;EAAZU,UAAAA,KAAAA,CAAAA;IAEnBd;IAAgCI,SAAAA,OAAAA,EAAAA,MAAAA;IAAZU;IAAW,SAAA,IAAA,CAAA,EAjB3CH,aAiB2C,CAjB7BC,WAiB6B,GAjBfC,WAiBe,CAAA,GAAA,SAAA;;;;;kBAZ7CD;;;4CAGwBX;;oBAEtBA;;qBAECC;;;iCAGUF,oBAAoBc,YAAYV;;kCAE/BJ,oBAAoBc,YAAYV"}
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
//#endregion
|
|
2
|
+
//#region src/withResolvers.d.ts
|
|
3
|
+
declare global {
|
|
4
|
+
interface PromiseConstructor {
|
|
5
|
+
withResolvers<T$1>(): {
|
|
6
|
+
promise: Promise<T$1>;
|
|
7
|
+
resolve: (value: T$1 | PromiseLike<T$1>) => void;
|
|
8
|
+
reject: (reason?: any) => void;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
declare function withResolvers<T$1>(): {
|
|
13
|
+
promise: Promise<T$1>;
|
|
14
|
+
resolve: (value: T$1 | PromiseLike<T$1>) => void;
|
|
15
|
+
reject: (reason?: any) => void;
|
|
16
|
+
};
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/utilityTypes.d.ts
|
|
19
|
+
type DropFirst<T$1 extends unknown[]> = T$1 extends [unknown, ...infer U] ? U : never;
|
|
20
|
+
type Stringable = string | CB<string>;
|
|
21
|
+
type CB<T$1 = any, Args extends TArgs = TArgs> = (...args: Args) => T$1;
|
|
22
|
+
type ValueOf<T$1> = T$1[keyof T$1];
|
|
23
|
+
type Nullish<T$1 = void> = Nullable<T$1> | Maybe<T$1>;
|
|
24
|
+
type Nullable<T$1> = T$1 | null;
|
|
25
|
+
type Maybe<T$1> = T$1 | undefined;
|
|
26
|
+
type OneOrMoreOf<T$1> = T$1 | T$1[];
|
|
27
|
+
type DynamicValue<T$1, Args extends TArgs = TArgs> = T$1 | CB<T$1, Args>;
|
|
28
|
+
type BlankValue = Maybe<''>;
|
|
29
|
+
type TArgs = any[];
|
|
30
|
+
type Predicate<T$1 = any> = boolean | ((value: T$1) => boolean);
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/cache.d.ts
|
|
33
|
+
/**
|
|
34
|
+
* Creates a cache function
|
|
35
|
+
*/
|
|
36
|
+
declare function createCache<T$1 = unknown>(maxSize?: number): CacheApi<T$1>;
|
|
37
|
+
type CacheApi<T$1 = unknown> = {
|
|
38
|
+
(deps: unknown[], cacheAction: DynamicValue<T$1>): T$1;
|
|
39
|
+
get(deps: unknown[]): Nullable<[unknown[], T$1]>;
|
|
40
|
+
set(deps: unknown[], value: T$1): void;
|
|
41
|
+
invalidate(item: any): void;
|
|
42
|
+
};
|
|
43
|
+
declare namespace bus_d_exports {
|
|
44
|
+
export { BusType, createBus };
|
|
45
|
+
}
|
|
46
|
+
declare const EVENT_WILDCARD = "*";
|
|
47
|
+
type TEventsWildcard = typeof EVENT_WILDCARD;
|
|
48
|
+
declare function createBus<TEvents extends Record<string, any> = Record<string, any>>(): BusType<TEvents>;
|
|
49
|
+
type OnReturn = {
|
|
50
|
+
off: CB<void>;
|
|
51
|
+
};
|
|
52
|
+
type BusType<TEvents extends Record<string, any>> = {
|
|
53
|
+
on<T$1 extends keyof TEvents>(event: T$1, handler: (payload: TEvents[T$1]) => void): OnReturn;
|
|
54
|
+
on(event: TEventsWildcard, handler: (payload: any) => void): OnReturn;
|
|
55
|
+
emit<T$1 extends keyof TEvents>(event: T$1, ...args: TEvents[T$1] extends void ? [payload?: TEvents[T$1]] : [payload: TEvents[T$1]]): void;
|
|
56
|
+
emit(event: TEventsWildcard, payload?: any): void;
|
|
57
|
+
};
|
|
58
|
+
declare namespace tinyState_d_exports {
|
|
59
|
+
export { TinyState, createTinyState };
|
|
60
|
+
}
|
|
61
|
+
declare function createTinyState<S>(initialValue: SetValueInput<S>): TinyState<S>;
|
|
62
|
+
type TinyState<S> = () => [value: S, setValue: (next: SetValueInput<S>) => void, resetValue: () => void];
|
|
63
|
+
type SetValueInput<S> = DynamicValue<S, [prev: S]>;
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/isNullish.d.ts
|
|
66
|
+
declare function isNullish(value: any): value is Nullish;
|
|
67
|
+
declare const isNotNullish: (value: any) => boolean;
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region src/asArray.d.ts
|
|
70
|
+
declare function asArray<T$1>(possibleArg: T$1 | T$1[]): T$1[];
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/callEach.d.ts
|
|
73
|
+
declare function callEach(arr: CB[]): void;
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/hasOwnProperty.d.ts
|
|
76
|
+
/**
|
|
77
|
+
* A safe hasOwnProperty access
|
|
78
|
+
*/
|
|
79
|
+
declare function hasOwnProperty<T$1>(obj: T$1, key: string | number | symbol): key is keyof T$1;
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/isPromise.d.ts
|
|
82
|
+
declare function isPromise(value: any): value is Promise<unknown>;
|
|
83
|
+
//#endregion
|
|
84
|
+
//#region src/dynamicValue.d.ts
|
|
85
|
+
declare function dynamicValue<T$1>(value: DynamicValue<T$1>, ...args: unknown[]): T$1;
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region src/assign.d.ts
|
|
88
|
+
declare const _default: {
|
|
89
|
+
<T$1 extends {}, U$1>(target: T$1, source: U$1): T$1 & U$1;
|
|
90
|
+
<T_1 extends {}, U_1, V>(target: T_1, source1: U_1, source2: V): T_1 & U_1 & V;
|
|
91
|
+
<T_2 extends {}, U_2, V_1, W>(target: T_2, source1: U_2, source2: V_1, source3: W): T_2 & U_2 & V_1 & W;
|
|
92
|
+
(target: object, ...sources: any[]): any;
|
|
93
|
+
};
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region src/defaultTo.d.ts
|
|
96
|
+
declare function defaultTo<T$1>(value: DynamicValue<Nullish<T$1>>, defaultValue: DynamicValue<T$1>): T$1;
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region src/invariant.d.ts
|
|
99
|
+
declare function invariant(condition: any, message?: String | Stringable): asserts condition;
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region src/isStringValue.d.ts
|
|
102
|
+
declare function isStringValue(v: unknown): v is string;
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/isUnsafeKey.d.ts
|
|
105
|
+
declare function isUnsafeKey(key: string): boolean;
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region src/bindNot.d.ts
|
|
108
|
+
declare function bindNot<T$1 extends (...args: any[]) => unknown>(fn: T$1): (...args: Parameters<T$1>) => boolean;
|
|
109
|
+
//#endregion
|
|
110
|
+
//#region src/either.d.ts
|
|
111
|
+
declare function either(a: unknown, b: unknown): boolean;
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region src/isBooleanValue.d.ts
|
|
114
|
+
declare function isBoolean(value: unknown): value is boolean;
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region src/deferThrow.d.ts
|
|
117
|
+
declare function deferThrow(message?: string): void;
|
|
118
|
+
//#endregion
|
|
119
|
+
//#region src/seq.d.ts
|
|
120
|
+
declare const seq: CB<string, any[]>;
|
|
121
|
+
declare function genSeq(namespace?: string): CB<string>;
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region src/isFunction.d.ts
|
|
124
|
+
declare function isFunction(value: unknown): value is (...args: unknown[]) => unknown;
|
|
125
|
+
//#endregion
|
|
126
|
+
//#region src/mapFirst.d.ts
|
|
127
|
+
declare function mapFirst<T$1>(array: T$1[], callback: (item: T$1, breakout: (conditional: boolean, value: unknown) => void, index: number) => unknown): any;
|
|
128
|
+
//#endregion
|
|
129
|
+
//#region src/greaterThan.d.ts
|
|
130
|
+
declare function greaterThan(value: number | string, gt: number | string): boolean;
|
|
131
|
+
//#endregion
|
|
132
|
+
//#region src/longerThan.d.ts
|
|
133
|
+
declare function longerThan(value: string | unknown[], arg1: string | number): boolean;
|
|
134
|
+
//#endregion
|
|
135
|
+
//#region src/isNumeric.d.ts
|
|
136
|
+
declare function isNumeric(value: string | number): boolean;
|
|
137
|
+
declare const isNotNumeric: (value: string | number) => boolean;
|
|
138
|
+
//#endregion
|
|
139
|
+
//#region src/valueIsObject.d.ts
|
|
140
|
+
declare function isObject(v: any): v is Record<any, any>;
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region src/lengthEquals.d.ts
|
|
143
|
+
declare function lengthEquals(value: string | unknown[], arg1: string | number): boolean;
|
|
144
|
+
declare const lengthNotEquals: (value: string | unknown[], arg1: string | number) => boolean;
|
|
145
|
+
//#endregion
|
|
146
|
+
//#region src/numberEquals.d.ts
|
|
147
|
+
declare function numberEquals(value: string | number, eq: string | number): boolean;
|
|
148
|
+
declare const numberNotEquals: (value: string | number, eq: string | number) => boolean;
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region src/isNull.d.ts
|
|
151
|
+
declare function isNull(value: unknown): value is null;
|
|
152
|
+
declare const isNotNull: (value: unknown) => boolean;
|
|
153
|
+
//#endregion
|
|
154
|
+
//#region src/isUndefined.d.ts
|
|
155
|
+
declare function isUndefined(value?: unknown): value is undefined;
|
|
156
|
+
declare const isNotUndefined: (value?: unknown) => boolean;
|
|
157
|
+
//#endregion
|
|
158
|
+
//#region src/isArrayValue.d.ts
|
|
159
|
+
declare function isArray(value: unknown): value is Array<unknown>;
|
|
160
|
+
declare const isNotArray: (value: unknown) => boolean;
|
|
161
|
+
//#endregion
|
|
162
|
+
//#region src/isEmpty.d.ts
|
|
163
|
+
declare function isEmpty(value: unknown): boolean;
|
|
164
|
+
declare const isNotEmpty: (value: unknown) => boolean;
|
|
165
|
+
//#endregion
|
|
166
|
+
//#region src/isEmptySet.d.ts
|
|
167
|
+
/**
|
|
168
|
+
* Checks if a given set is empty.
|
|
169
|
+
* @param value value to check
|
|
170
|
+
*/
|
|
171
|
+
declare function isEmptySet(value: Set<unknown>): boolean;
|
|
172
|
+
/**
|
|
173
|
+
* Checks if a given set is NOT empty.
|
|
174
|
+
* @param value value to check
|
|
175
|
+
*/
|
|
176
|
+
declare function isNotEmptySet(value: Set<unknown>): boolean;
|
|
177
|
+
//#endregion
|
|
178
|
+
//#region src/isPositive.d.ts
|
|
179
|
+
declare function isPositive(value: number | string): boolean;
|
|
180
|
+
//#endregion
|
|
181
|
+
//#region src/text.d.ts
|
|
182
|
+
declare function text(str: string, ...substitutions: Array<unknown>): string;
|
|
183
|
+
//#endregion
|
|
184
|
+
//#region src/Result.d.ts
|
|
185
|
+
type Result<T$1, E = unknown> = Success<T$1, E> | Failure<T$1, E>;
|
|
186
|
+
type Success<T$1, E> = {
|
|
187
|
+
chain<U$1, E2 = E>(fn: (value: T$1) => Result<U$1, E2>): Result<U$1, E | E2>;
|
|
188
|
+
map<U$1>(fn: (value: T$1) => U$1): Result<U$1, E>;
|
|
189
|
+
mapError<E2>(fn: (error: E) => E2): Result<T$1, E2>;
|
|
190
|
+
match<U$1>(handlers: {
|
|
191
|
+
ok: (value: T$1) => U$1;
|
|
192
|
+
err: (error: E) => U$1;
|
|
193
|
+
}): U$1;
|
|
194
|
+
readonly type: 'ok';
|
|
195
|
+
unwrap(): T$1;
|
|
196
|
+
unwrapOr(defaultValue: T$1): T$1;
|
|
197
|
+
readonly value: T$1;
|
|
198
|
+
};
|
|
199
|
+
type Failure<T$1, E> = {
|
|
200
|
+
chain<U$1, E2 = E>(fn: (value: T$1) => Result<U$1, E2>): Result<U$1, E | E2>;
|
|
201
|
+
readonly error: E;
|
|
202
|
+
map<U$1>(fn: (value: T$1) => U$1): Result<U$1, E>;
|
|
203
|
+
mapError<E2>(fn: (error: E) => E2): Result<T$1, E2>;
|
|
204
|
+
match<U$1>(handlers: {
|
|
205
|
+
ok: (value: T$1) => U$1;
|
|
206
|
+
err: (error: E) => U$1;
|
|
207
|
+
}): U$1;
|
|
208
|
+
readonly type: 'err';
|
|
209
|
+
unwrap(): T$1;
|
|
210
|
+
unwrapOr(defaultValue: T$1): T$1;
|
|
211
|
+
};
|
|
212
|
+
declare function ok<T$1, E = unknown>(value: T$1): Success<T$1, E>;
|
|
213
|
+
declare function err<T$1 = never, E = unknown>(error: E): Failure<T$1, E>;
|
|
214
|
+
declare const makeResult: {
|
|
215
|
+
readonly Ok: typeof ok;
|
|
216
|
+
readonly Err: typeof err;
|
|
217
|
+
};
|
|
218
|
+
declare function isResult(value: unknown): value is Result<unknown, unknown>;
|
|
219
|
+
declare function isSuccess<T$1, E>(value: Result<T$1, E>): value is Success<T$1, E>;
|
|
220
|
+
declare function isFailure<T$1, E>(value: Result<T$1, E>): value is Failure<T$1, E>;
|
|
221
|
+
/**
|
|
222
|
+
* Unwraps a Result.
|
|
223
|
+
* If the Result is Success, it returns the value.
|
|
224
|
+
* If the Result is Failure, it throws the error.
|
|
225
|
+
*/
|
|
226
|
+
declare function unwrap<T$1>(result: Result<T$1, any>): T$1;
|
|
227
|
+
//#endregion
|
|
228
|
+
//#region src/SimpleStateMachine.d.ts
|
|
229
|
+
declare const STATE_WILD_CARD = "*";
|
|
230
|
+
type TStateWildCard = typeof STATE_WILD_CARD;
|
|
231
|
+
type TransitionTarget<S extends string> = S | [S, CB<boolean, [payload?: any]>];
|
|
232
|
+
type StatesMap<S extends string = string, A extends string = string> = Record<S | TStateWildCard, Partial<Record<A, TransitionTarget<S>>>>;
|
|
233
|
+
type TStateMachine<S extends string = string, A extends string = string> = {
|
|
234
|
+
initial: S;
|
|
235
|
+
states: Partial<StatesMap<S, A>>;
|
|
236
|
+
};
|
|
237
|
+
type TStateMachineApi<S extends string = string, A extends string = string> = {
|
|
238
|
+
getState: CB<S>;
|
|
239
|
+
initial: CB<S>;
|
|
240
|
+
staticTransition: (from: S, action: A, payload?: any) => S;
|
|
241
|
+
transition: (action: A, payload?: any) => Result<void, string>;
|
|
242
|
+
};
|
|
243
|
+
type TransitionValue<V> = V extends [infer T, any] ? T extends string ? T : never : V extends string ? V : never;
|
|
244
|
+
type Values<T$1> = T$1[keyof T$1];
|
|
245
|
+
type StateConfigs<M extends {
|
|
246
|
+
states: Record<string, any>;
|
|
247
|
+
}> = Values<M['states']>;
|
|
248
|
+
type ActionFromConfig<M extends {
|
|
249
|
+
states: Record<string, any>;
|
|
250
|
+
}> = StateConfigs<M> extends infer SC ? SC extends any ? Extract<keyof SC, string> : never : never;
|
|
251
|
+
type TargetStatesFromConfig<M extends {
|
|
252
|
+
states: Record<string, any>;
|
|
253
|
+
}> = StateConfigs<M> extends infer SC ? SC extends any ? TransitionValue<Values<SC>> : never : never;
|
|
254
|
+
type StateFromConfig<M extends {
|
|
255
|
+
initial: string;
|
|
256
|
+
states: Record<string, any>;
|
|
257
|
+
}> = M['initial'] | Extract<keyof M['states'], string> | TargetStatesFromConfig<M>;
|
|
258
|
+
declare function StateMachine<M extends {
|
|
259
|
+
initial: string;
|
|
260
|
+
states: Record<string, any>;
|
|
261
|
+
}>(machine: M): TStateMachineApi<StateFromConfig<M>, ActionFromConfig<M>>;
|
|
262
|
+
//#endregion
|
|
263
|
+
//#region src/nonnullish.d.ts
|
|
264
|
+
declare function nonnullish<T$1>(value: Nullish<T$1>, error?: string): T$1;
|
|
265
|
+
//#endregion
|
|
266
|
+
//#region src/StringObject.d.ts
|
|
267
|
+
declare function StringObject(value?: Stringable): String;
|
|
268
|
+
//#endregion
|
|
269
|
+
//#region src/noop.d.ts
|
|
270
|
+
declare function noop(): void;
|
|
271
|
+
declare namespace Predicates_d_exports {
|
|
272
|
+
export { all, any };
|
|
273
|
+
}
|
|
274
|
+
declare function all<T$1 = any>(...p: Predicate<T$1>[]): (value: T$1) => boolean;
|
|
275
|
+
declare function any<T$1 = any>(...p: Predicate<T$1>[]): (value: T$1) => boolean;
|
|
276
|
+
//#endregion
|
|
277
|
+
//#region src/freezeAssign.d.ts
|
|
278
|
+
declare function freezeAssign<T$1 extends object>(...args: Partial<T$1>[]): T$1;
|
|
279
|
+
//#endregion
|
|
280
|
+
//#region src/withCatch.d.ts
|
|
281
|
+
declare function withCatch<T$1>(cb: CB<T$1>): () => T$1 | unknown;
|
|
282
|
+
//#endregion
|
|
283
|
+
//#region src/Brand.d.ts
|
|
284
|
+
type Brand<T$1, B> = T$1 & {
|
|
285
|
+
readonly __brand: B;
|
|
286
|
+
};
|
|
287
|
+
declare function makeBrand<T$1 extends Brand<any, any>>(value: unknown): T$1;
|
|
288
|
+
//#endregion
|
|
289
|
+
//#region src/toNumber.d.ts
|
|
290
|
+
declare function toNumber(value: any): Result<number, string>;
|
|
291
|
+
//#endregion
|
|
292
|
+
//#region src/IO.d.ts
|
|
293
|
+
type IO<T$1> = () => T$1;
|
|
294
|
+
//#endregion
|
|
295
|
+
export { type BlankValue, type Brand, type BusType, type CB, type CacheApi, type DropFirst, type DynamicValue, type Failure, type IO, type Maybe, type Nullable, type Nullish, type OneOrMoreOf, type Predicate, Predicates_d_exports as Predicates, type Result, StateMachine, StringObject, type Stringable, type TStateMachine, type TStateMachineApi, type TinyState, type ValueOf, asArray, _default as assign, bindNot, bus_d_exports as bus, createCache as cache, callEach, defaultTo, deferThrow, dynamicValue, either, freezeAssign, genSeq, greaterThan, hasOwnProperty, invariant, isArray, isBoolean, isEmpty, isEmptySet, isFailure, isFunction, isNotArray, isNotEmpty, isNotEmptySet, isNotNull, isNotNullish, isNotNumeric, isNotUndefined, isNull, isNullish, isNumeric, isObject, isPositive, isPromise, isResult, isStringValue, isSuccess, isUndefined, isUnsafeKey, lengthEquals, lengthNotEquals, longerThan, makeBrand, makeResult, mapFirst, nonnullish, noop, numberEquals, numberNotEquals, seq, text, tinyState_d_exports as tinyState, toNumber, unwrap, withCatch, withResolvers };
|
|
296
|
+
//# sourceMappingURL=vest-utils.d.cts.map
|