@hairy/utils 1.46.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 +6857 -3708
- package/dist/{index.d.ts → index.d.cts} +195 -181
- package/dist/index.d.mts +823 -0
- package/dist/index.mjs +7148 -0
- package/package.json +16 -17
- package/dist/index.global.js +0 -5179
- package/dist/index.js +0 -3992
|
@@ -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
|
|
@@ -334,6 +319,17 @@ declare function formatNumeric(value?: Numberish, options?: FormatNumericOptions
|
|
|
334
319
|
* @param symbol
|
|
335
320
|
*/
|
|
336
321
|
declare function cover(value: string, mode: [number, number, number], symbol?: string): string;
|
|
322
|
+
/**
|
|
323
|
+
* Shortens an identifier string by showing only the beginning and end portions,
|
|
324
|
+
* with ellipsis in the middle. Suitable for various types of identifiers like
|
|
325
|
+
* IPFS CID, transaction hashes, EVM addresses, user IDs, etc.
|
|
326
|
+
*
|
|
327
|
+
* @param value - The identifier string to shorten
|
|
328
|
+
* @param startWith - Number of characters to show at the start (default: 6)
|
|
329
|
+
* @param endWith - Number of characters to show at the end (default: 6)
|
|
330
|
+
* @returns Shortened identifier string with ellipsis, or empty string if id is null/undefined
|
|
331
|
+
*/
|
|
332
|
+
declare function shortenId(value: string | null | undefined, startWith?: number, endWith?: number): string;
|
|
337
333
|
/**
|
|
338
334
|
* Replace backslash to slash
|
|
339
335
|
*
|
|
@@ -396,7 +392,8 @@ declare function template(str: string, ...args: (string | number | bigint | unde
|
|
|
396
392
|
* `
|
|
397
393
|
*/
|
|
398
394
|
declare function unindent(str: TemplateStringsArray | string): string;
|
|
399
|
-
|
|
395
|
+
//#endregion
|
|
396
|
+
//#region src/util/compose-promise.d.ts
|
|
400
397
|
type UF$1<VT, RT> = (value: VT) => RT | PromiseLike<RT>;
|
|
401
398
|
type Composed<VT, RT> = (value?: VT) => Promise<RT>;
|
|
402
399
|
/**
|
|
@@ -425,8 +422,9 @@ declare function pCompose<VT, R1, R2, R3, R4, R5, RT>(f1: UF$1<R5, RT>, f2: UF$1
|
|
|
425
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>;
|
|
426
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>;
|
|
427
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>;
|
|
428
|
-
|
|
429
|
-
|
|
425
|
+
//#endregion
|
|
426
|
+
//#region src/util/compose.d.ts
|
|
427
|
+
type Fn$1<V, R> = (x: V) => R;
|
|
430
428
|
type Q<T, V> = (...args: T) => V;
|
|
431
429
|
/**
|
|
432
430
|
* Performs function composition in RTL (Right To Left) direction.
|
|
@@ -462,20 +460,21 @@ type Q<T, V> = (...args: T) => V;
|
|
|
462
460
|
* @param ...fns - Iterated over sequentially when returned `function` is called.
|
|
463
461
|
* @returns The `fns` functions are applied from right to left.
|
|
464
462
|
*/
|
|
465
|
-
declare function compose<T, V0, V1>(fn1: Fn<V0, V1>, fn0: Q<T, V0>): Q<T, V1>;
|
|
466
|
-
declare function compose<T, V0, V1, V2>(fn2: Fn<V1, V2>, fn1: Fn<V0, V1>, fn0: Q<T, V0>): Q<T, V2>;
|
|
467
|
-
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>;
|
|
468
|
-
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>;
|
|
469
|
-
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>;
|
|
470
|
-
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>;
|
|
471
|
-
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>;
|
|
472
|
-
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>;
|
|
473
|
-
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>;
|
|
474
|
-
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>;
|
|
475
473
|
declare namespace compose {
|
|
476
|
-
|
|
474
|
+
var promise: typeof pCompose;
|
|
477
475
|
}
|
|
478
|
-
|
|
476
|
+
//#endregion
|
|
477
|
+
//#region src/util/deferred.d.ts
|
|
479
478
|
/**
|
|
480
479
|
* A deferred promise.
|
|
481
480
|
* @param T - The type of the value.
|
|
@@ -486,11 +485,12 @@ declare namespace compose {
|
|
|
486
485
|
* deferred.resolve('value')
|
|
487
486
|
*/
|
|
488
487
|
declare class Deferred<T> extends Promise<T> {
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
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);
|
|
492
491
|
}
|
|
493
|
-
|
|
492
|
+
//#endregion
|
|
493
|
+
//#region src/util/delay.d.ts
|
|
494
494
|
/**
|
|
495
495
|
* Delay for a given number of milliseconds.
|
|
496
496
|
* @param ms - The number of milliseconds to delay.
|
|
@@ -500,9 +500,11 @@ declare class Deferred<T> extends Promise<T> {
|
|
|
500
500
|
* delay(1000).then(() => { console.log('1 second') })
|
|
501
501
|
*/
|
|
502
502
|
declare function delay(ms: number): Promise<void>;
|
|
503
|
-
|
|
503
|
+
//#endregion
|
|
504
|
+
//#region src/util/json.d.ts
|
|
504
505
|
declare function tryParseJson<T = any>(text: string | undefined | null): T | undefined;
|
|
505
|
-
|
|
506
|
+
//#endregion
|
|
507
|
+
//#region src/util/loop.d.ts
|
|
506
508
|
/**
|
|
507
509
|
* A function that performs a loop operation with delay control.
|
|
508
510
|
* @template T - The return type of the loop function (defaults to void)
|
|
@@ -540,32 +542,34 @@ declare function loop_return<T = void>(fn: Looper<T>): Promise<T>;
|
|
|
540
542
|
* console.log(result)
|
|
541
543
|
* ```
|
|
542
544
|
*/
|
|
543
|
-
declare function loop(fn: Looper<void>): Fn
|
|
545
|
+
declare function loop(fn: Looper<void>): Fn;
|
|
544
546
|
declare namespace loop {
|
|
545
|
-
|
|
546
|
-
|
|
547
|
+
var _a: typeof loop_return;
|
|
548
|
+
export { _a as return };
|
|
547
549
|
}
|
|
548
|
-
|
|
550
|
+
//#endregion
|
|
551
|
+
//#region src/util/noop.d.ts
|
|
549
552
|
declare const noop: (...args: any) => any;
|
|
550
|
-
|
|
553
|
+
//#endregion
|
|
554
|
+
//#region src/util/pipe-promise.d.ts
|
|
551
555
|
type UF<VT, RT> = (value: VT) => RT | PromiseLike<RT>;
|
|
552
556
|
type Pipeline<VT, RT> = (value?: VT) => Promise<RT>;
|
|
553
557
|
/**
|
|
554
|
-
Compose promise-returning & async fns into a reusable pipeline.
|
|
555
|
-
|
|
556
|
-
@param ...input - Iterated over sequentially when returned `function` is called.
|
|
557
|
-
@returns The `input` fns are applied from left to right.
|
|
558
|
-
|
|
559
|
-
@example
|
|
560
|
-
```
|
|
561
|
-
const addUnicorn = async string => `${string} Unicorn`;
|
|
562
|
-
const addRainbow = async string => `${string} Rainbow`;
|
|
563
|
-
|
|
564
|
-
const pipeline = pipe.promise(addUnicorn, addRainbow);
|
|
565
|
-
|
|
566
|
-
console.log(await pipeline('❤️'));
|
|
567
|
-
//=> '❤️ Unicorn Rainbow'
|
|
568
|
-
```
|
|
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
|
+
* ```
|
|
569
573
|
*/
|
|
570
574
|
declare function pPipe<VT, RT>(f1: UF<VT, RT>): Pipeline<VT, RT>;
|
|
571
575
|
declare function pPipe<VT, R1, RT>(f1: UF<VT, R1>, f2: UF<R1, RT>): Pipeline<VT, RT>;
|
|
@@ -576,7 +580,8 @@ declare function pPipe<VT, R1, R2, R3, R4, R5, RT>(f1: UF<VT, R1>, f2: UF<R1, R2
|
|
|
576
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>;
|
|
577
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>;
|
|
578
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>;
|
|
579
|
-
|
|
583
|
+
//#endregion
|
|
584
|
+
//#region src/util/pipe.d.ts
|
|
580
585
|
/**
|
|
581
586
|
* Performs function composition in LTR (Left To Right) direction.
|
|
582
587
|
*
|
|
@@ -623,15 +628,16 @@ declare function pipe<Args extends unknown[], T0, T1, T2, T3, T4, T5, T6, T7>(..
|
|
|
623
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;
|
|
624
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;
|
|
625
630
|
declare namespace pipe {
|
|
626
|
-
|
|
631
|
+
var promise: typeof pPipe;
|
|
627
632
|
}
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
};
|
|
633
|
+
//#endregion
|
|
634
|
+
//#region src/util/proxy.d.ts
|
|
635
|
+
type Proxyed<T extends object, E extends object = {}> = T & {
|
|
636
|
+
proxy: {
|
|
637
|
+
update: (object?: T) => void;
|
|
638
|
+
source: T | undefined;
|
|
639
|
+
};
|
|
640
|
+
} & E;
|
|
635
641
|
/**
|
|
636
642
|
* Creates a proxy object that updates the original object when the proxy is updated.
|
|
637
643
|
* @param initObject - The initial object to proxy.
|
|
@@ -642,22 +648,25 @@ type Proxyed<T extends object> = T & {
|
|
|
642
648
|
* const obj = proxy({ name: 'John' })
|
|
643
649
|
* console.log(obj.name) // John
|
|
644
650
|
*
|
|
645
|
-
* proxy.update({ name: 'Jane' })
|
|
651
|
+
* obj.proxy.update({ name: 'Jane' })
|
|
646
652
|
* console.log(obj.name) // Jane
|
|
647
653
|
*
|
|
648
654
|
* const obj2 = proxy()
|
|
649
655
|
*
|
|
650
656
|
* obj2.any // Error: Proxy not updated. Call object.proxy.update() to update the proxy.
|
|
651
657
|
*
|
|
652
|
-
* proxy.
|
|
658
|
+
* obj2.proxy.source // undefined
|
|
653
659
|
* obj2.update({ name: 'John' })
|
|
654
660
|
*
|
|
655
661
|
* // get the original object
|
|
656
|
-
* proxy.
|
|
662
|
+
* obj2.proxy.source // { name: 'John' }
|
|
657
663
|
* ```
|
|
658
664
|
*/
|
|
659
|
-
declare function proxy<T extends object>(initObject?: T
|
|
660
|
-
|
|
665
|
+
declare function proxy<T extends object, E extends object = {}>(initObject?: T, initExtend?: E, options?: {
|
|
666
|
+
strictMessage?: string;
|
|
667
|
+
}): Proxyed<T, E>;
|
|
668
|
+
//#endregion
|
|
669
|
+
//#region src/util/random.d.ts
|
|
661
670
|
/**
|
|
662
671
|
* Get a random item from an array.
|
|
663
672
|
* @param array - The array to get a random item from.
|
|
@@ -689,7 +698,8 @@ declare function randomNumber(min: number, max: number): number;
|
|
|
689
698
|
* randomString(20, 'abcdefghijklmnopqrstuvwxyz') // 20 characters long
|
|
690
699
|
*/
|
|
691
700
|
declare function randomString(size?: number, chars?: string): string;
|
|
692
|
-
|
|
701
|
+
//#endregion
|
|
702
|
+
//#region src/util/serialized.d.ts
|
|
693
703
|
/**
|
|
694
704
|
* formData to object
|
|
695
705
|
* @param formData
|
|
@@ -724,7 +734,8 @@ declare function stringify(value: any): string;
|
|
|
724
734
|
* @returns The numberish value.
|
|
725
735
|
*/
|
|
726
736
|
declare function numberish(value: Numberish): string;
|
|
727
|
-
|
|
737
|
+
//#endregion
|
|
738
|
+
//#region src/util/to.d.ts
|
|
728
739
|
/**
|
|
729
740
|
* Convert a promise to a tuple of [error, data].
|
|
730
741
|
* @param promise - The promise to convert.
|
|
@@ -736,7 +747,8 @@ declare function numberish(value: Numberish): string;
|
|
|
736
747
|
* to(Promise.reject(new Error('error'))) // Promise<[Error, undefined]>
|
|
737
748
|
*/
|
|
738
749
|
declare function to<T, U = Error>(promise: Promise<T> | (() => Promise<T>), error?: object): Promise<[U, undefined] | [null, T]>;
|
|
739
|
-
|
|
750
|
+
//#endregion
|
|
751
|
+
//#region src/util/to-array.d.ts
|
|
740
752
|
/**
|
|
741
753
|
* Convert a value to an array.
|
|
742
754
|
* @param value - The value to convert.
|
|
@@ -748,21 +760,23 @@ declare function to<T, U = Error>(promise: Promise<T> | (() => Promise<T>), erro
|
|
|
748
760
|
* toArray(arrayOrItemOrUndefined, true) // item[]
|
|
749
761
|
*/
|
|
750
762
|
declare function toArray<T, R extends boolean>(value?: T | T[], required?: R): R extends true ? T[] : T[] | undefined;
|
|
751
|
-
|
|
763
|
+
//#endregion
|
|
764
|
+
//#region src/util/unit.d.ts
|
|
752
765
|
type Dimension = Numeric | [Numeric, Numeric] | {
|
|
753
|
-
|
|
754
|
-
|
|
766
|
+
width: Numeric;
|
|
767
|
+
height: Numeric;
|
|
755
768
|
};
|
|
756
769
|
declare function unit(value: Numeric, unit?: string): string;
|
|
757
770
|
declare function size(dimension: Dimension, unit?: string): {
|
|
758
|
-
|
|
759
|
-
|
|
771
|
+
width: string;
|
|
772
|
+
height: string;
|
|
760
773
|
};
|
|
761
|
-
|
|
774
|
+
//#endregion
|
|
775
|
+
//#region src/util/util.d.ts
|
|
762
776
|
/** @deprecated Use range instead */
|
|
763
777
|
declare const arange: {
|
|
764
|
-
|
|
765
|
-
|
|
778
|
+
(start: number, end?: number, step?: number): number[];
|
|
779
|
+
(end: number, index: string | number, guard: object): number[];
|
|
766
780
|
};
|
|
767
781
|
/**
|
|
768
782
|
* Select a value based on a condition.
|
|
@@ -804,6 +818,6 @@ declare function unwrap<T extends object>(value: T | (() => T)): T;
|
|
|
804
818
|
* whenever(value, (value) => { return 'value' }) // value
|
|
805
819
|
*/
|
|
806
820
|
declare function whenever<T, C extends (value: Exclude<T, null | undefined>) => any>(value: T, callback: C): ReturnType<C> | undefined;
|
|
807
|
-
declare function call<T extends Fn
|
|
808
|
-
|
|
809
|
-
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 };
|