@hairy/utils 1.47.0 → 1.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{LICENSE.md → LICENSE} +21 -21
- package/README.md +688 -36
- package/dist/index.cjs +6878 -3723
- package/dist/{index.d.ts → index.d.cts} +179 -178
- package/dist/index.d.mts +823 -0
- package/dist/index.mjs +7168 -0
- package/package.json +16 -17
- package/dist/index.global.js +0 -5192
- package/dist/index.js +0 -4006
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
import _Bignumber from
|
|
1
|
+
import { chunk, clone, cloneDeep, cloneDeepWith, cloneWith, concat, debounce, find, get, groupBy, isArguments, isArray, isArrayBuffer, isArrayLike, isArrayLikeObject, isBoolean, isBuffer, isDate, isElement, isEmpty, isEqual, isEqualWith, isError, isFunction, isInteger, isMap, isMatch, isMatchWith, isNaN, isNative, isNull, isNumber, isObject, isObjectLike, isPlainObject, isRegExp as isRegexp, isSet, isString, isSymbol, isUndefined, isWeakMap, isWeakSet, join, keyBy, keys, max, maxBy, merge, mergeWith, min, minBy, omit, omitBy, once, pick, pickBy, range, set, truncate, uniq, uniqBy, uniqWith, values } from "lodash-es";
|
|
2
|
+
import _Bignumber from "bignumber.js";
|
|
3
3
|
|
|
4
|
+
//#region src/browser/file.d.ts
|
|
4
5
|
interface OpenFilePickerOptions {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
/**
|
|
7
|
+
* select multiple files
|
|
8
|
+
*/
|
|
9
|
+
multiple?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Choose the default format for the file
|
|
12
|
+
*/
|
|
13
|
+
accept?: string;
|
|
13
14
|
}
|
|
14
15
|
/**
|
|
15
16
|
* Select multiple files
|
|
@@ -18,10 +19,10 @@ declare function openFilePicker(option?: OpenFilePickerOptions): Promise<File[]>
|
|
|
18
19
|
/** @deprecated use openFilePicker */
|
|
19
20
|
declare const showOpenFilePicker: typeof openFilePicker;
|
|
20
21
|
interface OpenImagePickerOptions {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
/**
|
|
23
|
+
* select multiple images
|
|
24
|
+
*/
|
|
25
|
+
multiple?: boolean;
|
|
25
26
|
}
|
|
26
27
|
/**
|
|
27
28
|
* Select multiple images
|
|
@@ -51,30 +52,32 @@ type ReaderType = 'readAsArrayBuffer' | 'readAsBinaryString' | 'readAsDataURL' |
|
|
|
51
52
|
* @param file file object
|
|
52
53
|
*/
|
|
53
54
|
declare function readFileReader<T extends ReaderType>(formType: T, file: File): Promise<T extends "readAsArrayBuffer" ? ArrayBuffer : string>;
|
|
54
|
-
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region src/typings/atom.d.ts
|
|
55
57
|
type Numeric = string | number | bigint;
|
|
56
58
|
type Numberish = Numeric | {
|
|
57
|
-
|
|
59
|
+
toString: (...args: any[]) => string;
|
|
58
60
|
} | undefined | null;
|
|
59
61
|
interface DynamicObject {
|
|
60
|
-
|
|
62
|
+
[key: string]: any;
|
|
61
63
|
}
|
|
62
64
|
interface NumericObject {
|
|
63
|
-
|
|
65
|
+
[key: string]: Numeric;
|
|
64
66
|
}
|
|
65
67
|
interface StringObject {
|
|
66
|
-
|
|
68
|
+
[key: string]: string;
|
|
67
69
|
}
|
|
68
70
|
interface NumberObject {
|
|
69
|
-
|
|
71
|
+
[key: string]: string;
|
|
70
72
|
}
|
|
71
73
|
interface SymbolObject {
|
|
72
|
-
|
|
74
|
+
[key: string]: symbol;
|
|
73
75
|
}
|
|
74
76
|
type Key = string | number | symbol;
|
|
75
77
|
type BooleanLike = any;
|
|
76
78
|
type Noop = (...args: any[]) => any;
|
|
77
|
-
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/typings/util.d.ts
|
|
78
81
|
/**
|
|
79
82
|
* Any type that can be used where a big number is needed.
|
|
80
83
|
*/
|
|
@@ -83,7 +86,7 @@ type Arrayable<T> = T | T[];
|
|
|
83
86
|
type Promisify<T> = Promise<Awaited<T>>;
|
|
84
87
|
type ElementOf<T> = T extends (infer E)[] ? E : never;
|
|
85
88
|
type Nullable<T> = T | null | undefined;
|
|
86
|
-
type Fn
|
|
89
|
+
type Fn<T = void> = () => T;
|
|
87
90
|
type AnyFn = (...args: any[]) => any;
|
|
88
91
|
type PromiseFn = (...args: any[]) => Promise<any>;
|
|
89
92
|
type IfAny<T, Y, N> = 0 extends 1 & T ? Y : N;
|
|
@@ -92,51 +95,30 @@ type ConstructorType<T = void> = new (...args: any[]) => T;
|
|
|
92
95
|
type ArgumentsType<T> = T extends ((...args: infer A) => any) ? A : never;
|
|
93
96
|
type PromiseType<P extends PromiseLike<any>> = P extends PromiseLike<infer T> ? T : never;
|
|
94
97
|
type BrowserNativeObject = Date | FileList | File;
|
|
95
|
-
type Option<L extends Key = 'label', V extends Key = 'value', C extends Key = 'children'> = {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
[P in V]?: Numeric;
|
|
99
|
-
} & {
|
|
100
|
-
[P in C]?: Option<L, V, C>[];
|
|
101
|
-
};
|
|
102
|
-
type OmitBy<T, V> = {
|
|
103
|
-
[K in keyof T as T[K] extends V ? never : K]: T[K];
|
|
104
|
-
};
|
|
105
|
-
type PickBy<T, U> = {
|
|
106
|
-
[K in keyof T as T[K] extends U ? K : never]: T[K];
|
|
107
|
-
};
|
|
98
|
+
type Option<L extends Key = 'label', V extends Key = 'value', C extends Key = 'children'> = { [P in L]?: string } & { [P in V]?: Numeric } & { [P in C]?: Option<L, V, C>[] };
|
|
99
|
+
type OmitBy<T, V> = { [K in keyof T as T[K] extends V ? never : K]: T[K] };
|
|
100
|
+
type PickBy<T, U> = { [K in keyof T as T[K] extends U ? K : never]: T[K] };
|
|
108
101
|
type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;
|
|
109
102
|
type Assign<T, U> = Omit<T, keyof U> & U;
|
|
110
103
|
type NonUndefined<T> = T extends undefined ? never : T;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
};
|
|
115
|
-
type
|
|
116
|
-
|
|
117
|
-
};
|
|
118
|
-
type DeepPartial<T> = {
|
|
119
|
-
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
120
|
-
};
|
|
121
|
-
type DeepReplace<T, K = unknown, V = unknown> = {
|
|
122
|
-
[P in keyof T]: K extends P ? V : DeepReplace<T[P], K, V>;
|
|
123
|
-
};
|
|
104
|
+
//#endregion
|
|
105
|
+
//#region src/typings/deep.d.ts
|
|
106
|
+
type DeepReadonly<T> = { readonly [P in keyof T]: T[P] extends object ? DeepReadonly<T[P]> : T[P] };
|
|
107
|
+
type DeepRequired<T> = { [P in keyof T]-?: T[P] extends object ? DeepRequired<T[P]> : T[P] };
|
|
108
|
+
type DeepPartial<T> = { [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P] };
|
|
109
|
+
type DeepReplace<T, K = unknown, V = unknown> = { [P in keyof T]: K extends P ? V : DeepReplace<T[P], K, V> };
|
|
124
110
|
type DeepKeyof<T> = T extends object ? keyof T | DeepKeyof<T[keyof T]> : never;
|
|
125
|
-
type MergeInsertions<T> = T extends object ? {
|
|
126
|
-
|
|
127
|
-
} :
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}>;
|
|
131
|
-
type DeepMap<T, V, ST = BrowserNativeObject> = IsAny<T> extends true ? any : T extends ST ? V : T extends object ? {
|
|
132
|
-
[K in keyof T]: DeepMap<NonUndefined<T[K]>, V, ST>;
|
|
133
|
-
} : V;
|
|
134
|
-
|
|
111
|
+
type MergeInsertions<T> = T extends object ? { [K in keyof T]: MergeInsertions<T[K]> } : T;
|
|
112
|
+
type DeepMerge<F, S> = MergeInsertions<{ [K in keyof F | keyof S]: K extends keyof S & keyof F ? DeepMerge<F[K], S[K]> : K extends keyof S ? S[K] : K extends keyof F ? F[K] : never }>;
|
|
113
|
+
type DeepMap<T, V, ST = BrowserNativeObject> = IsAny<T> extends true ? any : T extends ST ? V : T extends object ? { [K in keyof T]: DeepMap<NonUndefined<T[K]>, V, ST> } : V;
|
|
114
|
+
//#endregion
|
|
115
|
+
//#region src/browser/util.d.ts
|
|
135
116
|
declare function redirectTo(url: string, target?: string): void;
|
|
136
117
|
declare function dialsPhone(phoneNumber: string): void;
|
|
137
|
-
declare function on<T extends Window | Document | HTMLElement | EventTarget>(obj: T | null, ...args: Parameters<T['addEventListener']> | [string, Fn
|
|
138
|
-
declare function off<T extends Window | Document | HTMLElement | EventTarget>(obj: T | null, ...args: Parameters<T['removeEventListener']> | [string, Fn
|
|
139
|
-
|
|
118
|
+
declare function on<T extends Window | Document | HTMLElement | EventTarget>(obj: T | null, ...args: Parameters<T['addEventListener']> | [string, Fn | null, ...any]): void;
|
|
119
|
+
declare function off<T extends Window | Document | HTMLElement | EventTarget>(obj: T | null, ...args: Parameters<T['removeEventListener']> | [string, Fn | null, ...any]): void;
|
|
120
|
+
//#endregion
|
|
121
|
+
//#region src/is/index.d.ts
|
|
140
122
|
declare const isBrowser: () => boolean;
|
|
141
123
|
declare const isWeex: () => boolean;
|
|
142
124
|
declare const isIE: () => boolean | "";
|
|
@@ -152,7 +134,8 @@ declare const isMobile: () => boolean;
|
|
|
152
134
|
declare const isFormData: (value: any) => value is FormData;
|
|
153
135
|
declare const isWindow: (value: any) => value is Window;
|
|
154
136
|
declare const isTruthy: <T>(value: T) => value is NonNullable<T>;
|
|
155
|
-
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region ../../node_modules/.pnpm/change-case@5.4.4/node_modules/change-case/dist/index.d.ts
|
|
156
139
|
/**
|
|
157
140
|
* Supported locale values. Use `false` to ignore locale.
|
|
158
141
|
* Defaults to `undefined`, which uses the host environment.
|
|
@@ -162,19 +145,19 @@ type Locale = string[] | string | false | undefined;
|
|
|
162
145
|
* Options used for converting strings to pascal/camel case.
|
|
163
146
|
*/
|
|
164
147
|
interface PascalCaseOptions extends Options {
|
|
165
|
-
|
|
148
|
+
mergeAmbiguousCharacters?: boolean;
|
|
166
149
|
}
|
|
167
150
|
/**
|
|
168
151
|
* Options used for converting strings to any case.
|
|
169
152
|
*/
|
|
170
153
|
interface Options {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
154
|
+
locale?: Locale;
|
|
155
|
+
split?: (value: string) => string[];
|
|
156
|
+
/** @deprecated Pass `split: splitSeparateNumbers` instead. */
|
|
157
|
+
separateNumbers?: boolean;
|
|
158
|
+
delimiter?: string;
|
|
159
|
+
prefixCharacters?: string;
|
|
160
|
+
suffixCharacters?: string;
|
|
178
161
|
}
|
|
179
162
|
/**
|
|
180
163
|
* Convert a string to space separated lower case (`foo bar`).
|
|
@@ -224,14 +207,15 @@ declare function snakeCase(input: string, options?: Options): string;
|
|
|
224
207
|
* Convert a string to header case (`Foo-Bar`).
|
|
225
208
|
*/
|
|
226
209
|
declare function trainCase(input: string, options?: Options): string;
|
|
227
|
-
|
|
210
|
+
//#endregion
|
|
211
|
+
//#region src/number/index.d.ts
|
|
228
212
|
declare const DEFAULT_BIGNUM_CONFIG: _Bignumber.Config;
|
|
229
213
|
declare namespace Bignumber {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
214
|
+
type RoundingMode = _Bignumber.RoundingMode;
|
|
215
|
+
type Format = _Bignumber.Format;
|
|
216
|
+
type Config = _Bignumber.Config;
|
|
217
|
+
type Instance = _Bignumber.Instance;
|
|
218
|
+
type Value = _Bignumber.Value;
|
|
235
219
|
}
|
|
236
220
|
declare const Bignumber: typeof _Bignumber;
|
|
237
221
|
/**
|
|
@@ -239,48 +223,31 @@ declare const Bignumber: typeof _Bignumber;
|
|
|
239
223
|
*
|
|
240
224
|
* do not use Bignumber directly, use bignumber function instead
|
|
241
225
|
*/
|
|
242
|
-
declare const BIG_INTS: {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
};
|
|
248
|
-
b: {
|
|
249
|
-
v: number;
|
|
250
|
-
d: number;
|
|
251
|
-
n: string;
|
|
252
|
-
};
|
|
253
|
-
m: {
|
|
254
|
-
v: number;
|
|
255
|
-
d: number;
|
|
256
|
-
n: string;
|
|
257
|
-
};
|
|
258
|
-
k: {
|
|
259
|
-
v: number;
|
|
260
|
-
d: number;
|
|
261
|
-
n: string;
|
|
262
|
-
};
|
|
263
|
-
};
|
|
226
|
+
declare const BIG_INTS: Record<Delimiter, {
|
|
227
|
+
v: number;
|
|
228
|
+
d: number;
|
|
229
|
+
n: string;
|
|
230
|
+
}>;
|
|
264
231
|
type Delimiter = 'k' | 'm' | 'b' | 't';
|
|
265
232
|
interface DecimalOptions {
|
|
266
|
-
|
|
267
|
-
|
|
233
|
+
d?: number;
|
|
234
|
+
r?: Bignumber.RoundingMode;
|
|
268
235
|
}
|
|
269
236
|
interface FormatGroupOptions {
|
|
270
|
-
|
|
271
|
-
|
|
237
|
+
size?: number;
|
|
238
|
+
symbol?: string;
|
|
272
239
|
}
|
|
273
240
|
interface FormatNumericOptions {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
241
|
+
delimiters?: Delimiter[] | false;
|
|
242
|
+
rounding?: Bignumber.RoundingMode;
|
|
243
|
+
decimals?: number;
|
|
244
|
+
decimalsZero?: boolean;
|
|
245
|
+
default?: string;
|
|
246
|
+
format?: Bignumber.Format;
|
|
280
247
|
}
|
|
281
248
|
declare function bignumber(n?: Numberish, base?: number): _Bignumber;
|
|
282
249
|
declare namespace bignumber {
|
|
283
|
-
|
|
250
|
+
var clone: (config: Bignumber.Config) => typeof _Bignumber;
|
|
284
251
|
}
|
|
285
252
|
declare function gte(a: Numberish, b: Numberish): boolean;
|
|
286
253
|
declare function gt(a: Numberish, b: Numberish): boolean;
|
|
@@ -316,9 +283,9 @@ declare function integer(value: Numberish): string;
|
|
|
316
283
|
*/
|
|
317
284
|
declare function decimal(value: Numberish, n?: number): string;
|
|
318
285
|
declare function parseNumeric(num: Numberish, delimiters?: Delimiter[]): {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
286
|
+
v: number;
|
|
287
|
+
d: number;
|
|
288
|
+
n: string;
|
|
322
289
|
};
|
|
323
290
|
/**
|
|
324
291
|
* format number thousand separator and unit
|
|
@@ -326,7 +293,8 @@ declare function parseNumeric(num: Numberish, delimiters?: Delimiter[]): {
|
|
|
326
293
|
* @param options
|
|
327
294
|
*/
|
|
328
295
|
declare function formatNumeric(value?: Numberish, options?: FormatNumericOptions): string;
|
|
329
|
-
|
|
296
|
+
//#endregion
|
|
297
|
+
//#region src/string/index.d.ts
|
|
330
298
|
/**
|
|
331
299
|
* Intercept front and back characters, hide middle characters
|
|
332
300
|
* @param value
|
|
@@ -405,9 +373,11 @@ declare function template(str: string, ...args: (string | number | bigint | unde
|
|
|
405
373
|
* b()
|
|
406
374
|
* }
|
|
407
375
|
* `
|
|
376
|
+
* ```
|
|
408
377
|
*/
|
|
409
378
|
declare function unindent(str: TemplateStringsArray | string): string;
|
|
410
|
-
|
|
379
|
+
//#endregion
|
|
380
|
+
//#region src/util/compose-promise.d.ts
|
|
411
381
|
type UF$1<VT, RT> = (value: VT) => RT | PromiseLike<RT>;
|
|
412
382
|
type Composed<VT, RT> = (value?: VT) => Promise<RT>;
|
|
413
383
|
/**
|
|
@@ -436,8 +406,9 @@ declare function pCompose<VT, R1, R2, R3, R4, R5, RT>(f1: UF$1<R5, RT>, f2: UF$1
|
|
|
436
406
|
declare function pCompose<VT, R1, R2, R3, R4, R5, R6, RT>(f1: UF$1<R6, RT>, f2: UF$1<R5, R6>, f3: UF$1<R4, R5>, f4: UF$1<R3, R4>, f5: UF$1<R2, R3>, f6: UF$1<R1, R2>, f7: UF$1<VT, R1>): Composed<VT, RT>;
|
|
437
407
|
declare function pCompose<VT, R1, R2, R3, R4, R5, R6, R7, RT>(f1: UF$1<R7, RT>, f2: UF$1<R6, R7>, f3: UF$1<R5, R6>, f4: UF$1<R4, R5>, f5: UF$1<R3, R4>, f6: UF$1<R2, R3>, f7: UF$1<R1, R2>, f8: UF$1<VT, R1>): Composed<VT, RT>;
|
|
438
408
|
declare function pCompose<VT, R1, R2, R3, R4, R5, R6, R7, R8, RT>(f1: UF$1<R8, RT>, f2: UF$1<R7, R8>, f3: UF$1<R6, R7>, f4: UF$1<R5, R6>, f5: UF$1<R4, R5>, f6: UF$1<R3, R4>, f7: UF$1<R2, R3>, f8: UF$1<R1, R2>, f9: UF$1<VT, R1>): Composed<VT, RT>;
|
|
439
|
-
|
|
440
|
-
|
|
409
|
+
//#endregion
|
|
410
|
+
//#region src/util/compose.d.ts
|
|
411
|
+
type Fn$1<V, R> = (x: V) => R;
|
|
441
412
|
type Q<T, V> = (...args: T) => V;
|
|
442
413
|
/**
|
|
443
414
|
* Performs function composition in RTL (Right To Left) direction.
|
|
@@ -473,20 +444,21 @@ type Q<T, V> = (...args: T) => V;
|
|
|
473
444
|
* @param ...fns - Iterated over sequentially when returned `function` is called.
|
|
474
445
|
* @returns The `fns` functions are applied from right to left.
|
|
475
446
|
*/
|
|
476
|
-
declare function compose<T, V0, V1>(fn1: Fn<V0, V1>, fn0: Q<T, V0>): Q<T, V1>;
|
|
477
|
-
declare function compose<T, V0, V1, V2>(fn2: Fn<V1, V2>, fn1: Fn<V0, V1>, fn0: Q<T, V0>): Q<T, V2>;
|
|
478
|
-
declare function compose<T, V0, V1, V2, V3>(fn3: Fn<V2, V3>, fn2: Fn<V1, V2>, fn1: Fn<V0, V1>, fn0: Q<T, V0>): Q<T, V3>;
|
|
479
|
-
declare function compose<T, V0, V1, V2, V3, V4>(fn4: Fn<V3, V4>, fn3: Fn<V2, V3>, fn2: Fn<V1, V2>, fn1: Fn<V0, V1>, fn0: Q<T, V0>): Q<T, V4>;
|
|
480
|
-
declare function compose<T, V0, V1, V2, V3, V4, V5>(fn5: Fn<V4, V5>, fn4: Fn<V3, V4>, fn3: Fn<V2, V3>, fn2: Fn<V1, V2>, fn1: Fn<V0, V1>, fn0: Q<T, V0>): Q<T, V5>;
|
|
481
|
-
declare function compose<T, V0, V1, V2, V3, V4, V5, V6>(fn6: Fn<V5, V6>, fn5: Fn<V4, V5>, fn4: Fn<V3, V4>, fn3: Fn<V2, V3>, fn2: Fn<V1, V2>, fn1: Fn<V0, V1>, fn0: Q<T, V0>): Q<T, V6>;
|
|
482
|
-
declare function compose<T, V0, V1, V2, V3, V4, V5, V6, V7>(fn7: Fn<V6, V7>, fn6: Fn<V5, V6>, fn5: Fn<V4, V5>, fn4: Fn<V3, V4>, fn3: Fn<V2, V3>, fn2: Fn<V1, V2>, fn1: Fn<V0, V1>, fn0: Q<T, V0>): Q<T, V7>;
|
|
483
|
-
declare function compose<T, V0, V1, V2, V3, V4, V5, V6, V7, V8>(fn8: Fn<V7, V8>, fn7: Fn<V6, V7>, fn6: Fn<V5, V6>, fn5: Fn<V4, V5>, fn4: Fn<V3, V4>, fn3: Fn<V2, V3>, fn2: Fn<V1, V2>, fn1: Fn<V0, V1>, fn0: Q<T, V0>): Q<T, V8>;
|
|
484
|
-
declare function compose<T, V0, V1, V2, V3, V4, V5, V6, V7, V8, V9>(fn9: Fn<V8, V9>, fn8: Fn<V7, V8>, fn7: Fn<V6, V7>, fn6: Fn<V5, V6>, fn5: Fn<V4, V5>, fn4: Fn<V3, V4>, fn3: Fn<V2, V3>, fn2: Fn<V1, V2>, fn1: Fn<V0, V1>, fn0: Q<T, V0>): Q<T, V9>;
|
|
485
|
-
declare function compose<T, V0, V1, V2, V3, V4, V5, V6, V7, V8, V9, V10>(fn10: Fn<V9, V10>, fn9: Fn<V8, V9>, fn8: Fn<V7, V8>, fn7: Fn<V6, V7>, fn6: Fn<V5, V6>, fn5: Fn<V4, V5>, fn4: Fn<V3, V4>, fn3: Fn<V2, V3>, fn2: Fn<V1, V2>, fn1: Fn<V0, V1>, fn0: Q<T, V0>): Q<T, V10>;
|
|
447
|
+
declare function compose<T, V0, V1>(fn1: Fn$1<V0, V1>, fn0: Q<T, V0>): Q<T, V1>;
|
|
448
|
+
declare function compose<T, V0, V1, V2>(fn2: Fn$1<V1, V2>, fn1: Fn$1<V0, V1>, fn0: Q<T, V0>): Q<T, V2>;
|
|
449
|
+
declare function compose<T, V0, V1, V2, V3>(fn3: Fn$1<V2, V3>, fn2: Fn$1<V1, V2>, fn1: Fn$1<V0, V1>, fn0: Q<T, V0>): Q<T, V3>;
|
|
450
|
+
declare function compose<T, V0, V1, V2, V3, V4>(fn4: Fn$1<V3, V4>, fn3: Fn$1<V2, V3>, fn2: Fn$1<V1, V2>, fn1: Fn$1<V0, V1>, fn0: Q<T, V0>): Q<T, V4>;
|
|
451
|
+
declare function compose<T, V0, V1, V2, V3, V4, V5>(fn5: Fn$1<V4, V5>, fn4: Fn$1<V3, V4>, fn3: Fn$1<V2, V3>, fn2: Fn$1<V1, V2>, fn1: Fn$1<V0, V1>, fn0: Q<T, V0>): Q<T, V5>;
|
|
452
|
+
declare function compose<T, V0, V1, V2, V3, V4, V5, V6>(fn6: Fn$1<V5, V6>, fn5: Fn$1<V4, V5>, fn4: Fn$1<V3, V4>, fn3: Fn$1<V2, V3>, fn2: Fn$1<V1, V2>, fn1: Fn$1<V0, V1>, fn0: Q<T, V0>): Q<T, V6>;
|
|
453
|
+
declare function compose<T, V0, V1, V2, V3, V4, V5, V6, V7>(fn7: Fn$1<V6, V7>, fn6: Fn$1<V5, V6>, fn5: Fn$1<V4, V5>, fn4: Fn$1<V3, V4>, fn3: Fn$1<V2, V3>, fn2: Fn$1<V1, V2>, fn1: Fn$1<V0, V1>, fn0: Q<T, V0>): Q<T, V7>;
|
|
454
|
+
declare function compose<T, V0, V1, V2, V3, V4, V5, V6, V7, V8>(fn8: Fn$1<V7, V8>, fn7: Fn$1<V6, V7>, fn6: Fn$1<V5, V6>, fn5: Fn$1<V4, V5>, fn4: Fn$1<V3, V4>, fn3: Fn$1<V2, V3>, fn2: Fn$1<V1, V2>, fn1: Fn$1<V0, V1>, fn0: Q<T, V0>): Q<T, V8>;
|
|
455
|
+
declare function compose<T, V0, V1, V2, V3, V4, V5, V6, V7, V8, V9>(fn9: Fn$1<V8, V9>, fn8: Fn$1<V7, V8>, fn7: Fn$1<V6, V7>, fn6: Fn$1<V5, V6>, fn5: Fn$1<V4, V5>, fn4: Fn$1<V3, V4>, fn3: Fn$1<V2, V3>, fn2: Fn$1<V1, V2>, fn1: Fn$1<V0, V1>, fn0: Q<T, V0>): Q<T, V9>;
|
|
456
|
+
declare function compose<T, V0, V1, V2, V3, V4, V5, V6, V7, V8, V9, V10>(fn10: Fn$1<V9, V10>, fn9: Fn$1<V8, V9>, fn8: Fn$1<V7, V8>, fn7: Fn$1<V6, V7>, fn6: Fn$1<V5, V6>, fn5: Fn$1<V4, V5>, fn4: Fn$1<V3, V4>, fn3: Fn$1<V2, V3>, fn2: Fn$1<V1, V2>, fn1: Fn$1<V0, V1>, fn0: Q<T, V0>): Q<T, V10>;
|
|
486
457
|
declare namespace compose {
|
|
487
|
-
|
|
458
|
+
var promise: typeof pCompose;
|
|
488
459
|
}
|
|
489
|
-
|
|
460
|
+
//#endregion
|
|
461
|
+
//#region src/util/deferred.d.ts
|
|
490
462
|
/**
|
|
491
463
|
* A deferred promise.
|
|
492
464
|
* @param T - The type of the value.
|
|
@@ -495,13 +467,15 @@ declare namespace compose {
|
|
|
495
467
|
* ```ts
|
|
496
468
|
* const deferred = new Deferred()
|
|
497
469
|
* deferred.resolve('value')
|
|
470
|
+
* ```
|
|
498
471
|
*/
|
|
499
472
|
declare class Deferred<T> extends Promise<T> {
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
473
|
+
resolve: (value?: T) => Deferred<T>;
|
|
474
|
+
reject: (reason?: any) => Deferred<T>;
|
|
475
|
+
constructor(executor?: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void);
|
|
503
476
|
}
|
|
504
|
-
|
|
477
|
+
//#endregion
|
|
478
|
+
//#region src/util/delay.d.ts
|
|
505
479
|
/**
|
|
506
480
|
* Delay for a given number of milliseconds.
|
|
507
481
|
* @param ms - The number of milliseconds to delay.
|
|
@@ -509,11 +483,21 @@ declare class Deferred<T> extends Promise<T> {
|
|
|
509
483
|
* @example
|
|
510
484
|
* ```ts
|
|
511
485
|
* delay(1000).then(() => { console.log('1 second') })
|
|
486
|
+
* ```
|
|
512
487
|
*/
|
|
513
488
|
declare function delay(ms: number): Promise<void>;
|
|
514
|
-
|
|
489
|
+
//#endregion
|
|
490
|
+
//#region src/util/ghost.d.ts
|
|
491
|
+
type Ghost<T extends object> = T & {
|
|
492
|
+
enabled: boolean;
|
|
493
|
+
resolve: (value: T) => void;
|
|
494
|
+
};
|
|
495
|
+
declare function ghost<T extends object>(strictMessage?: string): Ghost<T>;
|
|
496
|
+
//#endregion
|
|
497
|
+
//#region src/util/json.d.ts
|
|
515
498
|
declare function tryParseJson<T = any>(text: string | undefined | null): T | undefined;
|
|
516
|
-
|
|
499
|
+
//#endregion
|
|
500
|
+
//#region src/util/loop.d.ts
|
|
517
501
|
/**
|
|
518
502
|
* A function that performs a loop operation with delay control.
|
|
519
503
|
* @template T - The return type of the loop function (defaults to void)
|
|
@@ -551,32 +535,34 @@ declare function loop_return<T = void>(fn: Looper<T>): Promise<T>;
|
|
|
551
535
|
* console.log(result)
|
|
552
536
|
* ```
|
|
553
537
|
*/
|
|
554
|
-
declare function loop(fn: Looper<void>): Fn
|
|
538
|
+
declare function loop(fn: Looper<void>): Fn;
|
|
555
539
|
declare namespace loop {
|
|
556
|
-
|
|
557
|
-
|
|
540
|
+
var _a: typeof loop_return;
|
|
541
|
+
export { _a as return };
|
|
558
542
|
}
|
|
559
|
-
|
|
543
|
+
//#endregion
|
|
544
|
+
//#region src/util/noop.d.ts
|
|
560
545
|
declare const noop: (...args: any) => any;
|
|
561
|
-
|
|
546
|
+
//#endregion
|
|
547
|
+
//#region src/util/pipe-promise.d.ts
|
|
562
548
|
type UF<VT, RT> = (value: VT) => RT | PromiseLike<RT>;
|
|
563
549
|
type Pipeline<VT, RT> = (value?: VT) => Promise<RT>;
|
|
564
550
|
/**
|
|
565
|
-
Compose promise-returning & async fns into a reusable pipeline.
|
|
566
|
-
|
|
567
|
-
@param ...input - Iterated over sequentially when returned `function` is called.
|
|
568
|
-
@returns The `input` fns are applied from left to right.
|
|
569
|
-
|
|
570
|
-
@example
|
|
571
|
-
```
|
|
572
|
-
const addUnicorn = async string => `${string} Unicorn`;
|
|
573
|
-
const addRainbow = async string => `${string} Rainbow`;
|
|
574
|
-
|
|
575
|
-
const pipeline = pipe.promise(addUnicorn, addRainbow);
|
|
576
|
-
|
|
577
|
-
console.log(await pipeline('❤️'));
|
|
578
|
-
//=> '❤️ Unicorn Rainbow'
|
|
579
|
-
```
|
|
551
|
+
* Compose promise-returning & async fns into a reusable pipeline.
|
|
552
|
+
*
|
|
553
|
+
* @param ...input - Iterated over sequentially when returned `function` is called.
|
|
554
|
+
* @returns The `input` fns are applied from left to right.
|
|
555
|
+
*
|
|
556
|
+
* @example
|
|
557
|
+
* ```
|
|
558
|
+
* const addUnicorn = async string => `${string} Unicorn`;
|
|
559
|
+
* const addRainbow = async string => `${string} Rainbow`;
|
|
560
|
+
*
|
|
561
|
+
* const pipeline = pipe.promise(addUnicorn, addRainbow);
|
|
562
|
+
*
|
|
563
|
+
* console.log(await pipeline('❤️'));
|
|
564
|
+
* //=> '❤️ Unicorn Rainbow'
|
|
565
|
+
* ```
|
|
580
566
|
*/
|
|
581
567
|
declare function pPipe<VT, RT>(f1: UF<VT, RT>): Pipeline<VT, RT>;
|
|
582
568
|
declare function pPipe<VT, R1, RT>(f1: UF<VT, R1>, f2: UF<R1, RT>): Pipeline<VT, RT>;
|
|
@@ -587,7 +573,8 @@ declare function pPipe<VT, R1, R2, R3, R4, R5, RT>(f1: UF<VT, R1>, f2: UF<R1, R2
|
|
|
587
573
|
declare function pPipe<VT, R1, R2, R3, R4, R5, R6, RT>(f1: UF<VT, R1>, f2: UF<R1, R2>, f3: UF<R2, R3>, f4: UF<R3, R4>, f5: UF<R4, R5>, f6: UF<R5, R6>, f7: UF<R6, RT>): Pipeline<VT, RT>;
|
|
588
574
|
declare function pPipe<VT, R1, R2, R3, R4, R5, R6, R7, RT>(f1: UF<VT, R1>, f2: UF<R1, R2>, f3: UF<R2, R3>, f4: UF<R3, R4>, f5: UF<R4, R5>, f6: UF<R5, R6>, f7: UF<R6, R7>, f8: UF<R7, RT>): Pipeline<VT, RT>;
|
|
589
575
|
declare function pPipe<VT, R1, R2, R3, R4, R5, R6, R7, R8, RT>(f1: UF<VT, R1>, f2: UF<R1, R2>, f3: UF<R2, R3>, f4: UF<R3, R4>, f5: UF<R4, R5>, f6: UF<R5, R6>, f7: UF<R6, R7>, f8: UF<R7, R8>, f9: UF<R8, RT>): Pipeline<VT, RT>;
|
|
590
|
-
|
|
576
|
+
//#endregion
|
|
577
|
+
//#region src/util/pipe.d.ts
|
|
591
578
|
/**
|
|
592
579
|
* Performs function composition in LTR (Left To Right) direction.
|
|
593
580
|
*
|
|
@@ -634,14 +621,15 @@ declare function pipe<Args extends unknown[], T0, T1, T2, T3, T4, T5, T6, T7>(..
|
|
|
634
621
|
declare function pipe<Args extends unknown[], T0, T1, T2, T3, T4, T5, T6, T7, T8>(...fns: [(...xs: Args) => T0, (x: T0) => T1, (x: T1) => T2, (x: T2) => T3, (x: T3) => T4, (x: T4) => T5, (x: T5) => T6, (x: T6) => T7, (x: T7) => T8]): (...xs: Args) => T8;
|
|
635
622
|
declare function pipe<Args extends unknown[], T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>(...fns: [(...xs: Args) => T0, (x: T0) => T1, (x: T1) => T2, (x: T2) => T3, (x: T3) => T4, (x: T4) => T5, (x: T5) => T6, (x: T6) => T7, (x: T7) => T8, (x: T8) => T9]): (...xs: Args) => T9;
|
|
636
623
|
declare namespace pipe {
|
|
637
|
-
|
|
624
|
+
var promise: typeof pPipe;
|
|
638
625
|
}
|
|
639
|
-
|
|
626
|
+
//#endregion
|
|
627
|
+
//#region src/util/proxy.d.ts
|
|
640
628
|
type Proxyed<T extends object, E extends object = {}> = T & {
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
629
|
+
proxy: {
|
|
630
|
+
update: (object?: T) => void;
|
|
631
|
+
source: T | undefined;
|
|
632
|
+
};
|
|
645
633
|
} & E;
|
|
646
634
|
/**
|
|
647
635
|
* Creates a proxy object that updates the original object when the proxy is updated.
|
|
@@ -668,9 +656,10 @@ type Proxyed<T extends object, E extends object = {}> = T & {
|
|
|
668
656
|
* ```
|
|
669
657
|
*/
|
|
670
658
|
declare function proxy<T extends object, E extends object = {}>(initObject?: T, initExtend?: E, options?: {
|
|
671
|
-
|
|
659
|
+
strictMessage?: string;
|
|
672
660
|
}): Proxyed<T, E>;
|
|
673
|
-
|
|
661
|
+
//#endregion
|
|
662
|
+
//#region src/util/random.d.ts
|
|
674
663
|
/**
|
|
675
664
|
* Get a random item from an array.
|
|
676
665
|
* @param array - The array to get a random item from.
|
|
@@ -678,6 +667,7 @@ declare function proxy<T extends object, E extends object = {}>(initObject?: T,
|
|
|
678
667
|
* @example
|
|
679
668
|
* ```ts
|
|
680
669
|
* randomItem(['a', 'b', 'c']) // 'a' | 'b' | 'c'
|
|
670
|
+
* ```
|
|
681
671
|
*/
|
|
682
672
|
declare function randomItem<T>(array: T[]): T;
|
|
683
673
|
/**
|
|
@@ -688,6 +678,7 @@ declare function randomItem<T>(array: T[]): T;
|
|
|
688
678
|
* @example
|
|
689
679
|
* ```ts
|
|
690
680
|
* randomNumber(0, 100) // 0-100
|
|
681
|
+
* ```
|
|
691
682
|
*/
|
|
692
683
|
declare function randomNumber(min: number, max: number): number;
|
|
693
684
|
/**
|
|
@@ -700,9 +691,11 @@ declare function randomNumber(min: number, max: number): number;
|
|
|
700
691
|
* randomString() // 10 characters long
|
|
701
692
|
* randomString(20) // 20 characters long
|
|
702
693
|
* randomString(20, 'abcdefghijklmnopqrstuvwxyz') // 20 characters long
|
|
694
|
+
* ```
|
|
703
695
|
*/
|
|
704
696
|
declare function randomString(size?: number, chars?: string): string;
|
|
705
|
-
|
|
697
|
+
//#endregion
|
|
698
|
+
//#region src/util/serialized.d.ts
|
|
706
699
|
/**
|
|
707
700
|
* formData to object
|
|
708
701
|
* @param formData
|
|
@@ -737,7 +730,8 @@ declare function stringify(value: any): string;
|
|
|
737
730
|
* @returns The numberish value.
|
|
738
731
|
*/
|
|
739
732
|
declare function numberish(value: Numberish): string;
|
|
740
|
-
|
|
733
|
+
//#endregion
|
|
734
|
+
//#region src/util/to.d.ts
|
|
741
735
|
/**
|
|
742
736
|
* Convert a promise to a tuple of [error, data].
|
|
743
737
|
* @param promise - The promise to convert.
|
|
@@ -747,9 +741,11 @@ declare function numberish(value: Numberish): string;
|
|
|
747
741
|
* ```ts
|
|
748
742
|
* to(Promise.resolve('data')) // Promise<[null, 'data']>
|
|
749
743
|
* to(Promise.reject(new Error('error'))) // Promise<[Error, undefined]>
|
|
744
|
+
* ```
|
|
750
745
|
*/
|
|
751
746
|
declare function to<T, U = Error>(promise: Promise<T> | (() => Promise<T>), error?: object): Promise<[U, undefined] | [null, T]>;
|
|
752
|
-
|
|
747
|
+
//#endregion
|
|
748
|
+
//#region src/util/to-array.d.ts
|
|
753
749
|
/**
|
|
754
750
|
* Convert a value to an array.
|
|
755
751
|
* @param value - The value to convert.
|
|
@@ -759,23 +755,26 @@ declare function to<T, U = Error>(promise: Promise<T> | (() => Promise<T>), erro
|
|
|
759
755
|
* ```ts
|
|
760
756
|
* toArray(arrorOrItemOrUndefined) // item[] | undefined
|
|
761
757
|
* toArray(arrayOrItemOrUndefined, true) // item[]
|
|
758
|
+
* ```
|
|
762
759
|
*/
|
|
763
760
|
declare function toArray<T, R extends boolean>(value?: T | T[], required?: R): R extends true ? T[] : T[] | undefined;
|
|
764
|
-
|
|
761
|
+
//#endregion
|
|
762
|
+
//#region src/util/unit.d.ts
|
|
765
763
|
type Dimension = Numeric | [Numeric, Numeric] | {
|
|
766
|
-
|
|
767
|
-
|
|
764
|
+
width: Numeric;
|
|
765
|
+
height: Numeric;
|
|
768
766
|
};
|
|
769
767
|
declare function unit(value: Numeric, unit?: string): string;
|
|
770
768
|
declare function size(dimension: Dimension, unit?: string): {
|
|
771
|
-
|
|
772
|
-
|
|
769
|
+
width: string;
|
|
770
|
+
height: string;
|
|
773
771
|
};
|
|
774
|
-
|
|
772
|
+
//#endregion
|
|
773
|
+
//#region src/util/util.d.ts
|
|
775
774
|
/** @deprecated Use range instead */
|
|
776
775
|
declare const arange: {
|
|
777
|
-
|
|
778
|
-
|
|
776
|
+
(start: number, end?: number, step?: number): number[];
|
|
777
|
+
(end: number, index: string | number, guard: object): number[];
|
|
779
778
|
};
|
|
780
779
|
/**
|
|
781
780
|
* Select a value based on a condition.
|
|
@@ -805,6 +804,7 @@ declare const riposte: typeof select;
|
|
|
805
804
|
* ```ts
|
|
806
805
|
* unwrap({ name: 'John' }) // { name: 'John' }
|
|
807
806
|
* unwrap(() => { return { name: 'John' } }) // { name: 'John' }
|
|
807
|
+
* ```
|
|
808
808
|
*/
|
|
809
809
|
declare function unwrap<T extends object>(value: T | (() => T)): T;
|
|
810
810
|
/**
|
|
@@ -815,8 +815,9 @@ declare function unwrap<T extends object>(value: T | (() => T)): T;
|
|
|
815
815
|
* @example
|
|
816
816
|
* ```ts
|
|
817
817
|
* whenever(value, (value) => { return 'value' }) // value
|
|
818
|
+
* ```
|
|
818
819
|
*/
|
|
819
820
|
declare function whenever<T, C extends (value: Exclude<T, null | undefined>) => any>(value: T, callback: C): ReturnType<C> | undefined;
|
|
820
|
-
declare function call<T extends Fn
|
|
821
|
-
|
|
822
|
-
export {
|
|
821
|
+
declare function call<T extends Fn<any>>(fn: T, ...args: Parameters<T>): ReturnType<T>;
|
|
822
|
+
//#endregion
|
|
823
|
+
export { AnyFn, ArgumentsType, Arrayable, Assign, Awaitable, BIG_INTS, Bignumber, BooleanLike, BrowserNativeObject, ConstructorType, DEFAULT_BIGNUM_CONFIG, DecimalOptions, DeepKeyof, DeepMap, DeepMerge, DeepPartial, DeepReadonly, DeepReplace, DeepRequired, Deferred, Delimiter, Dimension, DynamicObject, ElementOf, Fn, FormatGroupOptions, FormatNumericOptions, Ghost, IfAny, IsAny, Key, Looper, MergeInsertions, NonUndefined, Noop, Nullable, NumberObject, Numberish, Numeric, NumericObject, OmitBy, OpenFilePickerOptions, OpenImagePickerOptions, Option, Overwrite, PickBy, PromiseFn, PromiseType, Promisify, Proxyed, ReaderType, StringObject, SymbolObject, arange, average, bignumber, call, camelCase, capitalCase, chunk, clone, cloneDeep, cloneDeepWith, cloneWith, compose, concat, constantCase, cover, debounce, decimal, delay, dialsPhone, divide, dotCase, downloadBlobFile, downloadNetworkFile, downloadUrlFile, ensurePrefix, ensureSuffix, find, formatNumeric, formdataToObject, get, ghost, groupBy, gt, gte, integer, isAndroid, isArguments, isArray, isArrayBuffer, isArrayLike, isArrayLikeObject, isBoolean, isBrowser, isBuffer, isChrome, isDate, isEdge, isElement, isEmpty, isEqual, isEqualWith, isError, isFF, isFormData, isFunction, isIE, isIE11, isIE9, isIOS, isInteger, isMap, isMatch, isMatchWith, isMobile, isNaN, isNative, isNull, isNumber, isObject, isObjectLike, isPhantomJS, isPlainObject, isRegexp, isSet, isString, isSymbol, isTruthy, isUndefined, isWeakMap, isWeakSet, isWeex, isWindow, join, kebabCase, keyBy, keys, loop, lt, lte, max, maxBy, merge, mergeWith, min, minBy, multiply, noCase, nonnanable, noop, numberify, numberish, objectToFormdata, off, omit, omitBy, on, once, openFilePicker, openImagePicker, parseNumeric, pascalCase, pascalSnakeCase, pathCase, percentage, pick, pickBy, pipe, plus, proxy, randomItem, randomNumber, randomString, range, readFileReader, redirectTo, riposte, select, selectImages, sentenceCase, set, shortenId, showOpenFilePicker, showOpenImagePicker, size, slash, snakeCase, stringify, template, to, toArray, trainCase, truncate, tryParseJson, unindent, uniq, uniqBy, uniqWith, unit, unwrap, values, whenever, zeroRemove, zerofill };
|