@stryke/types 0.10.23 → 0.10.24
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.d.cts +122 -2
- package/dist/array.d.cts.map +1 -0
- package/dist/array.d.mts +122 -2
- package/dist/array.d.mts.map +1 -0
- package/dist/async.d.cts +111 -2
- package/dist/async.d.cts.map +1 -0
- package/dist/async.d.mts +111 -2
- package/dist/async.d.mts.map +1 -0
- package/dist/base.cjs +3 -1
- package/dist/base.d.cts +331 -2
- package/dist/base.d.cts.map +1 -0
- package/dist/base.d.mts +331 -2
- package/dist/base.d.mts.map +1 -0
- package/dist/base.mjs +3 -1
- package/dist/base.mjs.map +1 -0
- package/dist/configuration.d.cts +71 -2
- package/dist/configuration.d.cts.map +1 -0
- package/dist/configuration.d.mts +71 -2
- package/dist/configuration.d.mts.map +1 -0
- package/dist/file.d.cts +51 -2
- package/dist/file.d.cts.map +1 -0
- package/dist/file.d.mts +51 -2
- package/dist/file.d.mts.map +1 -0
- package/dist/form.d.cts +40 -2
- package/dist/form.d.cts.map +1 -0
- package/dist/form.d.mts +40 -2
- package/dist/form.d.mts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +19 -18
- package/dist/index.d.mts +19 -18
- package/dist/index.mjs +1 -1
- package/dist/json.d.cts +70 -2
- package/dist/json.d.cts.map +1 -0
- package/dist/json.d.mts +70 -2
- package/dist/json.d.mts.map +1 -0
- package/dist/logic.d.cts +124 -2
- package/dist/logic.d.cts.map +1 -0
- package/dist/logic.d.mts +124 -2
- package/dist/logic.d.mts.map +1 -0
- package/dist/messages.d.cts +21 -2
- package/dist/messages.d.cts.map +1 -0
- package/dist/messages.d.mts +21 -2
- package/dist/messages.d.mts.map +1 -0
- package/dist/navigator.d.cts +42 -2
- package/dist/navigator.d.cts.map +1 -0
- package/dist/navigator.d.mts +42 -2
- package/dist/navigator.d.mts.map +1 -0
- package/dist/number.d.cts +181 -2
- package/dist/number.d.cts.map +1 -0
- package/dist/number.d.mts +181 -2
- package/dist/number.d.mts.map +1 -0
- package/dist/object.d.cts +394 -2
- package/dist/object.d.cts.map +1 -0
- package/dist/object.d.mts +394 -2
- package/dist/object.d.mts.map +1 -0
- package/dist/package-json.d.cts +261 -2
- package/dist/package-json.d.cts.map +1 -0
- package/dist/package-json.d.mts +261 -2
- package/dist/package-json.d.mts.map +1 -0
- package/dist/package-manager.d.cts +6 -2
- package/dist/package-manager.d.cts.map +1 -0
- package/dist/package-manager.d.mts +6 -2
- package/dist/package-manager.d.mts.map +1 -0
- package/dist/string.d.cts +81 -2
- package/dist/string.d.cts.map +1 -0
- package/dist/string.d.mts +81 -2
- package/dist/string.d.mts.map +1 -0
- package/dist/system.d.cts +5 -2
- package/dist/system.d.cts.map +1 -0
- package/dist/system.d.mts +5 -2
- package/dist/system.d.mts.map +1 -0
- package/dist/tsconfig.d.cts +803 -2
- package/dist/tsconfig.d.cts.map +1 -0
- package/dist/tsconfig.d.mts +803 -2
- package/dist/tsconfig.d.mts.map +1 -0
- package/dist/user.d.cts +29 -2
- package/dist/user.d.cts.map +1 -0
- package/dist/user.d.mts +29 -2
- package/dist/user.d.mts.map +1 -0
- package/dist/utilities.d.cts +51 -2
- package/dist/utilities.d.cts.map +1 -0
- package/dist/utilities.d.mts +51 -2
- package/dist/utilities.d.mts.map +1 -0
- package/dist/validations.d.cts +21 -2
- package/dist/validations.d.cts.map +1 -0
- package/dist/validations.d.mts +21 -2
- package/dist/validations.d.mts.map +1 -0
- package/package.json +3 -3
- package/dist/array-DVtfX_TI.d.mts +0 -122
- package/dist/array-DVtfX_TI.d.mts.map +0 -1
- package/dist/array-DtIKbcDr.d.cts +0 -122
- package/dist/array-DtIKbcDr.d.cts.map +0 -1
- package/dist/async-BtPWg6IL.d.mts +0 -111
- package/dist/async-BtPWg6IL.d.mts.map +0 -1
- package/dist/async-eKWh-_sF.d.cts +0 -111
- package/dist/async-eKWh-_sF.d.cts.map +0 -1
- package/dist/base-CiIyKS-b.d.mts +0 -331
- package/dist/base-CiIyKS-b.d.mts.map +0 -1
- package/dist/base-Cpeh4C5c.cjs +0 -3
- package/dist/base-DmFPRVSE.mjs +0 -3
- package/dist/base-DmFPRVSE.mjs.map +0 -1
- package/dist/base-EF17pdAI.d.cts +0 -331
- package/dist/base-EF17pdAI.d.cts.map +0 -1
- package/dist/configuration-5Q2wg3Id.d.mts +0 -71
- package/dist/configuration-5Q2wg3Id.d.mts.map +0 -1
- package/dist/configuration-Dvz7q6dd.d.cts +0 -71
- package/dist/configuration-Dvz7q6dd.d.cts.map +0 -1
- package/dist/file-dM8RAMNC.d.cts +0 -51
- package/dist/file-dM8RAMNC.d.cts.map +0 -1
- package/dist/file-eWushyiM.d.mts +0 -51
- package/dist/file-eWushyiM.d.mts.map +0 -1
- package/dist/form-mTzpZCeA.d.cts +0 -40
- package/dist/form-mTzpZCeA.d.cts.map +0 -1
- package/dist/form-sNCVXIEk.d.mts +0 -40
- package/dist/form-sNCVXIEk.d.mts.map +0 -1
- package/dist/json-BlaU0Pbq.d.cts +0 -70
- package/dist/json-BlaU0Pbq.d.cts.map +0 -1
- package/dist/json-C3wqh2t3.d.mts +0 -70
- package/dist/json-C3wqh2t3.d.mts.map +0 -1
- package/dist/logic-BoEG5A3-.d.cts +0 -374
- package/dist/logic-BoEG5A3-.d.cts.map +0 -1
- package/dist/logic-h9Jrrpsk.d.mts +0 -374
- package/dist/logic-h9Jrrpsk.d.mts.map +0 -1
- package/dist/messages-Bxu_o13x.d.mts +0 -21
- package/dist/messages-Bxu_o13x.d.mts.map +0 -1
- package/dist/messages-PtLJRJeN.d.cts +0 -21
- package/dist/messages-PtLJRJeN.d.cts.map +0 -1
- package/dist/navigator-DLpMW73v.d.mts +0 -42
- package/dist/navigator-DLpMW73v.d.mts.map +0 -1
- package/dist/navigator-wsxMUGqK.d.cts +0 -42
- package/dist/navigator-wsxMUGqK.d.cts.map +0 -1
- package/dist/object-B3Rc0f80.d.mts +0 -392
- package/dist/object-B3Rc0f80.d.mts.map +0 -1
- package/dist/object-DyLgFijN.d.cts +0 -392
- package/dist/object-DyLgFijN.d.cts.map +0 -1
- package/dist/package-json-BYMmXu4B.d.mts +0 -261
- package/dist/package-json-BYMmXu4B.d.mts.map +0 -1
- package/dist/package-json-DMeUqEmW.d.cts +0 -261
- package/dist/package-json-DMeUqEmW.d.cts.map +0 -1
- package/dist/package-manager-PRcovqs-.d.mts +0 -6
- package/dist/package-manager-PRcovqs-.d.mts.map +0 -1
- package/dist/package-manager-tcG2TLVT.d.cts +0 -6
- package/dist/package-manager-tcG2TLVT.d.cts.map +0 -1
- package/dist/system-BxYi2_rE.d.mts +0 -5
- package/dist/system-BxYi2_rE.d.mts.map +0 -1
- package/dist/system-n1LPjzuJ.d.cts +0 -5
- package/dist/system-n1LPjzuJ.d.cts.map +0 -1
- package/dist/tsconfig-C6dWY2RO.d.cts +0 -803
- package/dist/tsconfig-C6dWY2RO.d.cts.map +0 -1
- package/dist/tsconfig-CUKA7cEN.d.mts +0 -803
- package/dist/tsconfig-CUKA7cEN.d.mts.map +0 -1
- package/dist/user-CkdO4wnf.d.mts +0 -29
- package/dist/user-CkdO4wnf.d.mts.map +0 -1
- package/dist/user-CovHR6Ne.d.cts +0 -29
- package/dist/user-CovHR6Ne.d.cts.map +0 -1
- package/dist/utilities-BVS-gcgS.d.mts +0 -51
- package/dist/utilities-BVS-gcgS.d.mts.map +0 -1
- package/dist/utilities-Jb4ggdM-.d.cts +0 -51
- package/dist/utilities-Jb4ggdM-.d.cts.map +0 -1
- package/dist/validations-C_7osVpS.d.mts +0 -21
- package/dist/validations-C_7osVpS.d.mts.map +0 -1
- package/dist/validations-CvwxY4RE.d.cts +0 -21
- package/dist/validations-CvwxY4RE.d.cts.map +0 -1
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { K as IsUnknown, j as FunctionLike } from "./base-EF17pdAI.cjs";
|
|
2
|
-
|
|
3
|
-
//#region src/async.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Get the type of the value that a promise resolves to.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```
|
|
10
|
-
* import type {Awaited} from 'type-fest';
|
|
11
|
-
*
|
|
12
|
-
* const value: Awaited<Promise<string>> = 'foo';
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
type Awaitable<T> = T | PromiseLike<T>;
|
|
16
|
-
/**
|
|
17
|
-
* A type that can be either a value or a function that returns a value.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```
|
|
21
|
-
* import type {Resolvable} from 'type-fest';
|
|
22
|
-
*
|
|
23
|
-
* const foo: Resolvable<string> = 'bar';
|
|
24
|
-
* const bar: Resolvable<string> = () => 'baz';
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
type Resolvable<T> = Awaitable<T> | (() => Awaitable<T>);
|
|
28
|
-
/**
|
|
29
|
-
* Create a function type with a return type of your choice and the same parameters as the given function type.
|
|
30
|
-
*
|
|
31
|
-
* Use-case: You want to define a wrapped function that returns something different while receiving the same parameters. For example, you might want to wrap a function that can throw an error into one that will return `undefined` instead.
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* ```
|
|
35
|
-
* import type {SetReturnType} from 'type-fest';
|
|
36
|
-
*
|
|
37
|
-
* type MyFunctionThatCanThrow = (foo: SomeType, bar: unknown) => SomeOtherType;
|
|
38
|
-
*
|
|
39
|
-
* type MyWrappedFunction = SetReturnType<MyFunctionThatCanThrow, SomeOtherType | undefined>;
|
|
40
|
-
* //=> type MyWrappedFunction = (foo: SomeType, bar: unknown) => SomeOtherType | undefined;
|
|
41
|
-
* ```
|
|
42
|
-
*/
|
|
43
|
-
type SetReturnType<TFunct extends (...arguments_: any[]) => any, TypeToReturn> = TFunct extends ((this: infer ThisArgument, ...arguments_: infer Arguments) => any) ? IsUnknown<ThisArgument> extends true ? (...arguments_: Arguments) => TypeToReturn : (this: ThisArgument, ...arguments_: Arguments) => TypeToReturn : (...arguments_: Parameters<TFunct>) => TypeToReturn;
|
|
44
|
-
type AsyncFunction = (...arguments_: any[]) => Promise<unknown>;
|
|
45
|
-
/**
|
|
46
|
-
* Unwrap the return type of a function that returns a `Promise`.
|
|
47
|
-
*
|
|
48
|
-
* There has been [discussion](https://github.com/microsoft/TypeScript/pull/35998) about implementing this type in TypeScript.
|
|
49
|
-
*
|
|
50
|
-
* @example
|
|
51
|
-
* ```ts
|
|
52
|
-
* import type {AsyncReturnType} from 'type-fest';
|
|
53
|
-
* import {asyncFunction} from 'api';
|
|
54
|
-
*
|
|
55
|
-
* // This type resolves to the unwrapped return type of `asyncFunction`.
|
|
56
|
-
* type Value = AsyncReturnType<typeof asyncFunction>;
|
|
57
|
-
*
|
|
58
|
-
* async function doSomething(value: Value) {}
|
|
59
|
-
*
|
|
60
|
-
* asyncFunction().then(value => doSomething(value));
|
|
61
|
-
* ```
|
|
62
|
-
*/
|
|
63
|
-
type AsyncReturnType<Target extends AsyncFunction> = Awaited<ReturnType<Target>>;
|
|
64
|
-
/**
|
|
65
|
-
* Create an async version of the given function type, by boxing the return type in `Promise` while keeping the same parameter types.
|
|
66
|
-
*
|
|
67
|
-
* Use-case: You have two functions, one synchronous and one asynchronous that do the same thing. Instead of having to duplicate the type definition, you can use `Asyncify` to reuse the synchronous type.
|
|
68
|
-
*
|
|
69
|
-
* @example
|
|
70
|
-
* ```
|
|
71
|
-
* import type {Asyncify} from 'type-fest';
|
|
72
|
-
*
|
|
73
|
-
* // Synchronous function.
|
|
74
|
-
* function getFooSync(someArg: SomeType): Foo {
|
|
75
|
-
* // …
|
|
76
|
-
* }
|
|
77
|
-
*
|
|
78
|
-
* type AsyncifiedFooGetter = Asyncify<typeof getFooSync>;
|
|
79
|
-
* //=> type AsyncifiedFooGetter = (someArg: SomeType) => Promise<Foo>;
|
|
80
|
-
*
|
|
81
|
-
* // Same as `getFooSync` but asynchronous.
|
|
82
|
-
* const getFooAsync: AsyncifiedFooGetter = (someArg) => {
|
|
83
|
-
* // TypeScript now knows that `someArg` is `SomeType` automatically.
|
|
84
|
-
* // It also knows that this function must return `Promise<Foo>`.
|
|
85
|
-
* // If you have `@typescript-eslint/promise-function-async` linter rule enabled, it will even report that "Functions that return promises must be async.".
|
|
86
|
-
*
|
|
87
|
-
* // …
|
|
88
|
-
* }
|
|
89
|
-
* ```
|
|
90
|
-
*/
|
|
91
|
-
type Asyncify<TFunct extends FunctionLike> = SetReturnType<TFunct, Promise<Awaited<ReturnType<TFunct>>>>;
|
|
92
|
-
/**
|
|
93
|
-
* Get the result type of a `Promise`
|
|
94
|
-
*
|
|
95
|
-
* @example
|
|
96
|
-
* ```ts
|
|
97
|
-
* import { Await } from '@stryke/types'
|
|
98
|
-
*
|
|
99
|
-
* const promise = new Promise<string>((res, rej) => res('x'))
|
|
100
|
-
*
|
|
101
|
-
* type test0 = C.Await<typeof promise> // string
|
|
102
|
-
* type test1 = C.Await<Promise<number>> // number
|
|
103
|
-
* ```
|
|
104
|
-
*
|
|
105
|
-
* @param P - A promise
|
|
106
|
-
* @returns [[Any]]
|
|
107
|
-
*/
|
|
108
|
-
type Await<P> = P extends Promise<infer A> ? A : P;
|
|
109
|
-
//#endregion
|
|
110
|
-
export { Awaitable as a, Await as i, AsyncReturnType as n, Resolvable as o, Asyncify as r, SetReturnType as s, AsyncFunction as t };
|
|
111
|
-
//# sourceMappingURL=async-eKWh-_sF.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"async-eKWh-_sF.d.cts","names":[],"sources":["../src/async.ts"],"sourcesContent":[],"mappings":";;;;;;AA8BA;;;;;AAaA;;;AAA4D,KAbhD,SAagD,CAAA,CAAA,CAAA,GAbjC,CAaiC,GAb7B,WAa6B,CAbjB,CAaiB,CAAA;;;AAiB5D;;;;;;;;;AAeiC,KAhCrB,UAgCqB,CAAA,CAAA,CAAA,GAhCL,SAgCK,CAhCK,CAgCL,CAAA,GAAA,CAAA,GAAA,GAhCiB,SAgCjB,CAhC2B,CAgC3B,CAAA,CAAA;;;;AAEjC;AAoBA;;;;;;AA+BA;;;;;AAEU,KAtEE,aAsEF,CAAA,eAAA,CAAA,GAAA,UAAA,EAAA,GAAA,EAAA,EAAA,GAAA,GAAA,EAAA,YAAA,CAAA,GAjER,MAiEQ,UAAA,CAAA,IAAA,EAAA,KAAA,aAAA,EAAA,GAAA,UAAA,EAAA,KAAA,UAAA,EAAA,GAAA,GAAA,IA3DJ,SA2DI,CA3DM,YA2DN,CAAA,SAAA,IAAA,GAAA,CAAA,GAAA,UAAA,EA1Dc,SA0Dd,EAAA,GA1D4B,YA0D5B,GAAA,CAAA,IAAA,EAzDK,YAyDL,EAAA,GAAA,UAAA,EAzDkC,SAyDlC,EAAA,GAzDgD,YAyDhD,GAAA,CAAA,GAAA,UAAA,EAvDY,UAuDZ,CAvDuB,MAuDvB,CAAA,EAAA,GAvDmC,YAuDnC;AAAR,KArDU,aAAA,GAqDV,CAAA,GAAA,UAAA,EAAA,GAAA,EAAA,EAAA,GArDoD,OAqDpD,CAAA,OAAA,CAAA;;;AAmBF;;;;;;;;;;;;;;;;KApDY,+BAA+B,iBAAiB,QAC1D,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA8BD,wBAAwB,gBAAgB,cAClD,QACA,QAAQ,QAAQ,WAAW;;;;;;;;;;;;;;;;;KAmBjB,WAAW,UAAU,uBAAuB"}
|
package/dist/base-CiIyKS-b.d.mts
DELETED
|
@@ -1,331 +0,0 @@
|
|
|
1
|
-
import { l as TypedArray } from "./array-DVtfX_TI.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/base.d.ts
|
|
4
|
-
type SerializablePrimitive = null | undefined | string | number | boolean | bigint;
|
|
5
|
-
type Primitive = SerializablePrimitive | symbol;
|
|
6
|
-
/**
|
|
7
|
-
* Matches any primitive, `void`, `Date`, or `RegExp` value.
|
|
8
|
-
*/
|
|
9
|
-
type BuiltIns = Primitive | void | Date | RegExp;
|
|
10
|
-
/**
|
|
11
|
-
* Matches any non-primitive object
|
|
12
|
-
*/
|
|
13
|
-
type AtomicObject = Function | Promise<any> | Date | RegExp;
|
|
14
|
-
/** Determines if the passed value is of a specific type */
|
|
15
|
-
type TypeTester = (value: any) => boolean;
|
|
16
|
-
/**
|
|
17
|
-
* The interface for a type mapping (key =\> function) to use for {@link getType}.
|
|
18
|
-
* export * The key represents the name of the type. The function represents the {@link TypeTester | test method}.
|
|
19
|
-
* The map should be ordered by testing preference, with more specific tests first.
|
|
20
|
-
* If a test returns true, it is selected, and the key is returned as the type.
|
|
21
|
-
*/
|
|
22
|
-
type TypeMap = Record<string, TypeTester>;
|
|
23
|
-
declare const emptyObjectSymbol: unique symbol;
|
|
24
|
-
type FunctionOrValue<Value> = Value extends (() => infer X) ? X : Value;
|
|
25
|
-
/**
|
|
26
|
-
* A [[List]]
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```ts
|
|
30
|
-
* type list0 = [1, 2, 3]
|
|
31
|
-
* type list1 = number[]
|
|
32
|
-
* ```
|
|
33
|
-
*
|
|
34
|
-
* @param A - its type
|
|
35
|
-
* @returns [[List]]
|
|
36
|
-
*/
|
|
37
|
-
type List<A = any> = ReadonlyArray<A>;
|
|
38
|
-
/**
|
|
39
|
-
* Alias to create a [[Function]]
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* ```ts
|
|
43
|
-
* import { FunctionLike } from '@stryke/types'
|
|
44
|
-
*
|
|
45
|
-
* type test0 = FunctionLike<[string, number], boolean>
|
|
46
|
-
* /// (args_0: string, args_1: number) => boolean
|
|
47
|
-
* ```
|
|
48
|
-
*
|
|
49
|
-
* @param P - parameters
|
|
50
|
-
* @param R - return type
|
|
51
|
-
* @returns [[Function]]
|
|
52
|
-
*/
|
|
53
|
-
type FunctionLike<P extends List = any, R$1 = any> = (...args: P) => R$1;
|
|
54
|
-
type AnyFunction = FunctionLike<any, any>;
|
|
55
|
-
type Nullish = undefined | null;
|
|
56
|
-
type Nullishable<T> = T | Nullish;
|
|
57
|
-
type NonNullishObject = object;
|
|
58
|
-
type NativeClass = abstract new (...args: any) => any;
|
|
59
|
-
type AnyNumber = number | number;
|
|
60
|
-
type AnyString = string | string;
|
|
61
|
-
type AnyBoolean = boolean | boolean;
|
|
62
|
-
type AnyArray = any[];
|
|
63
|
-
type PlainObject = Record<any, object>;
|
|
64
|
-
type AnyMap = Map<any, any>;
|
|
65
|
-
type AnyWeakMap = WeakMap<WeakKey, any>;
|
|
66
|
-
type EmptyArray = [];
|
|
67
|
-
interface EmptyObject {
|
|
68
|
-
[emptyObjectSymbol]?: never;
|
|
69
|
-
}
|
|
70
|
-
type Any = boolean | number | bigint | string | null | undefined | void | symbol | object | PlainObject | AnyArray | AnyMap | AnyWeakMap;
|
|
71
|
-
/**
|
|
72
|
-
* The valid types of the index for an `Indexable` type object
|
|
73
|
-
*/
|
|
74
|
-
type IndexType = string | number | symbol;
|
|
75
|
-
/**
|
|
76
|
-
* The declaration of a ***dictionary-type*** object with a specific type
|
|
77
|
-
*
|
|
78
|
-
* @see {@link Indexable}
|
|
79
|
-
* @see {@link IndexType}
|
|
80
|
-
* @see {@link Dictionary}
|
|
81
|
-
*/
|
|
82
|
-
type TypedIndexable<T> = Record<IndexType, T>;
|
|
83
|
-
/**
|
|
84
|
-
* The declaration of a ***dictionary-type*** object
|
|
85
|
-
*
|
|
86
|
-
* @see {@link TypedIndexable}
|
|
87
|
-
* @see {@link IndexType}
|
|
88
|
-
* @see {@link Dictionary}
|
|
89
|
-
*/
|
|
90
|
-
type Indexable = TypedIndexable<any>;
|
|
91
|
-
/**
|
|
92
|
-
* The declaration of a ***dictionary-type*** object with a specific type
|
|
93
|
-
*
|
|
94
|
-
* @see {@link Indexable}
|
|
95
|
-
* @see {@link IndexType}
|
|
96
|
-
* @see {@link TypedIndexable}
|
|
97
|
-
*/
|
|
98
|
-
type Dictionary<T> = Record<string, T>;
|
|
99
|
-
declare const EMPTY_STRING = "";
|
|
100
|
-
declare const NEWLINE_STRING = "\r\n";
|
|
101
|
-
declare const EMPTY_OBJECT: {};
|
|
102
|
-
type AnyCase<T extends IndexType> = string extends T ? string : T extends `${infer F1}${infer F2}${infer R}` ? `${Uppercase<F1> | Lowercase<F1>}${Uppercase<F2> | Lowercase<F2>}${AnyCase<R>}` : T extends `${infer F}${infer R}` ? `${Uppercase<F> | Lowercase<F>}${AnyCase<R>}` : typeof EMPTY_STRING;
|
|
103
|
-
type Newable<T> = new (..._args: never[]) => T;
|
|
104
|
-
interface Abstract<T> {
|
|
105
|
-
prototype: T;
|
|
106
|
-
}
|
|
107
|
-
interface Clonable<T> {
|
|
108
|
-
clone: () => T;
|
|
109
|
-
}
|
|
110
|
-
type MaybePromise<T> = T | Promise<T>;
|
|
111
|
-
type ReducerFunction<TState, TAction> = (state: TState, action: TAction) => TState;
|
|
112
|
-
declare const TYPE_ARGUMENTS = "Arguments";
|
|
113
|
-
declare const TYPE_ARRAY = "Array";
|
|
114
|
-
declare const TYPE_OBJECT = "Object";
|
|
115
|
-
declare const TYPE_MAP = "Map";
|
|
116
|
-
declare const TYPE_SET = "Set";
|
|
117
|
-
type Collection = IArguments | unknown[] | Map<unknown, unknown> | Record<string | number | symbol, unknown> | Set<unknown>;
|
|
118
|
-
type NonUndefined<T> = T extends undefined ? never : T;
|
|
119
|
-
type BrowserNativeObject = Date | File;
|
|
120
|
-
type DeepPartial<T> = T extends BrowserNativeObject | NestedValue ? T : { [K in keyof T]?: DeepPartial<T[K]> };
|
|
121
|
-
type Rollback = Record<string, (initialValue: any, currentValue: any) => any>;
|
|
122
|
-
/**
|
|
123
|
-
* Extract all required keys from the given type.
|
|
124
|
-
*
|
|
125
|
-
* @remarks
|
|
126
|
-
* This is useful when you want to create a new type that contains different type values for the required keys only or use the list of keys for validation purposes, etc...
|
|
127
|
-
*/
|
|
128
|
-
type RequiredKeysOf<BaseType extends object> = Exclude<{ [Key in keyof BaseType]: BaseType extends Record<Key, BaseType[Key]> ? Key : never }[keyof BaseType], undefined>;
|
|
129
|
-
/**
|
|
130
|
-
* Returns a boolean for whether the two given types are equal.
|
|
131
|
-
*
|
|
132
|
-
* @remarks
|
|
133
|
-
* Use-cases: If you want to make a conditional branch based on the result of a comparison of two types.
|
|
134
|
-
*
|
|
135
|
-
* @see https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
136
|
-
* @see https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
137
|
-
*/
|
|
138
|
-
type IsEqual<A, B> = (<G>() => G extends A ? 1 : 2) extends (<G>() => G extends B ? 1 : 2) ? true : false;
|
|
139
|
-
type Filter<KeyType$1, ExcludeType> = IsEqual<KeyType$1, ExcludeType> extends true ? never : KeyType$1 extends ExcludeType ? never : KeyType$1;
|
|
140
|
-
interface ExceptOptions {
|
|
141
|
-
/**
|
|
142
|
-
Disallow assigning non-specified properties.
|
|
143
|
-
Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
|
|
144
|
-
@defaultValue false
|
|
145
|
-
*/
|
|
146
|
-
requireExactProps?: boolean;
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Create a type from an object type without certain keys.
|
|
150
|
-
*
|
|
151
|
-
* @remarks
|
|
152
|
-
* We recommend setting the `requireExactProps` option to `true`.
|
|
153
|
-
*
|
|
154
|
-
* This type is a stricter version of [`Omit`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-5.html#the-omit-helper-type). The `Omit` type does not restrict the omitted keys to be keys present on the given type, while `Except` does. The benefits of a stricter type are avoiding typos and allowing the compiler to pick up on rename refactors automatically.
|
|
155
|
-
*
|
|
156
|
-
* This type was proposed to the TypeScript team, which declined it, saying they prefer that libraries implement stricter versions of the built-in types ([microsoft/TypeScript#30825](https://github.com/microsoft/TypeScript/issues/30825#issuecomment-523668235)).
|
|
157
|
-
*/
|
|
158
|
-
type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {
|
|
159
|
-
requireExactProps: false;
|
|
160
|
-
}> = { [KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType] } & (Options["requireExactProps"] extends true ? Partial<Record<KeysType, never>> : Record<string, never>);
|
|
161
|
-
/**
|
|
162
|
-
* Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.
|
|
163
|
-
*
|
|
164
|
-
* @remarks
|
|
165
|
-
* Sometimes it is desired to pass a value as a function argument that has a different type. At first inspection it may seem assignable, and then you discover it is not because the `value`'s type definition was defined as an interface. In the following example, `fn` requires an argument of type `Record<string, unknown>`. If the value is defined as a literal, then it is assignable. And if the `value` is defined as type using the `Simplify` utility the value is assignable. But if the `value` is defined as an interface, it is not assignable because the interface is not sealed and elsewhere a non-string property could be added to the interface.
|
|
166
|
-
*
|
|
167
|
-
* If the type definition must be an interface (perhaps it was defined in a third-party npm package), then the `value` can be defined as `const value: Simplify<SomeInterface> = ...`. Then `value` will be assignable to the `fn` argument. Or the `value` can be cast as `Simplify<SomeInterface>` if you can't re-declare the `value`.
|
|
168
|
-
*
|
|
169
|
-
* @see https://github.com/microsoft/TypeScript/issues/15300
|
|
170
|
-
*/
|
|
171
|
-
type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
|
|
172
|
-
/**
|
|
173
|
-
* Create a type that makes the given keys required. The remaining keys are kept as is. The sister of the `SetOptional` type.
|
|
174
|
-
*
|
|
175
|
-
* @remarks
|
|
176
|
-
* Use-case: You want to define a single model where the only thing that changes is whether or not some of the keys are required.
|
|
177
|
-
*/
|
|
178
|
-
type SetRequired<BaseType, Keys extends keyof BaseType> = BaseType extends unknown ? Simplify<Except<BaseType, Keys> & Required<Pick<BaseType, Keys>>> : never;
|
|
179
|
-
declare const $NestedValue: unique symbol;
|
|
180
|
-
type NestedValue<TValue extends object = object> = {
|
|
181
|
-
[$NestedValue]: never;
|
|
182
|
-
} & TValue;
|
|
183
|
-
interface RefObject<T> {
|
|
184
|
-
current: T;
|
|
185
|
-
}
|
|
186
|
-
interface Identity<T = string> {
|
|
187
|
-
id: T;
|
|
188
|
-
}
|
|
189
|
-
interface Versioned {
|
|
190
|
-
version: number;
|
|
191
|
-
}
|
|
192
|
-
interface Sequenced {
|
|
193
|
-
/**
|
|
194
|
-
* The sequence number (version, or event counter, etc.) of the record
|
|
195
|
-
*/
|
|
196
|
-
sequence: number;
|
|
197
|
-
}
|
|
198
|
-
interface Typed {
|
|
199
|
-
/**
|
|
200
|
-
* The type of the record
|
|
201
|
-
*/
|
|
202
|
-
__type: string;
|
|
203
|
-
}
|
|
204
|
-
interface ClassTypeCheckable<T> extends Typed {
|
|
205
|
-
/**
|
|
206
|
-
* Run type check on the given value
|
|
207
|
-
* @param value - The value to check
|
|
208
|
-
* @returns True if the value is of the type of the class
|
|
209
|
-
*/
|
|
210
|
-
isTypeOf: (value: unknown) => value is T;
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* Matches non-recursive types.
|
|
214
|
-
*/
|
|
215
|
-
type NonRecursiveType = BuiltIns | Function | (new (...arguments_: any[]) => unknown);
|
|
216
|
-
type IsPrimitive<T> = [T] extends [Primitive] ? true : false;
|
|
217
|
-
type IsNever<T> = [T] extends [never] ? true : false;
|
|
218
|
-
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
219
|
-
type IsNull<T> = [T] extends [null] ? true : false;
|
|
220
|
-
type IsUndefined<T> = T extends undefined ? true : false;
|
|
221
|
-
type IsUnknown<T> = unknown extends T ? IsNull<T> extends false ? true : false : false;
|
|
222
|
-
type IsNullish<T> = IsNull<T> & IsUndefined<T>;
|
|
223
|
-
type IsFunction<T> = T extends AnyFunction ? true : false;
|
|
224
|
-
/**
|
|
225
|
-
* Declare locally scoped properties on `globalThis`.
|
|
226
|
-
*
|
|
227
|
-
* When defining a global variable in a declaration file is inappropriate, it can be helpful to define a `type` or `interface` (say `ExtraGlobals`) with the global variable and then cast `globalThis` via code like `globalThis as unknown as ExtraGlobals`.
|
|
228
|
-
*
|
|
229
|
-
* Instead of casting through `unknown`, you can update your `type` or `interface` to extend `GlobalThis` and then directly cast `globalThis`.
|
|
230
|
-
*
|
|
231
|
-
* @example
|
|
232
|
-
* ```
|
|
233
|
-
* import type { GlobalThis } from '@stryke/types';
|
|
234
|
-
*
|
|
235
|
-
* type ExtraGlobals = GlobalThis & {
|
|
236
|
-
* readonly GLOBAL_TOKEN: string;
|
|
237
|
-
* };
|
|
238
|
-
*
|
|
239
|
-
* (globalThis as ExtraGlobals).GLOBAL_TOKEN;
|
|
240
|
-
* ```
|
|
241
|
-
*/
|
|
242
|
-
type GlobalThis = typeof globalThis;
|
|
243
|
-
/**
|
|
244
|
-
* Matches a [`class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).
|
|
245
|
-
*/
|
|
246
|
-
interface Class<T, Arguments extends unknown[] = any[]> {
|
|
247
|
-
prototype: Pick<T, keyof T>;
|
|
248
|
-
new (...arguments_: Arguments): T;
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* Matches a [`class` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).
|
|
252
|
-
*/
|
|
253
|
-
type Constructor<T, Arguments extends unknown[] = any[]> = new (...arguments_: Arguments) => T;
|
|
254
|
-
/**
|
|
255
|
-
* Matches an [`abstract class`](https://www.typescriptlang.org/docs/handbook/classes.html#abstract-classes).
|
|
256
|
-
*
|
|
257
|
-
* @privateRemarks
|
|
258
|
-
* We cannot use a `type` here because TypeScript throws: 'abstract' modifier cannot appear on a type member. (1070)
|
|
259
|
-
*/
|
|
260
|
-
interface AbstractClass<T, Arguments extends unknown[] = any[]> extends AbstractConstructor<T, Arguments> {
|
|
261
|
-
prototype: Pick<T, keyof T>;
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* Matches an [`abstract class`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-2.html#abstract-construct-signatures) constructor.
|
|
265
|
-
*/
|
|
266
|
-
type AbstractConstructor<T, Arguments extends unknown[] = any[]> = abstract new (...arguments_: Arguments) => T;
|
|
267
|
-
/**
|
|
268
|
-
* Create a tuple type of the given length `<L>` and fill it with the given type `<Fill>`.
|
|
269
|
-
*
|
|
270
|
-
* If `<Fill>` is not provided, it will default to `unknown`.
|
|
271
|
-
*
|
|
272
|
-
* @see https://itnext.io/implementing-arithmetic-within-typescripts-type-system-a1ef140a6f6f
|
|
273
|
-
*/
|
|
274
|
-
type BuildTuple<L extends number, Fill = unknown, T extends readonly unknown[] = []> = T["length"] extends L ? T : BuildTuple<L, Fill, [...T, Fill]>;
|
|
275
|
-
/**
|
|
276
|
-
* Test if the given function has multiple call signatures.
|
|
277
|
-
*
|
|
278
|
-
* Needed to handle the case of a single call signature with properties.
|
|
279
|
-
*
|
|
280
|
-
* Multiple call signatures cannot currently be supported due to a TypeScript limitation.
|
|
281
|
-
* @see https://github.com/microsoft/TypeScript/issues/29732
|
|
282
|
-
*/
|
|
283
|
-
type HasMultipleCallSignatures<T extends (...arguments_: any[]) => unknown> = T extends {
|
|
284
|
-
(...arguments_: infer A): unknown;
|
|
285
|
-
(...arguments_: infer B): unknown;
|
|
286
|
-
} ? B extends A ? A extends B ? false : true : true : false;
|
|
287
|
-
type StructuredCloneablePrimitive = string | number | bigint | boolean | null | undefined | boolean | number | string;
|
|
288
|
-
type StructuredCloneableData = ArrayBuffer | DataView | Date | Error | RegExp | TypedArray | Blob | File;
|
|
289
|
-
type StructuredCloneableCollection = readonly StructuredCloneable[] | {
|
|
290
|
-
readonly [key: string]: StructuredCloneable;
|
|
291
|
-
readonly [key: number]: StructuredCloneable;
|
|
292
|
-
} | ReadonlyMap<StructuredCloneable, StructuredCloneable> | ReadonlySet<StructuredCloneable>;
|
|
293
|
-
/**
|
|
294
|
-
* Matches a value that can be losslessly cloned using `structuredClone`.
|
|
295
|
-
*
|
|
296
|
-
* Note:
|
|
297
|
-
* - Custom error types will be cloned as the base `Error` type
|
|
298
|
-
* - This type doesn't include types exclusive to the TypeScript DOM library (e.g. `DOMRect` and `VideoFrame`)
|
|
299
|
-
*
|
|
300
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm
|
|
301
|
-
*
|
|
302
|
-
* @example
|
|
303
|
-
* ```
|
|
304
|
-
* import type { StructuredCloneable } from '@stryke/types';
|
|
305
|
-
*
|
|
306
|
-
* class CustomClass {}
|
|
307
|
-
*
|
|
308
|
-
* // @ts-expect-error
|
|
309
|
-
* const error: StructuredCloneable = {
|
|
310
|
-
* custom: new CustomClass(),
|
|
311
|
-
* };
|
|
312
|
-
*
|
|
313
|
-
* structuredClone(error);
|
|
314
|
-
* //=> {custom: {}}
|
|
315
|
-
*
|
|
316
|
-
* const good: StructuredCloneable = {
|
|
317
|
-
* number: 3,
|
|
318
|
-
* date: new Date(),
|
|
319
|
-
* map: new Map<string, number>(),
|
|
320
|
-
* }
|
|
321
|
-
*
|
|
322
|
-
* good.map.set('key', 1);
|
|
323
|
-
*
|
|
324
|
-
* structuredClone(good);
|
|
325
|
-
* //=> {number: 3, date: Date(2022-10-17 22:22:35.920), map: Map {'key' -> 1}}
|
|
326
|
-
* ```
|
|
327
|
-
*/
|
|
328
|
-
type StructuredCloneable = StructuredCloneablePrimitive | StructuredCloneableData | StructuredCloneableCollection;
|
|
329
|
-
//#endregion
|
|
330
|
-
export { NonNullishObject as $, Filter as A, IsFunction as B, DeepPartial as C, TypedIndexable as Ct, EmptyArray as D, EMPTY_STRING as E, Identity as F, IsUndefined as G, IsNull as H, IndexType as I, MaybePromise as J, IsUnknown as K, Indexable as L, FunctionOrValue as M, GlobalThis as N, EmptyObject as O, HasMultipleCallSignatures as P, Newable as Q, IsAny as R, Constructor as S, Typed as St, EMPTY_OBJECT as T, IsNullish as U, IsNever as V, IsPrimitive as W, NativeClass as X, NEWLINE_STRING as Y, NestedValue as Z, BuiltIns as _, TYPE_MAP as _t, Any as a, Primitive as at, Clonable as b, TypeMap as bt, AnyCase as c, RequiredKeysOf as ct, AnyNumber as d, SerializablePrimitive as dt, NonRecursiveType as et, AnyString as f, SetRequired as ft, BuildTuple as g, TYPE_ARRAY as gt, BrowserNativeObject as h, TYPE_ARGUMENTS as ht, AbstractConstructor as i, PlainObject as it, FunctionLike as j, Except as k, AnyFunction as l, Rollback as lt, AtomicObject as m, StructuredCloneable as mt, Abstract as n, Nullish as nt, AnyArray as o, ReducerFunction as ot, AnyWeakMap as p, Simplify as pt, List as q, AbstractClass as r, Nullishable as rt, AnyBoolean as s, RefObject as st, $NestedValue as t, NonUndefined as tt, AnyMap as u, Sequenced as ut, Class as v, TYPE_OBJECT as vt, Dictionary as w, Versioned as wt, Collection as x, TypeTester as xt, ClassTypeCheckable as y, TYPE_SET as yt, IsEqual as z };
|
|
331
|
-
//# sourceMappingURL=base-CiIyKS-b.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base-CiIyKS-b.d.mts","names":[],"sources":["../src/base.ts"],"sourcesContent":[],"mappings":";;;KAoBY,qBAAA;KAOA,SAAA,GAAY;AAPxB;AAOA;AAKA;AAAuB,KAAX,QAAA,GAAW,SAAA,GAAA,IAAA,GAAmB,IAAnB,GAA0B,MAA1B;;;;AAMX,KAAA,YAAA,GAAe,QAAH,GAAc,OAAd,CAAA,GAAA,CAAA,GAA6B,IAA7B,GAAoC,MAApC;;AAAc,KAG1B,UAAA,GAH0B,CAAA,KAAA,EAAA,GAAA,EAAA,GAAA,OAAA;;;;AAGtC;AAQA;AAAiD;AAIrC,KAJA,OAAA,GAAU,MAIK,CAAA,MAAA,EAJU,UAIkC,CAAA;AAcvE,cAhBc,iBAgBc,EAAA,OAAa,MAAA;AAiB7B,KA/BA,eA+BY,CAAA,KAAA,CAAA,GA/Ba,KA+Bb,UAAA,GAAA,GAAA,KAAA,EAAA,IAAA,CAAA,GA/B+C,KA+B/C;;;;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,KA3BA,IA2BQ,CAAA,IAA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AoB,IAAI,IAAI,WAAW,GAAG,UAAU,GAAG;;;;;;;;;KAU/C,yEAER;;;;KAWC,4BAAA;KAWA,uBAAA,GACD,cACA,WACA,OACA,QACA,SACA,aACA,OACA;KAyBC,6BAAA,YACQ;0BAEiB;0BACA;IAE1B,YAAY,qBAAqB,uBACjC,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAqCJ,mBAAA,GACR,+BACA,0BACA"}
|
package/dist/base-Cpeh4C5c.cjs
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
const e=``,t=`\r
|
|
2
|
-
`,n={},r=`Arguments`,i=`Array`,a=`Object`,o=`Map`,s=`Set`,c=Symbol(`NestedValue`);Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return`Arguments`}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return`Object`}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return`\r
|
|
3
|
-
`}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return`Set`}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return`Array`}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return``}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return`Map`}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return c}});
|
package/dist/base-DmFPRVSE.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base-DmFPRVSE.mjs","names":["$NestedValue: unique symbol"],"sources":["../src/base.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { TypedArray } from \"./array\";\n\nexport type SerializablePrimitive =\n | null\n | undefined\n | string\n | number\n | boolean\n | bigint;\nexport type Primitive = SerializablePrimitive | symbol;\n\n/**\n * Matches any primitive, `void`, `Date`, or `RegExp` value.\n */\nexport type BuiltIns = Primitive | void | Date | RegExp;\n\n/**\n * Matches any non-primitive object\n */\n// eslint-disable-next-line ts/no-unsafe-function-type\nexport type AtomicObject = Function | Promise<any> | Date | RegExp;\n\n/** Determines if the passed value is of a specific type */\nexport type TypeTester = (value: any) => boolean;\n\n/**\n * The interface for a type mapping (key =\\> function) to use for {@link getType}.\n * export * The key represents the name of the type. The function represents the {@link TypeTester | test method}.\n * The map should be ordered by testing preference, with more specific tests first.\n * If a test returns true, it is selected, and the key is returned as the type.\n */\nexport type TypeMap = Record<string, TypeTester>;\n\ndeclare const emptyObjectSymbol: unique symbol;\n\nexport type FunctionOrValue<Value> = Value extends () => infer X ? X : Value;\n\n/**\n * A [[List]]\n *\n * @example\n * ```ts\n * type list0 = [1, 2, 3]\n * type list1 = number[]\n * ```\n *\n * @param A - its type\n * @returns [[List]]\n */\nexport type List<A = any> = ReadonlyArray<A>;\n\n/**\n * Alias to create a [[Function]]\n *\n * @example\n * ```ts\n * import { FunctionLike } from '@stryke/types'\n *\n * type test0 = FunctionLike<[string, number], boolean>\n * /// (args_0: string, args_1: number) => boolean\n * ```\n *\n * @param P - parameters\n * @param R - return type\n * @returns [[Function]]\n */\nexport type FunctionLike<P extends List = any, R = any> = (...args: P) => R;\n\nexport type AnyFunction = FunctionLike<any, any>;\nexport type Nullish = undefined | null;\nexport type Nullishable<T> = T | Nullish;\nexport type NonNullishObject = object; // not null/undefined which are Object\nexport type NativeClass = abstract new (...args: any) => any;\nexport type AnyNumber = number | number;\nexport type AnyString = string | string;\nexport type AnyBoolean = boolean | boolean;\nexport type AnyArray = any[];\nexport type PlainObject = Record<any, object>; // https://stackoverflow.com/a/75052315/130638\nexport type AnyMap = Map<any, any>;\nexport type AnyWeakMap = WeakMap<WeakKey, any>;\nexport type EmptyArray = [];\nexport interface EmptyObject {\n [emptyObjectSymbol]?: never;\n}\n\nexport type Any =\n | boolean\n | number\n | bigint\n | string\n | null\n | undefined\n | void\n | symbol\n | object\n | PlainObject\n | AnyArray\n | AnyMap\n | AnyWeakMap;\n\n/**\n * The valid types of the index for an `Indexable` type object\n */\nexport type IndexType = string | number | symbol;\n\n/**\n * The declaration of a ***dictionary-type*** object with a specific type\n *\n * @see {@link Indexable}\n * @see {@link IndexType}\n * @see {@link Dictionary}\n */\nexport type TypedIndexable<T> = Record<IndexType, T>;\n\n/**\n * The declaration of a ***dictionary-type*** object\n *\n * @see {@link TypedIndexable}\n * @see {@link IndexType}\n * @see {@link Dictionary}\n */\nexport type Indexable = TypedIndexable<any>;\n\n/**\n * The declaration of a ***dictionary-type*** object with a specific type\n *\n * @see {@link Indexable}\n * @see {@link IndexType}\n * @see {@link TypedIndexable}\n */\nexport type Dictionary<T> = Record<string, T>;\n\nexport const EMPTY_STRING = \"\";\nexport const NEWLINE_STRING = \"\\r\\n\";\nexport const EMPTY_OBJECT = {};\n\nexport type AnyCase<T extends IndexType> = string extends T\n ? string\n : T extends `${infer F1}${infer F2}${infer R}`\n ? `${Uppercase<F1> | Lowercase<F1>}${Uppercase<F2> | Lowercase<F2>}${AnyCase<R>}`\n : T extends `${infer F}${infer R}`\n ? `${Uppercase<F> | Lowercase<F>}${AnyCase<R>}`\n : typeof EMPTY_STRING;\n\nexport type Newable<T> = new (..._args: never[]) => T;\n\nexport interface Abstract<T> {\n prototype: T;\n}\n\nexport interface Clonable<T> {\n clone: () => T;\n}\n\nexport type MaybePromise<T> = T | Promise<T>;\n\nexport type ReducerFunction<TState, TAction> = (\n state: TState,\n action: TAction\n) => TState;\n\n// NOTE: for the file size optimization\nexport const TYPE_ARGUMENTS = \"Arguments\";\nexport const TYPE_ARRAY = \"Array\";\nexport const TYPE_OBJECT = \"Object\";\nexport const TYPE_MAP = \"Map\";\nexport const TYPE_SET = \"Set\";\n\nexport type Collection =\n | IArguments\n | unknown[]\n | Map<unknown, unknown>\n | Record<string | number | symbol, unknown>\n | Set<unknown>;\n\nexport type NonUndefined<T> = T extends undefined ? never : T;\n\nexport type BrowserNativeObject = Date | File;\n\nexport type DeepPartial<T> = T extends BrowserNativeObject | NestedValue\n ? T\n : {\n [K in keyof T]?: DeepPartial<T[K]>;\n };\n\nexport type Rollback = Record<\n string,\n (initialValue: any, currentValue: any) => any\n>;\n\n/**\n * Extract all required keys from the given type.\n *\n * @remarks\n * This is useful when you want to create a new type that contains different type values for the required keys only or use the list of keys for validation purposes, etc...\n */\nexport type RequiredKeysOf<BaseType extends object> = Exclude<\n {\n [Key in keyof BaseType]: BaseType extends Record<Key, BaseType[Key]>\n ? Key\n : never;\n }[keyof BaseType],\n undefined\n>;\n\n/**\n * Returns a boolean for whether the two given types are equal.\n *\n * @remarks\n * Use-cases: If you want to make a conditional branch based on the result of a comparison of two types.\n *\n * @see https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650\n * @see https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796\n */\nexport type IsEqual<A, B> =\n (<G>() => G extends A ? 1 : 2) extends <G>() => G extends B ? 1 : 2\n ? true\n : false;\n\nexport type Filter<KeyType, ExcludeType> =\n IsEqual<KeyType, ExcludeType> extends true\n ? never\n : KeyType extends ExcludeType\n ? never\n : KeyType;\n\ninterface ExceptOptions {\n /**\n Disallow assigning non-specified properties.\n\n Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.\n\n @defaultValue false\n */\n requireExactProps?: boolean;\n}\n\n/**\n * Create a type from an object type without certain keys.\n *\n * @remarks\n * We recommend setting the `requireExactProps` option to `true`.\n *\n * This type is a stricter version of [`Omit`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-5.html#the-omit-helper-type). The `Omit` type does not restrict the omitted keys to be keys present on the given type, while `Except` does. The benefits of a stricter type are avoiding typos and allowing the compiler to pick up on rename refactors automatically.\n *\n * This type was proposed to the TypeScript team, which declined it, saying they prefer that libraries implement stricter versions of the built-in types ([microsoft/TypeScript#30825](https://github.com/microsoft/TypeScript/issues/30825#issuecomment-523668235)).\n */\nexport type Except<\n ObjectType,\n KeysType extends keyof ObjectType,\n Options extends ExceptOptions = { requireExactProps: false }\n> = {\n [KeyType in keyof ObjectType as Filter<\n KeyType,\n KeysType\n >]: ObjectType[KeyType];\n} & (Options[\"requireExactProps\"] extends true\n ? Partial<Record<KeysType, never>>\n : Record<string, never>);\n\n/**\n * Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.\n *\n * @remarks\n * Sometimes it is desired to pass a value as a function argument that has a different type. At first inspection it may seem assignable, and then you discover it is not because the `value`'s type definition was defined as an interface. In the following example, `fn` requires an argument of type `Record<string, unknown>`. If the value is defined as a literal, then it is assignable. And if the `value` is defined as type using the `Simplify` utility the value is assignable. But if the `value` is defined as an interface, it is not assignable because the interface is not sealed and elsewhere a non-string property could be added to the interface.\n *\n * If the type definition must be an interface (perhaps it was defined in a third-party npm package), then the `value` can be defined as `const value: Simplify<SomeInterface> = ...`. Then `value` will be assignable to the `fn` argument. Or the `value` can be cast as `Simplify<SomeInterface>` if you can't re-declare the `value`.\n *\n * @see https://github.com/microsoft/TypeScript/issues/15300\n */\nexport type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};\n\n/**\n * Create a type that makes the given keys required. The remaining keys are kept as is. The sister of the `SetOptional` type.\n *\n * @remarks\n * Use-case: You want to define a single model where the only thing that changes is whether or not some of the keys are required.\n */\nexport type SetRequired<\n BaseType,\n Keys extends keyof BaseType\n> = BaseType extends unknown // type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types). // union into a [distributive conditional // `extends unknown` is always going to be the case and is used to convert any\n ? Simplify<\n // Pick just the keys that are optional from the base type.\n Except<BaseType, Keys> &\n // Pick the keys that should be required from the base type and make them required.\n Required<Pick<BaseType, Keys>>\n >\n : never;\n\nexport const $NestedValue: unique symbol = Symbol(\"NestedValue\");\n\nexport type NestedValue<TValue extends object = object> = {\n [$NestedValue]: never;\n} & TValue;\n\nexport interface RefObject<T> {\n current: T;\n}\n\nexport interface Identity<T = string> {\n id: T;\n}\n\nexport interface Versioned {\n version: number;\n}\n\nexport interface Sequenced {\n /**\n * The sequence number (version, or event counter, etc.) of the record\n */\n sequence: number;\n}\n\nexport interface Typed {\n /**\n * The type of the record\n */\n __type: string;\n}\n\nexport interface ClassTypeCheckable<T> extends Typed {\n /**\n * Run type check on the given value\n * @param value - The value to check\n * @returns True if the value is of the type of the class\n */\n isTypeOf: (value: unknown) => value is T;\n}\n\n/**\n * Matches non-recursive types.\n */\nexport type NonRecursiveType =\n | BuiltIns\n // eslint-disable-next-line ts/no-unsafe-function-type\n | Function\n | (new (...arguments_: any[]) => unknown);\n\nexport type IsPrimitive<T> = [T] extends [Primitive] ? true : false;\nexport type IsNever<T> = [T] extends [never] ? true : false;\nexport type IsAny<T> = 0 extends 1 & T ? true : false;\nexport type IsNull<T> = [T] extends [null] ? true : false;\nexport type IsUndefined<T> = T extends undefined ? true : false;\nexport type IsUnknown<T> = unknown extends T // `T` can be `unknown` or `any`\n ? IsNull<T> extends false // `any` can be `null`, but `unknown` can't be\n ? true\n : false\n : false;\nexport type IsNullish<T> = IsNull<T> & IsUndefined<T>;\nexport type IsFunction<T> = T extends AnyFunction ? true : false;\n\n/**\n * Declare locally scoped properties on `globalThis`.\n *\n * When defining a global variable in a declaration file is inappropriate, it can be helpful to define a `type` or `interface` (say `ExtraGlobals`) with the global variable and then cast `globalThis` via code like `globalThis as unknown as ExtraGlobals`.\n *\n * Instead of casting through `unknown`, you can update your `type` or `interface` to extend `GlobalThis` and then directly cast `globalThis`.\n *\n * @example\n * ```\n * import type { GlobalThis } from '@stryke/types';\n *\n * type ExtraGlobals = GlobalThis & {\n * readonly GLOBAL_TOKEN: string;\n * };\n *\n * (globalThis as ExtraGlobals).GLOBAL_TOKEN;\n * ```\n */\nexport type GlobalThis = typeof globalThis;\n\n/**\n * Matches a [`class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).\n */\nexport interface Class<T, Arguments extends unknown[] = any[]> {\n prototype: Pick<T, keyof T>;\n new (...arguments_: Arguments): T;\n}\n\n/**\n * Matches a [`class` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).\n */\nexport type Constructor<T, Arguments extends unknown[] = any[]> = new (\n ...arguments_: Arguments\n) => T;\n\n/**\n * Matches an [`abstract class`](https://www.typescriptlang.org/docs/handbook/classes.html#abstract-classes).\n *\n * @privateRemarks\n * We cannot use a `type` here because TypeScript throws: 'abstract' modifier cannot appear on a type member. (1070)\n */\n\nexport interface AbstractClass<\n T,\n Arguments extends unknown[] = any[]\n> extends AbstractConstructor<T, Arguments> {\n prototype: Pick<T, keyof T>;\n}\n\n/**\n * Matches an [`abstract class`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-2.html#abstract-construct-signatures) constructor.\n */\nexport type AbstractConstructor<\n T,\n Arguments extends unknown[] = any[]\n> = abstract new (...arguments_: Arguments) => T;\n\n/**\n * Create a tuple type of the given length `<L>` and fill it with the given type `<Fill>`.\n *\n * If `<Fill>` is not provided, it will default to `unknown`.\n *\n * @see https://itnext.io/implementing-arithmetic-within-typescripts-type-system-a1ef140a6f6f\n */\nexport type BuildTuple<\n L extends number,\n Fill = unknown,\n T extends readonly unknown[] = []\n> = T[\"length\"] extends L ? T : BuildTuple<L, Fill, [...T, Fill]>;\n\n/**\n * Test if the given function has multiple call signatures.\n *\n * Needed to handle the case of a single call signature with properties.\n *\n * Multiple call signatures cannot currently be supported due to a TypeScript limitation.\n * @see https://github.com/microsoft/TypeScript/issues/29732\n */\nexport type HasMultipleCallSignatures<\n T extends (...arguments_: any[]) => unknown\n> = T extends {\n (...arguments_: infer A): unknown;\n (...arguments_: infer B): unknown;\n}\n ? B extends A\n ? A extends B\n ? false\n : true\n : true\n : false;\n\ntype StructuredCloneablePrimitive =\n | string\n | number\n | bigint\n | boolean\n | null\n | undefined\n | boolean\n | number\n | string;\n\ntype StructuredCloneableData =\n | ArrayBuffer\n | DataView\n | Date\n | Error\n | RegExp\n | TypedArray\n | Blob\n | File;\n\n// DOM exclusive types\n// | AudioData\n// | CropTarget\n// | CryptoKey\n// | DOMException\n// | DOMMatrix\n// | DOMMatrixReadOnly\n// | DOMPoint\n// | DOMPointReadOnly\n// | DOMQuad\n// | DOMRect\n// | DOMRectReadOnly\n// | FileList\n// | FileSystemDirectoryHandle\n// | FileSystemFileHandle\n// | FileSystemHandle\n// | GPUCompilationInfo\n// | GPUCompilationMessage\n// | ImageBitmap\n// | ImageData\n// | RTCCertificate\n// | VideoFrame\n\ntype StructuredCloneableCollection =\n | readonly StructuredCloneable[]\n | {\n readonly [key: string]: StructuredCloneable;\n readonly [key: number]: StructuredCloneable;\n }\n | ReadonlyMap<StructuredCloneable, StructuredCloneable>\n | ReadonlySet<StructuredCloneable>;\n\n/**\n * Matches a value that can be losslessly cloned using `structuredClone`.\n *\n * Note:\n * - Custom error types will be cloned as the base `Error` type\n * - This type doesn't include types exclusive to the TypeScript DOM library (e.g. `DOMRect` and `VideoFrame`)\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm\n *\n * @example\n * ```\n * import type { StructuredCloneable } from '@stryke/types';\n *\n * class CustomClass {}\n *\n * // @ts-expect-error\n * const error: StructuredCloneable = {\n * custom: new CustomClass(),\n * };\n *\n * structuredClone(error);\n * //=> {custom: {}}\n *\n * const good: StructuredCloneable = {\n * number: 3,\n * date: new Date(),\n * map: new Map<string, number>(),\n * }\n *\n * good.map.set('key', 1);\n *\n * structuredClone(good);\n * //=> {number: 3, date: Date(2022-10-17 22:22:35.920), map: Map {'key' -> 1}}\n * ```\n */\nexport type StructuredCloneable =\n | StructuredCloneablePrimitive\n | StructuredCloneableData\n | StructuredCloneableCollection;\n"],"mappings":"AAsJA,MAAa,EAAe,GACf,EAAiB;EACjB,EAAe,EAAE,CA4BjB,EAAiB,YACjB,EAAa,QACb,EAAc,SACd,EAAW,MACX,EAAW,MA4HXA,EAA8B,OAAO,cAAc"}
|