-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmod.d.ts
135 lines (116 loc) · 3.13 KB
/
mod.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
export type Primitive =
| string
| number
| bigint
| boolean
| symbol
| undefined
| object
| Function;
export interface WeakRef<T extends object> {
readonly [Symbol.toStringTag]: "WeakRef";
/**
* Returns the WeakRef instance's target object, or undefined if the target object has been
* reclaimed.
*/
deref(): T | undefined;
}
export interface WeakRefConstructor {
readonly prototype: WeakRef<any>;
/**
* Creates a WeakRef instance for the given target object.
* @param target The target object for the WeakRef instance.
*/
new <T extends object>(target: T): WeakRef<T>;
}
export const WeakRef: WeakRefConstructor;
// deno-fmt-ignore
export type Flatten<T, Deep = false, Infer = false> =
| T extends Keyable
? Infer extends true
? T extends infer U
? Flatten<U, Deep, false>
: never
: { [K in keyof T]: Deep extends true ? Flatten<T[K], true, Infer> : T[K] }
: T;
export type UnionToIntersection<U> =
(U extends any ? (k: U) => void : never) extends (
k: infer I,
) => void ? I
: never;
export type UnionToFunction<T> = T extends any ? () => T : never;
export type LastOf<T> = UnionToIntersection<UnionToFunction<T>> extends
() => infer R ? R
: never;
export type Push<T extends unknown[], V> = [
...T,
...(V extends unknown[] ? V : [V]),
];
export type UnionToTuple<
T,
L = LastOf<T>,
N = [T] extends [never] ? true : false,
> = true extends N ? [] : Push<UnionToTuple<Exclude<T, L>>, L>;
/**
* Matches a `class` constructor.
* @see https://mdn.io/Classes.
*/
export interface Class<
Proto = unknown,
Args extends any[] = any[],
> extends Constructor<Proto, Args> {
readonly prototype: Proto;
}
export interface Constructor<Proto = unknown, Args extends any[] = any[]> {
new (...args: Args): Proto;
}
export type Predicate<T = unknown> = (value: unknown) => value is T;
/**
* Matches any primitive value.
* @see https://mdn.io/Primitive
*/
export type Primitive =
| null
| undefined
| string
| number
| boolean
| symbol
| bigint;
/**
* @see {@link Printable} for more information on Printable Primitive types.
*/
export type MaybePrintable = Exclude<Primitive, symbol>;
/**
* The "Printable" Primitives - `string`, `number`, `boolean`, `bigint` - are
* the subset of the Primitive types that can be printed in Template Literal
* types (a feature of TypeScript 4.1+).
*
* _Technically_ `null` and `undefined` are also printable, but only as the
* literal strings `"null"` and `"undefined"`, respectively. As such, they
* are not included in this type.
*
* @see {@linkcode MaybePrintable} if you need to include `null` and `undefined` in the Printable type for your use case.
*/
export type Printable = NonNullable<MaybePrintable>;
/**
* Matches any [typed array](https://mdn.io/TypedArray).
* @see https://mdn.io/TypedArray
*/
export type TypedArray =
| Int8Array
| Uint8Array
| Uint8ClampedArray
| Int16Array
| Uint16Array
| Int32Array
| Uint32Array
| Float32Array
| Float64Array
| BigInt64Array
| BigUint64Array;
export type Keyable =
| Record<PropertyKey, unknown>
| unknown[]
| Map<any, any>
| Set<any>;