@hairy/utils 1.47.0 → 1.49.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 +21 -21
- package/README.md +36 -36
- package/dist/index.cjs +6854 -3720
- package/dist/{index.d.ts → index.d.cts} +177 -176
- package/dist/index.d.mts +823 -0
- package/dist/index.mjs +7148 -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
|
/**
|
|
@@ -240,47 +224,47 @@ declare const Bignumber: typeof _Bignumber;
|
|
|
240
224
|
* do not use Bignumber directly, use bignumber function instead
|
|
241
225
|
*/
|
|
242
226
|
declare const BIG_INTS: {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
227
|
+
t: {
|
|
228
|
+
v: number;
|
|
229
|
+
d: number;
|
|
230
|
+
n: string;
|
|
231
|
+
};
|
|
232
|
+
b: {
|
|
233
|
+
v: number;
|
|
234
|
+
d: number;
|
|
235
|
+
n: string;
|
|
236
|
+
};
|
|
237
|
+
m: {
|
|
238
|
+
v: number;
|
|
239
|
+
d: number;
|
|
240
|
+
n: string;
|
|
241
|
+
};
|
|
242
|
+
k: {
|
|
243
|
+
v: number;
|
|
244
|
+
d: number;
|
|
245
|
+
n: string;
|
|
246
|
+
};
|
|
263
247
|
};
|
|
264
248
|
type Delimiter = 'k' | 'm' | 'b' | 't';
|
|
265
249
|
interface DecimalOptions {
|
|
266
|
-
|
|
267
|
-
|
|
250
|
+
d?: number;
|
|
251
|
+
r?: Bignumber.RoundingMode;
|
|
268
252
|
}
|
|
269
253
|
interface FormatGroupOptions {
|
|
270
|
-
|
|
271
|
-
|
|
254
|
+
size?: number;
|
|
255
|
+
symbol?: string;
|
|
272
256
|
}
|
|
273
257
|
interface FormatNumericOptions {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
258
|
+
delimiters?: Delimiter[] | false;
|
|
259
|
+
rounding?: Bignumber.RoundingMode;
|
|
260
|
+
decimals?: number;
|
|
261
|
+
decimalsZero?: boolean;
|
|
262
|
+
default?: string;
|
|
263
|
+
format?: Bignumber.Format;
|
|
280
264
|
}
|
|
281
265
|
declare function bignumber(n?: Numberish, base?: number): _Bignumber;
|
|
282
266
|
declare namespace bignumber {
|
|
283
|
-
|
|
267
|
+
var clone: (config: Bignumber.Config) => typeof _Bignumber;
|
|
284
268
|
}
|
|
285
269
|
declare function gte(a: Numberish, b: Numberish): boolean;
|
|
286
270
|
declare function gt(a: Numberish, b: Numberish): boolean;
|
|
@@ -316,9 +300,9 @@ declare function integer(value: Numberish): string;
|
|
|
316
300
|
*/
|
|
317
301
|
declare function decimal(value: Numberish, n?: number): string;
|
|
318
302
|
declare function parseNumeric(num: Numberish, delimiters?: Delimiter[]): {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
303
|
+
v: number;
|
|
304
|
+
d: number;
|
|
305
|
+
n: string;
|
|
322
306
|
};
|
|
323
307
|
/**
|
|
324
308
|
* format number thousand separator and unit
|
|
@@ -326,7 +310,8 @@ declare function parseNumeric(num: Numberish, delimiters?: Delimiter[]): {
|
|
|
326
310
|
* @param options
|
|
327
311
|
*/
|
|
328
312
|
declare function formatNumeric(value?: Numberish, options?: FormatNumericOptions): string;
|
|
329
|
-
|
|
313
|
+
//#endregion
|
|
314
|
+
//#region src/string/index.d.ts
|
|
330
315
|
/**
|
|
331
316
|
* Intercept front and back characters, hide middle characters
|
|
332
317
|
* @param value
|
|
@@ -407,7 +392,8 @@ declare function template(str: string, ...args: (string | number | bigint | unde
|
|
|
407
392
|
* `
|
|
408
393
|
*/
|
|
409
394
|
declare function unindent(str: TemplateStringsArray | string): string;
|
|
410
|
-
|
|
395
|
+
//#endregion
|
|
396
|
+
//#region src/util/compose-promise.d.ts
|
|
411
397
|
type UF$1<VT, RT> = (value: VT) => RT | PromiseLike<RT>;
|
|
412
398
|
type Composed<VT, RT> = (value?: VT) => Promise<RT>;
|
|
413
399
|
/**
|
|
@@ -436,8 +422,9 @@ declare function pCompose<VT, R1, R2, R3, R4, R5, RT>(f1: UF$1<R5, RT>, f2: UF$1
|
|
|
436
422
|
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
423
|
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
424
|
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
|
-
|
|
425
|
+
//#endregion
|
|
426
|
+
//#region src/util/compose.d.ts
|
|
427
|
+
type Fn$1<V, R> = (x: V) => R;
|
|
441
428
|
type Q<T, V> = (...args: T) => V;
|
|
442
429
|
/**
|
|
443
430
|
* Performs function composition in RTL (Right To Left) direction.
|
|
@@ -473,20 +460,21 @@ type Q<T, V> = (...args: T) => V;
|
|
|
473
460
|
* @param ...fns - Iterated over sequentially when returned `function` is called.
|
|
474
461
|
* @returns The `fns` functions are applied from right to left.
|
|
475
462
|
*/
|
|
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>;
|
|
463
|
+
declare function compose<T, V0, V1>(fn1: Fn$1<V0, V1>, fn0: Q<T, V0>): Q<T, V1>;
|
|
464
|
+
declare function compose<T, V0, V1, V2>(fn2: Fn$1<V1, V2>, fn1: Fn$1<V0, V1>, fn0: Q<T, V0>): Q<T, V2>;
|
|
465
|
+
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>;
|
|
466
|
+
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>;
|
|
467
|
+
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>;
|
|
468
|
+
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>;
|
|
469
|
+
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>;
|
|
470
|
+
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>;
|
|
471
|
+
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>;
|
|
472
|
+
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
473
|
declare namespace compose {
|
|
487
|
-
|
|
474
|
+
var promise: typeof pCompose;
|
|
488
475
|
}
|
|
489
|
-
|
|
476
|
+
//#endregion
|
|
477
|
+
//#region src/util/deferred.d.ts
|
|
490
478
|
/**
|
|
491
479
|
* A deferred promise.
|
|
492
480
|
* @param T - The type of the value.
|
|
@@ -497,11 +485,12 @@ declare namespace compose {
|
|
|
497
485
|
* deferred.resolve('value')
|
|
498
486
|
*/
|
|
499
487
|
declare class Deferred<T> extends Promise<T> {
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
488
|
+
resolve: (value?: T) => Deferred<T>;
|
|
489
|
+
reject: (reason?: any) => Deferred<T>;
|
|
490
|
+
constructor(executor?: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void);
|
|
503
491
|
}
|
|
504
|
-
|
|
492
|
+
//#endregion
|
|
493
|
+
//#region src/util/delay.d.ts
|
|
505
494
|
/**
|
|
506
495
|
* Delay for a given number of milliseconds.
|
|
507
496
|
* @param ms - The number of milliseconds to delay.
|
|
@@ -511,9 +500,11 @@ declare class Deferred<T> extends Promise<T> {
|
|
|
511
500
|
* delay(1000).then(() => { console.log('1 second') })
|
|
512
501
|
*/
|
|
513
502
|
declare function delay(ms: number): Promise<void>;
|
|
514
|
-
|
|
503
|
+
//#endregion
|
|
504
|
+
//#region src/util/json.d.ts
|
|
515
505
|
declare function tryParseJson<T = any>(text: string | undefined | null): T | undefined;
|
|
516
|
-
|
|
506
|
+
//#endregion
|
|
507
|
+
//#region src/util/loop.d.ts
|
|
517
508
|
/**
|
|
518
509
|
* A function that performs a loop operation with delay control.
|
|
519
510
|
* @template T - The return type of the loop function (defaults to void)
|
|
@@ -551,32 +542,34 @@ declare function loop_return<T = void>(fn: Looper<T>): Promise<T>;
|
|
|
551
542
|
* console.log(result)
|
|
552
543
|
* ```
|
|
553
544
|
*/
|
|
554
|
-
declare function loop(fn: Looper<void>): Fn
|
|
545
|
+
declare function loop(fn: Looper<void>): Fn;
|
|
555
546
|
declare namespace loop {
|
|
556
|
-
|
|
557
|
-
|
|
547
|
+
var _a: typeof loop_return;
|
|
548
|
+
export { _a as return };
|
|
558
549
|
}
|
|
559
|
-
|
|
550
|
+
//#endregion
|
|
551
|
+
//#region src/util/noop.d.ts
|
|
560
552
|
declare const noop: (...args: any) => any;
|
|
561
|
-
|
|
553
|
+
//#endregion
|
|
554
|
+
//#region src/util/pipe-promise.d.ts
|
|
562
555
|
type UF<VT, RT> = (value: VT) => RT | PromiseLike<RT>;
|
|
563
556
|
type Pipeline<VT, RT> = (value?: VT) => Promise<RT>;
|
|
564
557
|
/**
|
|
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
|
-
```
|
|
558
|
+
* Compose promise-returning & async fns into a reusable pipeline.
|
|
559
|
+
*
|
|
560
|
+
* @param ...input - Iterated over sequentially when returned `function` is called.
|
|
561
|
+
* @returns The `input` fns are applied from left to right.
|
|
562
|
+
*
|
|
563
|
+
* @example
|
|
564
|
+
* ```
|
|
565
|
+
* const addUnicorn = async string => `${string} Unicorn`;
|
|
566
|
+
* const addRainbow = async string => `${string} Rainbow`;
|
|
567
|
+
*
|
|
568
|
+
* const pipeline = pipe.promise(addUnicorn, addRainbow);
|
|
569
|
+
*
|
|
570
|
+
* console.log(await pipeline('❤️'));
|
|
571
|
+
* //=> '❤️ Unicorn Rainbow'
|
|
572
|
+
* ```
|
|
580
573
|
*/
|
|
581
574
|
declare function pPipe<VT, RT>(f1: UF<VT, RT>): Pipeline<VT, RT>;
|
|
582
575
|
declare function pPipe<VT, R1, RT>(f1: UF<VT, R1>, f2: UF<R1, RT>): Pipeline<VT, RT>;
|
|
@@ -587,7 +580,8 @@ declare function pPipe<VT, R1, R2, R3, R4, R5, RT>(f1: UF<VT, R1>, f2: UF<R1, R2
|
|
|
587
580
|
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
581
|
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
582
|
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
|
-
|
|
583
|
+
//#endregion
|
|
584
|
+
//#region src/util/pipe.d.ts
|
|
591
585
|
/**
|
|
592
586
|
* Performs function composition in LTR (Left To Right) direction.
|
|
593
587
|
*
|
|
@@ -634,14 +628,15 @@ declare function pipe<Args extends unknown[], T0, T1, T2, T3, T4, T5, T6, T7>(..
|
|
|
634
628
|
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
629
|
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
630
|
declare namespace pipe {
|
|
637
|
-
|
|
631
|
+
var promise: typeof pPipe;
|
|
638
632
|
}
|
|
639
|
-
|
|
633
|
+
//#endregion
|
|
634
|
+
//#region src/util/proxy.d.ts
|
|
640
635
|
type Proxyed<T extends object, E extends object = {}> = T & {
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
636
|
+
proxy: {
|
|
637
|
+
update: (object?: T) => void;
|
|
638
|
+
source: T | undefined;
|
|
639
|
+
};
|
|
645
640
|
} & E;
|
|
646
641
|
/**
|
|
647
642
|
* Creates a proxy object that updates the original object when the proxy is updated.
|
|
@@ -668,9 +663,10 @@ type Proxyed<T extends object, E extends object = {}> = T & {
|
|
|
668
663
|
* ```
|
|
669
664
|
*/
|
|
670
665
|
declare function proxy<T extends object, E extends object = {}>(initObject?: T, initExtend?: E, options?: {
|
|
671
|
-
|
|
666
|
+
strictMessage?: string;
|
|
672
667
|
}): Proxyed<T, E>;
|
|
673
|
-
|
|
668
|
+
//#endregion
|
|
669
|
+
//#region src/util/random.d.ts
|
|
674
670
|
/**
|
|
675
671
|
* Get a random item from an array.
|
|
676
672
|
* @param array - The array to get a random item from.
|
|
@@ -702,7 +698,8 @@ declare function randomNumber(min: number, max: number): number;
|
|
|
702
698
|
* randomString(20, 'abcdefghijklmnopqrstuvwxyz') // 20 characters long
|
|
703
699
|
*/
|
|
704
700
|
declare function randomString(size?: number, chars?: string): string;
|
|
705
|
-
|
|
701
|
+
//#endregion
|
|
702
|
+
//#region src/util/serialized.d.ts
|
|
706
703
|
/**
|
|
707
704
|
* formData to object
|
|
708
705
|
* @param formData
|
|
@@ -737,7 +734,8 @@ declare function stringify(value: any): string;
|
|
|
737
734
|
* @returns The numberish value.
|
|
738
735
|
*/
|
|
739
736
|
declare function numberish(value: Numberish): string;
|
|
740
|
-
|
|
737
|
+
//#endregion
|
|
738
|
+
//#region src/util/to.d.ts
|
|
741
739
|
/**
|
|
742
740
|
* Convert a promise to a tuple of [error, data].
|
|
743
741
|
* @param promise - The promise to convert.
|
|
@@ -749,7 +747,8 @@ declare function numberish(value: Numberish): string;
|
|
|
749
747
|
* to(Promise.reject(new Error('error'))) // Promise<[Error, undefined]>
|
|
750
748
|
*/
|
|
751
749
|
declare function to<T, U = Error>(promise: Promise<T> | (() => Promise<T>), error?: object): Promise<[U, undefined] | [null, T]>;
|
|
752
|
-
|
|
750
|
+
//#endregion
|
|
751
|
+
//#region src/util/to-array.d.ts
|
|
753
752
|
/**
|
|
754
753
|
* Convert a value to an array.
|
|
755
754
|
* @param value - The value to convert.
|
|
@@ -761,21 +760,23 @@ declare function to<T, U = Error>(promise: Promise<T> | (() => Promise<T>), erro
|
|
|
761
760
|
* toArray(arrayOrItemOrUndefined, true) // item[]
|
|
762
761
|
*/
|
|
763
762
|
declare function toArray<T, R extends boolean>(value?: T | T[], required?: R): R extends true ? T[] : T[] | undefined;
|
|
764
|
-
|
|
763
|
+
//#endregion
|
|
764
|
+
//#region src/util/unit.d.ts
|
|
765
765
|
type Dimension = Numeric | [Numeric, Numeric] | {
|
|
766
|
-
|
|
767
|
-
|
|
766
|
+
width: Numeric;
|
|
767
|
+
height: Numeric;
|
|
768
768
|
};
|
|
769
769
|
declare function unit(value: Numeric, unit?: string): string;
|
|
770
770
|
declare function size(dimension: Dimension, unit?: string): {
|
|
771
|
-
|
|
772
|
-
|
|
771
|
+
width: string;
|
|
772
|
+
height: string;
|
|
773
773
|
};
|
|
774
|
-
|
|
774
|
+
//#endregion
|
|
775
|
+
//#region src/util/util.d.ts
|
|
775
776
|
/** @deprecated Use range instead */
|
|
776
777
|
declare const arange: {
|
|
777
|
-
|
|
778
|
-
|
|
778
|
+
(start: number, end?: number, step?: number): number[];
|
|
779
|
+
(end: number, index: string | number, guard: object): number[];
|
|
779
780
|
};
|
|
780
781
|
/**
|
|
781
782
|
* Select a value based on a condition.
|
|
@@ -817,6 +818,6 @@ declare function unwrap<T extends object>(value: T | (() => T)): T;
|
|
|
817
818
|
* whenever(value, (value) => { return 'value' }) // value
|
|
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, 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, 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 };
|