@stryke/types 0.5.1 → 0.6.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 +16 -14
- package/dist/{utility-types/array.d.ts → array.d.ts} +0 -12
- package/dist/{utility-types/async.d.ts → async.d.ts} +1 -11
- package/dist/{utility-types/base.d.ts → base.d.ts} +23 -31
- package/dist/index.cjs +181 -16
- package/dist/index.d.ts +19 -4
- package/dist/index.mjs +1 -1
- package/dist/{utility-types/json.d.ts → json.d.ts} +0 -10
- package/dist/{utility-types/number.d.ts → number.d.ts} +0 -22
- package/dist/{utility-types/object.d.ts → object.d.ts} +1 -15
- package/dist/{utility-types/package-json.d.ts → package-json.d.ts} +3 -5
- package/dist/{utility-types/string.d.ts → string.d.ts} +0 -12
- package/dist/{utility-types/tsconfig.d.ts → tsconfig.d.ts} +0 -2
- package/dist/{utility-types/utilities.d.ts → utilities.d.ts} +1 -1
- package/dist/validations.cjs +1 -0
- package/dist/validations.mjs +0 -0
- package/package.json +125 -987
- package/dist/convert/buffer-to-string.cjs +0 -8
- package/dist/convert/buffer-to-string.d.ts +0 -1
- package/dist/convert/buffer-to-string.mjs +0 -1
- package/dist/convert/index.cjs +0 -71
- package/dist/convert/index.d.ts +0 -6
- package/dist/convert/index.mjs +0 -1
- package/dist/convert/string-to-uint8-array.cjs +0 -8
- package/dist/convert/string-to-uint8-array.d.ts +0 -7
- package/dist/convert/string-to-uint8-array.mjs +0 -1
- package/dist/convert/to-array.cjs +0 -9
- package/dist/convert/to-array.d.ts +0 -8
- package/dist/convert/to-array.mjs +0 -1
- package/dist/convert/to-string-key.cjs +0 -9
- package/dist/convert/to-string-key.d.ts +0 -7
- package/dist/convert/to-string-key.mjs +0 -1
- package/dist/convert/uint8-array-to-string.cjs +0 -8
- package/dist/convert/uint8-array-to-string.d.ts +0 -13
- package/dist/convert/uint8-array-to-string.mjs +0 -1
- package/dist/convert/utf8-array-to-string.cjs +0 -8
- package/dist/convert/utf8-array-to-string.d.ts +0 -13
- package/dist/convert/utf8-array-to-string.mjs +0 -1
- package/dist/helpers/index.cjs +0 -16
- package/dist/helpers/index.d.ts +0 -1
- package/dist/helpers/index.mjs +0 -1
- package/dist/helpers/parse-type-definition.cjs +0 -33
- package/dist/helpers/parse-type-definition.d.ts +0 -8
- package/dist/helpers/parse-type-definition.mjs +0 -1
- package/dist/type-checks/get-object-tag.cjs +0 -8
- package/dist/type-checks/get-object-tag.d.ts +0 -7
- package/dist/type-checks/get-object-tag.mjs +0 -1
- package/dist/type-checks/index.cjs +0 -456
- package/dist/type-checks/index.d.ts +0 -41
- package/dist/type-checks/index.mjs +0 -1
- package/dist/type-checks/is-array-like.cjs +0 -11
- package/dist/type-checks/is-array-like.d.ts +0 -7
- package/dist/type-checks/is-array-like.mjs +0 -1
- package/dist/type-checks/is-async-iterable.cjs +0 -10
- package/dist/type-checks/is-async-iterable.d.ts +0 -7
- package/dist/type-checks/is-async-iterable.mjs +0 -1
- package/dist/type-checks/is-bigint.cjs +0 -9
- package/dist/type-checks/is-bigint.d.ts +0 -16
- package/dist/type-checks/is-bigint.mjs +0 -1
- package/dist/type-checks/is-boolean.cjs +0 -14
- package/dist/type-checks/is-boolean.d.ts +0 -7
- package/dist/type-checks/is-boolean.mjs +0 -1
- package/dist/type-checks/is-buffer.cjs +0 -10
- package/dist/type-checks/is-buffer.d.ts +0 -5
- package/dist/type-checks/is-buffer.mjs +0 -1
- package/dist/type-checks/is-collection.cjs +0 -11
- package/dist/type-checks/is-collection.d.ts +0 -8
- package/dist/type-checks/is-collection.mjs +0 -1
- package/dist/type-checks/is-date.cjs +0 -10
- package/dist/type-checks/is-date.d.ts +0 -16
- package/dist/type-checks/is-date.mjs +0 -1
- package/dist/type-checks/is-deep-key.cjs +0 -26
- package/dist/type-checks/is-deep-key.d.ts +0 -35
- package/dist/type-checks/is-deep-key.mjs +0 -1
- package/dist/type-checks/is-empty-object.cjs +0 -23
- package/dist/type-checks/is-empty-object.d.ts +0 -14
- package/dist/type-checks/is-empty-object.mjs +0 -1
- package/dist/type-checks/is-empty-string.cjs +0 -16
- package/dist/type-checks/is-empty-string.d.ts +0 -7
- package/dist/type-checks/is-empty-string.mjs +0 -1
- package/dist/type-checks/is-empty.cjs +0 -35
- package/dist/type-checks/is-empty.d.ts +0 -8
- package/dist/type-checks/is-empty.mjs +0 -1
- package/dist/type-checks/is-equal.cjs +0 -18
- package/dist/type-checks/is-equal.d.ts +0 -1
- package/dist/type-checks/is-equal.mjs +0 -1
- package/dist/type-checks/is-error.cjs +0 -15
- package/dist/type-checks/is-error.d.ts +0 -17
- package/dist/type-checks/is-error.mjs +0 -1
- package/dist/type-checks/is-file-result.cjs +0 -11
- package/dist/type-checks/is-file-result.d.ts +0 -8
- package/dist/type-checks/is-file-result.mjs +0 -1
- package/dist/type-checks/is-float.cjs +0 -9
- package/dist/type-checks/is-float.d.ts +0 -8
- package/dist/type-checks/is-float.mjs +0 -1
- package/dist/type-checks/is-function.cjs +0 -23
- package/dist/type-checks/is-function.d.ts +0 -10
- package/dist/type-checks/is-function.mjs +0 -1
- package/dist/type-checks/is-integer.cjs +0 -10
- package/dist/type-checks/is-integer.d.ts +0 -8
- package/dist/type-checks/is-integer.mjs +0 -1
- package/dist/type-checks/is-mergeable-object.cjs +0 -14
- package/dist/type-checks/is-mergeable-object.d.ts +0 -1
- package/dist/type-checks/is-mergeable-object.mjs +0 -1
- package/dist/type-checks/is-non-null-object.cjs +0 -10
- package/dist/type-checks/is-non-null-object.d.ts +0 -7
- package/dist/type-checks/is-non-null-object.mjs +0 -1
- package/dist/type-checks/is-not-empty.cjs +0 -17
- package/dist/type-checks/is-not-empty.d.ts +0 -7
- package/dist/type-checks/is-not-empty.mjs +0 -1
- package/dist/type-checks/is-null.cjs +0 -14
- package/dist/type-checks/is-null.d.ts +0 -1
- package/dist/type-checks/is-null.mjs +0 -1
- package/dist/type-checks/is-number.cjs +0 -19
- package/dist/type-checks/is-number.d.ts +0 -15
- package/dist/type-checks/is-number.mjs +0 -1
- package/dist/type-checks/is-object-index.cjs +0 -17
- package/dist/type-checks/is-object-index.d.ts +0 -7
- package/dist/type-checks/is-object-index.mjs +0 -1
- package/dist/type-checks/is-object.cjs +0 -30
- package/dist/type-checks/is-object.d.ts +0 -30
- package/dist/type-checks/is-object.mjs +0 -1
- package/dist/type-checks/is-plain-object.cjs +0 -17
- package/dist/type-checks/is-plain-object.d.ts +0 -50
- package/dist/type-checks/is-plain-object.mjs +0 -1
- package/dist/type-checks/is-primitive.cjs +0 -14
- package/dist/type-checks/is-primitive.d.ts +0 -1
- package/dist/type-checks/is-primitive.mjs +0 -1
- package/dist/type-checks/is-promise.cjs +0 -12
- package/dist/type-checks/is-promise.d.ts +0 -17
- package/dist/type-checks/is-promise.mjs +0 -1
- package/dist/type-checks/is-react-element.cjs +0 -8
- package/dist/type-checks/is-react-element.d.ts +0 -1
- package/dist/type-checks/is-react-element.mjs +0 -1
- package/dist/type-checks/is-ref.cjs +0 -14
- package/dist/type-checks/is-ref.d.ts +0 -8
- package/dist/type-checks/is-ref.mjs +0 -1
- package/dist/type-checks/is-regexp.cjs +0 -10
- package/dist/type-checks/is-regexp.d.ts +0 -16
- package/dist/type-checks/is-regexp.mjs +0 -1
- package/dist/type-checks/is-select-option.cjs +0 -15
- package/dist/type-checks/is-select-option.d.ts +0 -8
- package/dist/type-checks/is-select-option.mjs +0 -1
- package/dist/type-checks/is-set-object.cjs +0 -15
- package/dist/type-checks/is-set-object.d.ts +0 -7
- package/dist/type-checks/is-set-object.mjs +0 -1
- package/dist/type-checks/is-set-string.cjs +0 -16
- package/dist/type-checks/is-set-string.d.ts +0 -7
- package/dist/type-checks/is-set-string.mjs +0 -1
- package/dist/type-checks/is-set.cjs +0 -15
- package/dist/type-checks/is-set.d.ts +0 -7
- package/dist/type-checks/is-set.mjs +0 -1
- package/dist/type-checks/is-string.cjs +0 -14
- package/dist/type-checks/is-string.d.ts +0 -1
- package/dist/type-checks/is-string.mjs +0 -1
- package/dist/type-checks/is-symbol.cjs +0 -14
- package/dist/type-checks/is-symbol.d.ts +0 -1
- package/dist/type-checks/is-symbol.mjs +0 -1
- package/dist/type-checks/is-typed-array.cjs +0 -9
- package/dist/type-checks/is-typed-array.d.ts +0 -1
- package/dist/type-checks/is-typed-array.mjs +0 -1
- package/dist/type-checks/is-typed.cjs +0 -16
- package/dist/type-checks/is-typed.d.ts +0 -8
- package/dist/type-checks/is-typed.mjs +0 -1
- package/dist/type-checks/is-undefined.cjs +0 -8
- package/dist/type-checks/is-undefined.d.ts +0 -1
- package/dist/type-checks/is-undefined.mjs +0 -1
- package/dist/type-checks/property-exists.cjs +0 -17
- package/dist/type-checks/property-exists.d.ts +0 -16
- package/dist/type-checks/property-exists.mjs +0 -1
- package/dist/type-checks/type-detect.cjs +0 -38
- package/dist/type-checks/type-detect.d.ts +0 -1
- package/dist/type-checks/type-detect.mjs +0 -1
- package/dist/utility-types/array.cjs +0 -9
- package/dist/utility-types/array.mjs +0 -1
- package/dist/utility-types/index.cjs +0 -214
- package/dist/utility-types/index.d.ts +0 -19
- package/dist/utility-types/index.mjs +0 -1
- /package/dist/{utility-types/async.cjs → array.cjs} +0 -0
- /package/dist/{utility-types/async.mjs → array.mjs} +0 -0
- /package/dist/{utility-types/configuration.cjs → async.cjs} +0 -0
- /package/dist/{utility-types/configuration.mjs → async.mjs} +0 -0
- /package/dist/{utility-types/base.cjs → base.cjs} +0 -0
- /package/dist/{utility-types/base.mjs → base.mjs} +0 -0
- /package/dist/{utility-types/form.cjs → configuration.cjs} +0 -0
- /package/dist/{utility-types/configuration.d.ts → configuration.d.ts} +0 -0
- /package/dist/{utility-types/form.mjs → configuration.mjs} +0 -0
- /package/dist/{utility-types/file.cjs → file.cjs} +0 -0
- /package/dist/{utility-types/file.d.ts → file.d.ts} +0 -0
- /package/dist/{utility-types/file.mjs → file.mjs} +0 -0
- /package/dist/{utility-types/json.cjs → form.cjs} +0 -0
- /package/dist/{utility-types/form.d.ts → form.d.ts} +0 -0
- /package/dist/{utility-types/json.mjs → form.mjs} +0 -0
- /package/dist/{utility-types/logic.cjs → json.cjs} +0 -0
- /package/dist/{utility-types/logic.mjs → json.mjs} +0 -0
- /package/dist/{utility-types/navigator.cjs → logic.cjs} +0 -0
- /package/dist/{utility-types/logic.d.ts → logic.d.ts} +0 -0
- /package/dist/{utility-types/navigator.mjs → logic.mjs} +0 -0
- /package/dist/{utility-types/messages.cjs → messages.cjs} +0 -0
- /package/dist/{utility-types/messages.d.ts → messages.d.ts} +0 -0
- /package/dist/{utility-types/messages.mjs → messages.mjs} +0 -0
- /package/dist/{utility-types/number.cjs → navigator.cjs} +0 -0
- /package/dist/{utility-types/navigator.d.ts → navigator.d.ts} +0 -0
- /package/dist/{utility-types/number.mjs → navigator.mjs} +0 -0
- /package/dist/{utility-types/object.cjs → number.cjs} +0 -0
- /package/dist/{utility-types/object.mjs → number.mjs} +0 -0
- /package/dist/{utility-types/package-json.cjs → object.cjs} +0 -0
- /package/dist/{utility-types/package-json.mjs → object.mjs} +0 -0
- /package/dist/{utility-types/string.cjs → package-json.cjs} +0 -0
- /package/dist/{utility-types/string.mjs → package-json.mjs} +0 -0
- /package/dist/{utility-types/package-manager.cjs → package-manager.cjs} +0 -0
- /package/dist/{utility-types/package-manager.d.ts → package-manager.d.ts} +0 -0
- /package/dist/{utility-types/package-manager.mjs → package-manager.mjs} +0 -0
- /package/dist/{utility-types/system.cjs → string.cjs} +0 -0
- /package/dist/{utility-types/system.mjs → string.mjs} +0 -0
- /package/dist/{utility-types/tsconfig.cjs → system.cjs} +0 -0
- /package/dist/{utility-types/system.d.ts → system.d.ts} +0 -0
- /package/dist/{utility-types/tsconfig.mjs → system.mjs} +0 -0
- /package/dist/{utility-types/utilities.cjs → tsconfig.cjs} +0 -0
- /package/dist/{utility-types/utilities.mjs → tsconfig.mjs} +0 -0
- /package/dist/{utility-types/user.cjs → user.cjs} +0 -0
- /package/dist/{utility-types/user.d.ts → user.d.ts} +0 -0
- /package/dist/{utility-types/user.mjs → user.mjs} +0 -0
- /package/dist/{utility-types/validations.cjs → utilities.cjs} +0 -0
- /package/dist/{utility-types/validations.mjs → utilities.mjs} +0 -0
- /package/dist/{utility-types/validations.d.ts → validations.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -44,7 +44,7 @@ This package is part of Storm Software's **🌩️ Stryke** monorepo. Stryke pac
|
|
|
44
44
|
|
|
45
45
|
<!-- END header -->
|
|
46
46
|
|
|
47
|
-
# Stryke -
|
|
47
|
+
# Stryke - Shared Types
|
|
48
48
|
|
|
49
49
|
A package containing many base TypeScript type definitions that are shared
|
|
50
50
|
across many projects.
|
|
@@ -54,19 +54,21 @@ across many projects.
|
|
|
54
54
|
|
|
55
55
|
## Table of Contents
|
|
56
56
|
|
|
57
|
-
- [
|
|
58
|
-
- [
|
|
59
|
-
- [
|
|
60
|
-
- [
|
|
61
|
-
- [
|
|
62
|
-
|
|
63
|
-
- [
|
|
64
|
-
- [
|
|
65
|
-
- [
|
|
66
|
-
- [
|
|
67
|
-
- [
|
|
68
|
-
- [
|
|
69
|
-
- [
|
|
57
|
+
- [Stryke - Shared Types](#stryke---shared-types)
|
|
58
|
+
- [Table of Contents](#table-of-contents)
|
|
59
|
+
- [Installing](#installing)
|
|
60
|
+
- [Reduced Package Size](#reduced-package-size)
|
|
61
|
+
- [Development](#development)
|
|
62
|
+
- [Building](#building)
|
|
63
|
+
- [Running unit tests](#running-unit-tests)
|
|
64
|
+
- [Linting](#linting)
|
|
65
|
+
- [Storm Workspaces](#storm-workspaces)
|
|
66
|
+
- [Roadmap](#roadmap)
|
|
67
|
+
- [Support](#support)
|
|
68
|
+
- [License](#license)
|
|
69
|
+
- [Changelog](#changelog)
|
|
70
|
+
- [Contributing](#contributing)
|
|
71
|
+
- [Contributors](#contributors)
|
|
70
72
|
|
|
71
73
|
<!-- END doctoc -->
|
|
72
74
|
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Matches any array or array-like object.
|
|
3
|
-
*
|
|
4
|
-
* @category Array
|
|
5
3
|
*/
|
|
6
4
|
export type Arrayable<T> = T | T[];
|
|
7
5
|
export type UnknownArray = readonly unknown[];
|
|
8
6
|
/**
|
|
9
7
|
* Matches any [typed array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray), like `Uint8Array` or `Float64Array`.
|
|
10
|
-
*
|
|
11
|
-
* @category Array
|
|
12
8
|
*/
|
|
13
9
|
export type TypedArray = BigInt64Array | BigUint64Array | Float32Array | Float64Array | Int8Array | Int16Array | Int32Array | Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array;
|
|
14
10
|
/**
|
|
@@ -45,8 +41,6 @@ export type ArrayElement<T> = T extends readonly unknown[] ? T[0] : never;
|
|
|
45
41
|
* ```
|
|
46
42
|
*
|
|
47
43
|
* @see {@link ArrayIndices}
|
|
48
|
-
*
|
|
49
|
-
* @category Array
|
|
50
44
|
*/
|
|
51
45
|
export type ArrayValues<T extends readonly unknown[]> = T[number];
|
|
52
46
|
/**
|
|
@@ -67,8 +61,6 @@ export type ArrayValues<T extends readonly unknown[]> = T[number];
|
|
|
67
61
|
* ```
|
|
68
62
|
*
|
|
69
63
|
* @see {@link ArrayValues}
|
|
70
|
-
*
|
|
71
|
-
* @category Array
|
|
72
64
|
*/
|
|
73
65
|
export type ArrayIndices<Element extends readonly unknown[]> = Exclude<Partial<Element>["length"], Element["length"]>;
|
|
74
66
|
/**
|
|
@@ -100,9 +92,6 @@ export type FirstArrayElement<TArray extends UnknownArrayOrTuple> = TArray exten
|
|
|
100
92
|
* typeof lastOf(array);
|
|
101
93
|
* //=> 2
|
|
102
94
|
* ```
|
|
103
|
-
*
|
|
104
|
-
* @category Array
|
|
105
|
-
* @category Template literal
|
|
106
95
|
*/
|
|
107
96
|
export type LastArrayElement<Elements extends readonly unknown[], ElementBeforeTailingSpreadElement = never> = Elements extends readonly [] ? ElementBeforeTailingSpreadElement : Elements extends readonly [...infer _U, infer V] ? V : Elements extends readonly [infer U, ...infer V] ? LastArrayElement<V, U> : Elements extends readonly (infer U)[] ? ElementBeforeTailingSpreadElement | U : never;
|
|
108
97
|
/**
|
|
@@ -127,4 +116,3 @@ export type StaticPartOfArray<T extends UnknownArray, Result extends UnknownArra
|
|
|
127
116
|
* ```
|
|
128
117
|
*/
|
|
129
118
|
export type VariablePartOfArray<T extends UnknownArray> = T extends unknown ? T extends readonly [...StaticPartOfArray<T>, ...infer U] ? U : [] : never;
|
|
130
|
-
export declare const filterEmpty: <T>(values?: (T | null | undefined)[]) => T[];
|
|
@@ -8,8 +8,6 @@ import type { FunctionLike, IsUnknown } from "./base";
|
|
|
8
8
|
*
|
|
9
9
|
* const value: Awaited<Promise<string>> = 'foo';
|
|
10
10
|
* ```
|
|
11
|
-
*
|
|
12
|
-
* @category Async
|
|
13
11
|
*/
|
|
14
12
|
export type Awaitable<T> = T | PromiseLike<T>;
|
|
15
13
|
/**
|
|
@@ -26,8 +24,6 @@ export type Awaitable<T> = T | PromiseLike<T>;
|
|
|
26
24
|
* type MyWrappedFunction = SetReturnType<MyFunctionThatCanThrow, SomeOtherType | undefined>;
|
|
27
25
|
* //=> type MyWrappedFunction = (foo: SomeType, bar: unknown) => SomeOtherType | undefined;
|
|
28
26
|
* ```
|
|
29
|
-
*
|
|
30
|
-
* @category Function
|
|
31
27
|
*/
|
|
32
28
|
export type SetReturnType<Function_ extends (...arguments_: any[]) => any, TypeToReturn> = Function_ extends (this: infer ThisArgument, ...arguments_: infer Arguments) => any ? IsUnknown<ThisArgument> extends true ? (...arguments_: Arguments) => TypeToReturn : (this: ThisArgument, ...arguments_: Arguments) => TypeToReturn : (...arguments_: Parameters<Function_>) => TypeToReturn;
|
|
33
29
|
export type AsyncFunction = (...arguments_: any[]) => Promise<unknown>;
|
|
@@ -48,8 +44,6 @@ export type AsyncFunction = (...arguments_: any[]) => Promise<unknown>;
|
|
|
48
44
|
*
|
|
49
45
|
* asyncFunction().then(value => doSomething(value));
|
|
50
46
|
* ```
|
|
51
|
-
*
|
|
52
|
-
* @category Async
|
|
53
47
|
*/
|
|
54
48
|
export type AsyncReturnType<Target extends AsyncFunction> = Awaited<ReturnType<Target>>;
|
|
55
49
|
/**
|
|
@@ -78,8 +72,6 @@ export type AsyncReturnType<Target extends AsyncFunction> = Awaited<ReturnType<T
|
|
|
78
72
|
* // …
|
|
79
73
|
* }
|
|
80
74
|
* ```
|
|
81
|
-
*
|
|
82
|
-
* @category Async
|
|
83
75
|
*/
|
|
84
76
|
export type Asyncify<Function_ extends FunctionLike> = SetReturnType<Function_, Promise<Awaited<ReturnType<Function_>>>>;
|
|
85
77
|
/**
|
|
@@ -97,7 +89,5 @@ export type Asyncify<Function_ extends FunctionLike> = SetReturnType<Function_,
|
|
|
97
89
|
*
|
|
98
90
|
* @param P - A promise
|
|
99
91
|
* @returns [[Any]]
|
|
100
|
-
*
|
|
101
|
-
* @category Async
|
|
102
92
|
*/
|
|
103
|
-
export type Await<P
|
|
93
|
+
export type Await<P> = P extends Promise<infer A> ? A : P;
|
|
@@ -48,7 +48,7 @@ export type List<A = any> = ReadonlyArray<A>;
|
|
|
48
48
|
* @param R - return type
|
|
49
49
|
* @returns [[Function]]
|
|
50
50
|
*/
|
|
51
|
-
export type FunctionLike<P extends List = any, R
|
|
51
|
+
export type FunctionLike<P extends List = any, R = any> = (...args: P) => R;
|
|
52
52
|
export type AnyFunction = FunctionLike<any, any>;
|
|
53
53
|
export type Nullish = undefined | null;
|
|
54
54
|
export type Nullishable<T> = T | Nullish;
|
|
@@ -102,8 +102,8 @@ export type Rollback = Record<string, (initialValue: any, currentValue: any) =>
|
|
|
102
102
|
/**
|
|
103
103
|
* Extract all required keys from the given type.
|
|
104
104
|
*
|
|
105
|
-
* @remarks
|
|
106
|
-
*
|
|
105
|
+
* @remarks
|
|
106
|
+
* 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...
|
|
107
107
|
*/
|
|
108
108
|
export type RequiredKeysOf<BaseType extends object> = Exclude<{
|
|
109
109
|
[Key in keyof BaseType]: BaseType extends Record<Key, BaseType[Key]> ? Key : never;
|
|
@@ -111,11 +111,11 @@ export type RequiredKeysOf<BaseType extends object> = Exclude<{
|
|
|
111
111
|
/**
|
|
112
112
|
* Returns a boolean for whether the two given types are equal.
|
|
113
113
|
*
|
|
114
|
-
* @remarks
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
* @
|
|
118
|
-
* @
|
|
114
|
+
* @remarks
|
|
115
|
+
* Use-cases: If you want to make a conditional branch based on the result of a comparison of two types.
|
|
116
|
+
*
|
|
117
|
+
* @see https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
118
|
+
* @see https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
119
119
|
*/
|
|
120
120
|
export type IsEqual<A, B> = (<G>() => G extends A ? 1 : 2) extends <G>() => G extends B ? 1 : 2 ? true : false;
|
|
121
121
|
export type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : KeyType extends ExcludeType ? never : KeyType;
|
|
@@ -132,10 +132,12 @@ interface ExceptOptions {
|
|
|
132
132
|
/**
|
|
133
133
|
* Create a type from an object type without certain keys.
|
|
134
134
|
*
|
|
135
|
-
* @remarks
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
135
|
+
* @remarks
|
|
136
|
+
* We recommend setting the `requireExactProps` option to `true`.
|
|
137
|
+
*
|
|
138
|
+
* 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.
|
|
139
|
+
*
|
|
140
|
+
* 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)).
|
|
139
141
|
*/
|
|
140
142
|
export type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {
|
|
141
143
|
requireExactProps: false;
|
|
@@ -145,10 +147,12 @@ export type Except<ObjectType, KeysType extends keyof ObjectType, Options extend
|
|
|
145
147
|
/**
|
|
146
148
|
* 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.
|
|
147
149
|
*
|
|
148
|
-
* @remarks
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
150
|
+
* @remarks
|
|
151
|
+
* 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.
|
|
152
|
+
*
|
|
153
|
+
* 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`.
|
|
154
|
+
*
|
|
155
|
+
* @see https://github.com/microsoft/TypeScript/issues/15300
|
|
152
156
|
*/
|
|
153
157
|
export type Simplify<T> = {
|
|
154
158
|
[KeyType in keyof T]: T[KeyType];
|
|
@@ -156,8 +160,8 @@ export type Simplify<T> = {
|
|
|
156
160
|
/**
|
|
157
161
|
* Create a type that makes the given keys required. The remaining keys are kept as is. The sister of the `SetOptional` type.
|
|
158
162
|
*
|
|
159
|
-
* @remarks
|
|
160
|
-
*
|
|
163
|
+
* @remarks
|
|
164
|
+
* 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.
|
|
161
165
|
*/
|
|
162
166
|
export type SetRequired<BaseType, Keys extends keyof BaseType> = BaseType extends unknown ? Simplify<Except<BaseType, Keys> & Required<Pick<BaseType, Keys>>> : never;
|
|
163
167
|
export declare const $NestedValue: unique symbol;
|
|
@@ -222,14 +226,10 @@ export type IsFunction<T> = T extends AnyFunction ? true : false;
|
|
|
222
226
|
*
|
|
223
227
|
* (globalThis as ExtraGlobals).GLOBAL_TOKEN;
|
|
224
228
|
* ```
|
|
225
|
-
*
|
|
226
|
-
* @category Type
|
|
227
229
|
*/
|
|
228
230
|
export type GlobalThis = typeof globalThis;
|
|
229
231
|
/**
|
|
230
232
|
* Matches a [`class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).
|
|
231
|
-
*
|
|
232
|
-
* @category Class
|
|
233
233
|
*/
|
|
234
234
|
export interface Class<T, Arguments extends unknown[] = any[]> {
|
|
235
235
|
prototype: Pick<T, keyof T>;
|
|
@@ -237,15 +237,11 @@ export interface Class<T, Arguments extends unknown[] = any[]> {
|
|
|
237
237
|
}
|
|
238
238
|
/**
|
|
239
239
|
* Matches a [`class` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).
|
|
240
|
-
*
|
|
241
|
-
* @category Class
|
|
242
240
|
*/
|
|
243
241
|
export type Constructor<T, Arguments extends unknown[] = any[]> = new (...arguments_: Arguments) => T;
|
|
244
242
|
/**
|
|
245
243
|
* Matches an [`abstract class`](https://www.typescriptlang.org/docs/handbook/classes.html#abstract-classes).
|
|
246
244
|
*
|
|
247
|
-
* @category Class
|
|
248
|
-
*
|
|
249
245
|
* @privateRemarks
|
|
250
246
|
* We cannot use a `type` here because TypeScript throws: 'abstract' modifier cannot appear on a type member. (1070)
|
|
251
247
|
*/
|
|
@@ -254,8 +250,6 @@ export interface AbstractClass<T, Arguments extends unknown[] = any[]> extends A
|
|
|
254
250
|
}
|
|
255
251
|
/**
|
|
256
252
|
* Matches an [`abstract class`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-2.html#abstract-construct-signatures) constructor.
|
|
257
|
-
*
|
|
258
|
-
* @category Class
|
|
259
253
|
*/
|
|
260
254
|
export type AbstractConstructor<T, Arguments extends unknown[] = any[]> = abstract new (...arguments_: Arguments) => T;
|
|
261
255
|
/**
|
|
@@ -263,7 +257,7 @@ export type AbstractConstructor<T, Arguments extends unknown[] = any[]> = abstra
|
|
|
263
257
|
*
|
|
264
258
|
* If `<Fill>` is not provided, it will default to `unknown`.
|
|
265
259
|
*
|
|
266
|
-
* @
|
|
260
|
+
* @see https://itnext.io/implementing-arithmetic-within-typescripts-type-system-a1ef140a6f6f
|
|
267
261
|
*/
|
|
268
262
|
export type BuildTuple<L extends number, Fill = unknown, T extends readonly unknown[] = []> = T["length"] extends L ? T : BuildTuple<L, Fill, [...T, Fill]>;
|
|
269
263
|
/**
|
|
@@ -318,8 +312,6 @@ type StructuredCloneableCollection = readonly StructuredCloneable[] | {
|
|
|
318
312
|
* structuredClone(good);
|
|
319
313
|
* //=> {number: 3, date: Date(2022-10-17 22:22:35.920), map: Map {'key' -> 1}}
|
|
320
314
|
* ```
|
|
321
|
-
*
|
|
322
|
-
* @category Structured clone
|
|
323
315
|
*/
|
|
324
316
|
export type StructuredCloneable = StructuredCloneablePrimitive | StructuredCloneableData | StructuredCloneableCollection;
|
|
325
317
|
export {};
|
package/dist/index.cjs
CHANGED
|
@@ -3,47 +3,212 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
var
|
|
7
|
-
Object.keys(
|
|
6
|
+
var _array = require("./array.cjs");
|
|
7
|
+
Object.keys(_array).forEach(function (key) {
|
|
8
8
|
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] ===
|
|
9
|
+
if (key in exports && exports[key] === _array[key]) return;
|
|
10
10
|
Object.defineProperty(exports, key, {
|
|
11
11
|
enumerable: true,
|
|
12
12
|
get: function () {
|
|
13
|
-
return
|
|
13
|
+
return _array[key];
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
16
|
});
|
|
17
|
-
var
|
|
18
|
-
Object.keys(
|
|
17
|
+
var _async = require("./async.cjs");
|
|
18
|
+
Object.keys(_async).forEach(function (key) {
|
|
19
19
|
if (key === "default" || key === "__esModule") return;
|
|
20
|
-
if (key in exports && exports[key] ===
|
|
20
|
+
if (key in exports && exports[key] === _async[key]) return;
|
|
21
21
|
Object.defineProperty(exports, key, {
|
|
22
22
|
enumerable: true,
|
|
23
23
|
get: function () {
|
|
24
|
-
return
|
|
24
|
+
return _async[key];
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
27
|
});
|
|
28
|
-
var
|
|
29
|
-
Object.keys(
|
|
28
|
+
var _base = require("./base.cjs");
|
|
29
|
+
Object.keys(_base).forEach(function (key) {
|
|
30
30
|
if (key === "default" || key === "__esModule") return;
|
|
31
|
-
if (key in exports && exports[key] ===
|
|
31
|
+
if (key in exports && exports[key] === _base[key]) return;
|
|
32
32
|
Object.defineProperty(exports, key, {
|
|
33
33
|
enumerable: true,
|
|
34
34
|
get: function () {
|
|
35
|
-
return
|
|
35
|
+
return _base[key];
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
38
|
});
|
|
39
|
-
var
|
|
40
|
-
Object.keys(
|
|
39
|
+
var _configuration = require("./configuration.cjs");
|
|
40
|
+
Object.keys(_configuration).forEach(function (key) {
|
|
41
41
|
if (key === "default" || key === "__esModule") return;
|
|
42
|
-
if (key in exports && exports[key] ===
|
|
42
|
+
if (key in exports && exports[key] === _configuration[key]) return;
|
|
43
43
|
Object.defineProperty(exports, key, {
|
|
44
44
|
enumerable: true,
|
|
45
45
|
get: function () {
|
|
46
|
-
return
|
|
46
|
+
return _configuration[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
var _file = require("./file.cjs");
|
|
51
|
+
Object.keys(_file).forEach(function (key) {
|
|
52
|
+
if (key === "default" || key === "__esModule") return;
|
|
53
|
+
if (key in exports && exports[key] === _file[key]) return;
|
|
54
|
+
Object.defineProperty(exports, key, {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _file[key];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
var _form = require("./form.cjs");
|
|
62
|
+
Object.keys(_form).forEach(function (key) {
|
|
63
|
+
if (key === "default" || key === "__esModule") return;
|
|
64
|
+
if (key in exports && exports[key] === _form[key]) return;
|
|
65
|
+
Object.defineProperty(exports, key, {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
get: function () {
|
|
68
|
+
return _form[key];
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
var _json = require("./json.cjs");
|
|
73
|
+
Object.keys(_json).forEach(function (key) {
|
|
74
|
+
if (key === "default" || key === "__esModule") return;
|
|
75
|
+
if (key in exports && exports[key] === _json[key]) return;
|
|
76
|
+
Object.defineProperty(exports, key, {
|
|
77
|
+
enumerable: true,
|
|
78
|
+
get: function () {
|
|
79
|
+
return _json[key];
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
var _logic = require("./logic.cjs");
|
|
84
|
+
Object.keys(_logic).forEach(function (key) {
|
|
85
|
+
if (key === "default" || key === "__esModule") return;
|
|
86
|
+
if (key in exports && exports[key] === _logic[key]) return;
|
|
87
|
+
Object.defineProperty(exports, key, {
|
|
88
|
+
enumerable: true,
|
|
89
|
+
get: function () {
|
|
90
|
+
return _logic[key];
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
var _messages = require("./messages.cjs");
|
|
95
|
+
Object.keys(_messages).forEach(function (key) {
|
|
96
|
+
if (key === "default" || key === "__esModule") return;
|
|
97
|
+
if (key in exports && exports[key] === _messages[key]) return;
|
|
98
|
+
Object.defineProperty(exports, key, {
|
|
99
|
+
enumerable: true,
|
|
100
|
+
get: function () {
|
|
101
|
+
return _messages[key];
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
var _navigator = require("./navigator.cjs");
|
|
106
|
+
Object.keys(_navigator).forEach(function (key) {
|
|
107
|
+
if (key === "default" || key === "__esModule") return;
|
|
108
|
+
if (key in exports && exports[key] === _navigator[key]) return;
|
|
109
|
+
Object.defineProperty(exports, key, {
|
|
110
|
+
enumerable: true,
|
|
111
|
+
get: function () {
|
|
112
|
+
return _navigator[key];
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
var _object = require("./object.cjs");
|
|
117
|
+
Object.keys(_object).forEach(function (key) {
|
|
118
|
+
if (key === "default" || key === "__esModule") return;
|
|
119
|
+
if (key in exports && exports[key] === _object[key]) return;
|
|
120
|
+
Object.defineProperty(exports, key, {
|
|
121
|
+
enumerable: true,
|
|
122
|
+
get: function () {
|
|
123
|
+
return _object[key];
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
var _packageJson = require("./package-json.cjs");
|
|
128
|
+
Object.keys(_packageJson).forEach(function (key) {
|
|
129
|
+
if (key === "default" || key === "__esModule") return;
|
|
130
|
+
if (key in exports && exports[key] === _packageJson[key]) return;
|
|
131
|
+
Object.defineProperty(exports, key, {
|
|
132
|
+
enumerable: true,
|
|
133
|
+
get: function () {
|
|
134
|
+
return _packageJson[key];
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
var _packageManager = require("./package-manager.cjs");
|
|
139
|
+
Object.keys(_packageManager).forEach(function (key) {
|
|
140
|
+
if (key === "default" || key === "__esModule") return;
|
|
141
|
+
if (key in exports && exports[key] === _packageManager[key]) return;
|
|
142
|
+
Object.defineProperty(exports, key, {
|
|
143
|
+
enumerable: true,
|
|
144
|
+
get: function () {
|
|
145
|
+
return _packageManager[key];
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
var _string = require("./string.cjs");
|
|
150
|
+
Object.keys(_string).forEach(function (key) {
|
|
151
|
+
if (key === "default" || key === "__esModule") return;
|
|
152
|
+
if (key in exports && exports[key] === _string[key]) return;
|
|
153
|
+
Object.defineProperty(exports, key, {
|
|
154
|
+
enumerable: true,
|
|
155
|
+
get: function () {
|
|
156
|
+
return _string[key];
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
var _system = require("./system.cjs");
|
|
161
|
+
Object.keys(_system).forEach(function (key) {
|
|
162
|
+
if (key === "default" || key === "__esModule") return;
|
|
163
|
+
if (key in exports && exports[key] === _system[key]) return;
|
|
164
|
+
Object.defineProperty(exports, key, {
|
|
165
|
+
enumerable: true,
|
|
166
|
+
get: function () {
|
|
167
|
+
return _system[key];
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
var _tsconfig = require("./tsconfig.cjs");
|
|
172
|
+
Object.keys(_tsconfig).forEach(function (key) {
|
|
173
|
+
if (key === "default" || key === "__esModule") return;
|
|
174
|
+
if (key in exports && exports[key] === _tsconfig[key]) return;
|
|
175
|
+
Object.defineProperty(exports, key, {
|
|
176
|
+
enumerable: true,
|
|
177
|
+
get: function () {
|
|
178
|
+
return _tsconfig[key];
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
var _user = require("./user.cjs");
|
|
183
|
+
Object.keys(_user).forEach(function (key) {
|
|
184
|
+
if (key === "default" || key === "__esModule") return;
|
|
185
|
+
if (key in exports && exports[key] === _user[key]) return;
|
|
186
|
+
Object.defineProperty(exports, key, {
|
|
187
|
+
enumerable: true,
|
|
188
|
+
get: function () {
|
|
189
|
+
return _user[key];
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
var _utilities = require("./utilities.cjs");
|
|
194
|
+
Object.keys(_utilities).forEach(function (key) {
|
|
195
|
+
if (key === "default" || key === "__esModule") return;
|
|
196
|
+
if (key in exports && exports[key] === _utilities[key]) return;
|
|
197
|
+
Object.defineProperty(exports, key, {
|
|
198
|
+
enumerable: true,
|
|
199
|
+
get: function () {
|
|
200
|
+
return _utilities[key];
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
var _validations = require("./validations.cjs");
|
|
205
|
+
Object.keys(_validations).forEach(function (key) {
|
|
206
|
+
if (key === "default" || key === "__esModule") return;
|
|
207
|
+
if (key in exports && exports[key] === _validations[key]) return;
|
|
208
|
+
Object.defineProperty(exports, key, {
|
|
209
|
+
enumerable: true,
|
|
210
|
+
get: function () {
|
|
211
|
+
return _validations[key];
|
|
47
212
|
}
|
|
48
213
|
});
|
|
49
214
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,22 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @packageDocumentation
|
|
8
8
|
*/
|
|
9
|
-
export * from "./
|
|
10
|
-
export * from "./
|
|
11
|
-
export * from "./
|
|
12
|
-
export * from "./
|
|
9
|
+
export * from "./array";
|
|
10
|
+
export * from "./async";
|
|
11
|
+
export * from "./base";
|
|
12
|
+
export * from "./configuration";
|
|
13
|
+
export * from "./file";
|
|
14
|
+
export * from "./form";
|
|
15
|
+
export * from "./json";
|
|
16
|
+
export * from "./logic";
|
|
17
|
+
export * from "./messages";
|
|
18
|
+
export * from "./navigator";
|
|
19
|
+
export * from "./object";
|
|
20
|
+
export * from "./package-json";
|
|
21
|
+
export * from "./package-manager";
|
|
22
|
+
export * from "./string";
|
|
23
|
+
export * from "./system";
|
|
24
|
+
export * from "./tsconfig";
|
|
25
|
+
export * from "./user";
|
|
26
|
+
export * from "./utilities";
|
|
27
|
+
export * from "./validations";
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./
|
|
1
|
+
export*from"./array";export*from"./async";export*from"./base";export*from"./configuration";export*from"./file";export*from"./form";export*from"./json";export*from"./logic";export*from"./messages";export*from"./navigator";export*from"./object";export*from"./package-json";export*from"./package-manager";export*from"./string";export*from"./system";export*from"./tsconfig";export*from"./user";export*from"./utilities";export*from"./validations";
|
|
@@ -5,22 +5,16 @@ export type JsonObject = {
|
|
|
5
5
|
};
|
|
6
6
|
/**
|
|
7
7
|
* Matches a JSON array.
|
|
8
|
-
*
|
|
9
|
-
* @category JSON
|
|
10
8
|
*/
|
|
11
9
|
export type JsonArray = JsonValue[] | readonly JsonValue[];
|
|
12
10
|
/**
|
|
13
11
|
* Matches any valid JSON primitive value.
|
|
14
|
-
*
|
|
15
|
-
* @category JSON
|
|
16
12
|
*/
|
|
17
13
|
export type JsonPrimitive = string | number | boolean | null;
|
|
18
14
|
/**
|
|
19
15
|
* Matches any valid JSON value.
|
|
20
16
|
*
|
|
21
17
|
* @see `Jsonify` if you need to transform a type to one that is assignable to `JsonValue`.
|
|
22
|
-
*
|
|
23
|
-
* @category JSON
|
|
24
18
|
*/
|
|
25
19
|
export type JsonValue = JsonPrimitive | JsonObject | JsonArray;
|
|
26
20
|
/**
|
|
@@ -49,8 +43,6 @@ export type JsonPointerPath = (string | number)[];
|
|
|
49
43
|
* speed: '101'
|
|
50
44
|
* };
|
|
51
45
|
* ```
|
|
52
|
-
*
|
|
53
|
-
* @category Object
|
|
54
46
|
*/
|
|
55
47
|
export type Stringified<ObjectType> = {
|
|
56
48
|
[KeyType in keyof ObjectType]: string;
|
|
@@ -76,7 +68,5 @@ export type Stringified<ObjectType> = {
|
|
|
76
68
|
* type StringKeysOfFoo = StringKeyOf<Foo>;
|
|
77
69
|
* //=> '1' | 'stringKey'
|
|
78
70
|
* ```
|
|
79
|
-
*
|
|
80
|
-
* @category Object
|
|
81
71
|
*/
|
|
82
72
|
export type StringKeyOf<BaseType> = `${Extract<keyof BaseType, string | number>}`;
|
|
@@ -7,8 +7,6 @@ export type Zero = 0 | 0n;
|
|
|
7
7
|
* Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/32277) if you want to have this type as a built-in in TypeScript.
|
|
8
8
|
*
|
|
9
9
|
* @see NegativeInfinity
|
|
10
|
-
*
|
|
11
|
-
* @category Numeric
|
|
12
10
|
*/
|
|
13
11
|
export type PositiveInfinity = 1e999;
|
|
14
12
|
/**
|
|
@@ -17,8 +15,6 @@ export type PositiveInfinity = 1e999;
|
|
|
17
15
|
* Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/32277) if you want to have this type as a built-in in TypeScript.
|
|
18
16
|
*
|
|
19
17
|
* @see PositiveInfinity
|
|
20
|
-
*
|
|
21
|
-
* @category Numeric
|
|
22
18
|
*/
|
|
23
19
|
export type NegativeInfinity = -1e999;
|
|
24
20
|
/**
|
|
@@ -35,8 +31,6 @@ export type NegativeInfinity = -1e999;
|
|
|
35
31
|
*
|
|
36
32
|
* declare function setScore<T extends number>(length: Finite<T>): void;
|
|
37
33
|
* ```
|
|
38
|
-
*
|
|
39
|
-
* @category Numeric
|
|
40
34
|
*/
|
|
41
35
|
export type Finite<T extends number> = T extends PositiveInfinity | NegativeInfinity ? never : T;
|
|
42
36
|
/**
|
|
@@ -79,8 +73,6 @@ export type Finite<T extends number> = T extends PositiveInfinity | NegativeInfi
|
|
|
79
73
|
*
|
|
80
74
|
* @see NegativeInteger
|
|
81
75
|
* @see NonNegativeInteger
|
|
82
|
-
*
|
|
83
|
-
* @category Numeric
|
|
84
76
|
*/
|
|
85
77
|
export type Integer<T> = T extends unknown ? IsInteger<T> extends true ? T : never : never;
|
|
86
78
|
export type IsInteger<T> = T extends bigint ? true : T extends number ? number extends T ? false : T extends PositiveInfinity | NegativeInfinity ? false : Not<IsFloat<T>> : false;
|
|
@@ -100,8 +92,6 @@ export type IsFloat<T> = T extends number ? `${T}` extends `${string | number |
|
|
|
100
92
|
* ```
|
|
101
93
|
*
|
|
102
94
|
* @see Integer
|
|
103
|
-
*
|
|
104
|
-
* @category Numeric
|
|
105
95
|
*/
|
|
106
96
|
export type Float<T> = T extends unknown ? IsFloat<T> extends true ? T : never : never;
|
|
107
97
|
/**
|
|
@@ -112,8 +102,6 @@ export type Float<T> = T extends unknown ? IsFloat<T> extends true ? T : never :
|
|
|
112
102
|
*
|
|
113
103
|
* @see Negative
|
|
114
104
|
* @see Float
|
|
115
|
-
*
|
|
116
|
-
* @category Numeric
|
|
117
105
|
*/
|
|
118
106
|
export type NegativeFloat<T extends number> = Negative<Float<T>>;
|
|
119
107
|
/**
|
|
@@ -123,8 +111,6 @@ export type NegativeFloat<T extends number> = Negative<Float<T>>;
|
|
|
123
111
|
*
|
|
124
112
|
* @see NegativeInteger
|
|
125
113
|
* @see NonNegative
|
|
126
|
-
*
|
|
127
|
-
* @category Numeric
|
|
128
114
|
*/
|
|
129
115
|
export type Negative<T extends Numeric> = T extends Zero ? never : `${T}` extends `-${string}` ? T : never;
|
|
130
116
|
/**
|
|
@@ -137,8 +123,6 @@ export type Negative<T extends Numeric> = T extends Zero ? never : `${T}` extend
|
|
|
137
123
|
*
|
|
138
124
|
* @see Negative
|
|
139
125
|
* @see Integer
|
|
140
|
-
*
|
|
141
|
-
* @category Numeric
|
|
142
126
|
*/
|
|
143
127
|
export type NegativeInteger<T extends number> = Negative<Integer<T>>;
|
|
144
128
|
/**
|
|
@@ -155,8 +139,6 @@ export type NegativeInteger<T extends number> = Negative<Integer<T>>;
|
|
|
155
139
|
*
|
|
156
140
|
* declare function setLength<T extends number>(length: NonNegative<T>): void;
|
|
157
141
|
* ```
|
|
158
|
-
*
|
|
159
|
-
* @category Numeric
|
|
160
142
|
*/
|
|
161
143
|
export type NonNegative<T extends Numeric> = T extends Zero ? T : Negative<T> extends never ? T : never;
|
|
162
144
|
/**
|
|
@@ -176,8 +158,6 @@ export type NonNegative<T extends Numeric> = T extends Zero ? T : Negative<T> ex
|
|
|
176
158
|
*
|
|
177
159
|
* declare function setLength<T extends number>(length: NonNegativeInteger<T>): void;
|
|
178
160
|
* ```
|
|
179
|
-
*
|
|
180
|
-
* @category Numeric
|
|
181
161
|
*/
|
|
182
162
|
export type NonNegativeInteger<T extends number> = NonNegative<Integer<T>>;
|
|
183
163
|
/**
|
|
@@ -192,7 +172,5 @@ export type NonNegativeInteger<T extends number> = NonNegative<Integer<T>>;
|
|
|
192
172
|
* type ShouldBeFalse = IsNegative<1>;
|
|
193
173
|
* type ShouldBeTrue = IsNegative<-1>;
|
|
194
174
|
* ```
|
|
195
|
-
*
|
|
196
|
-
* @category Numeric
|
|
197
175
|
*/
|
|
198
176
|
export type IsNegative<T extends Numeric> = T extends Negative<T> ? true : false;
|