@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.
@@ -0,0 +1,823 @@
1
+ import _Bignumber from "bignumber.js";
2
+ 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";
3
+
4
+ //#region src/browser/file.d.ts
5
+ interface OpenFilePickerOptions {
6
+ /**
7
+ * select multiple files
8
+ */
9
+ multiple?: boolean;
10
+ /**
11
+ * Choose the default format for the file
12
+ */
13
+ accept?: string;
14
+ }
15
+ /**
16
+ * Select multiple files
17
+ */
18
+ declare function openFilePicker(option?: OpenFilePickerOptions): Promise<File[]>;
19
+ /** @deprecated use openFilePicker */
20
+ declare const showOpenFilePicker: typeof openFilePicker;
21
+ interface OpenImagePickerOptions {
22
+ /**
23
+ * select multiple images
24
+ */
25
+ multiple?: boolean;
26
+ }
27
+ /**
28
+ * Select multiple images
29
+ */
30
+ declare function openImagePicker(options?: OpenImagePickerOptions): Promise<File[]>;
31
+ /** @deprecated use openImagePicker */
32
+ declare const selectImages: typeof openImagePicker;
33
+ declare const showOpenImagePicker: typeof openImagePicker;
34
+ /**
35
+ * Generate Blob | string file and download it
36
+ * @param data Blob data, or string
37
+ * @param name file name
38
+ */
39
+ declare function downloadBlobFile(data: Blob | string, name: string): void;
40
+ /**
41
+ * Download network files
42
+ * @param url Download link
43
+ * @param name file name
44
+ */
45
+ declare function downloadUrlFile(url: string, name?: string): void;
46
+ /** @deprecated use downloadUrlFile */
47
+ declare const downloadNetworkFile: typeof downloadUrlFile;
48
+ type ReaderType = 'readAsArrayBuffer' | 'readAsBinaryString' | 'readAsDataURL' | 'readAsText';
49
+ /**
50
+ * Read File file
51
+ * @param formType Transform type
52
+ * @param file file object
53
+ */
54
+ declare function readFileReader<T extends ReaderType>(formType: T, file: File): Promise<T extends "readAsArrayBuffer" ? ArrayBuffer : string>;
55
+ //#endregion
56
+ //#region src/typings/atom.d.ts
57
+ type Numeric = string | number | bigint;
58
+ type Numberish = Numeric | {
59
+ toString: (...args: any[]) => string;
60
+ } | undefined | null;
61
+ interface DynamicObject {
62
+ [key: string]: any;
63
+ }
64
+ interface NumericObject {
65
+ [key: string]: Numeric;
66
+ }
67
+ interface StringObject {
68
+ [key: string]: string;
69
+ }
70
+ interface NumberObject {
71
+ [key: string]: string;
72
+ }
73
+ interface SymbolObject {
74
+ [key: string]: symbol;
75
+ }
76
+ type Key = string | number | symbol;
77
+ type BooleanLike = any;
78
+ type Noop = (...args: any[]) => any;
79
+ //#endregion
80
+ //#region src/typings/util.d.ts
81
+ /**
82
+ * Any type that can be used where a big number is needed.
83
+ */
84
+ type Awaitable<T> = T | PromiseLike<T>;
85
+ type Arrayable<T> = T | T[];
86
+ type Promisify<T> = Promise<Awaited<T>>;
87
+ type ElementOf<T> = T extends (infer E)[] ? E : never;
88
+ type Nullable<T> = T | null | undefined;
89
+ type Fn<T = void> = () => T;
90
+ type AnyFn = (...args: any[]) => any;
91
+ type PromiseFn = (...args: any[]) => Promise<any>;
92
+ type IfAny<T, Y, N> = 0 extends 1 & T ? Y : N;
93
+ type IsAny<T> = IfAny<T, true, false>;
94
+ type ConstructorType<T = void> = new (...args: any[]) => T;
95
+ type ArgumentsType<T> = T extends ((...args: infer A) => any) ? A : never;
96
+ type PromiseType<P extends PromiseLike<any>> = P extends PromiseLike<infer T> ? T : never;
97
+ type BrowserNativeObject = Date | FileList | File;
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] };
101
+ type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;
102
+ type Assign<T, U> = Omit<T, keyof U> & U;
103
+ type NonUndefined<T> = T extends undefined ? never : T;
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> };
110
+ type DeepKeyof<T> = T extends object ? keyof T | DeepKeyof<T[keyof T]> : never;
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
116
+ declare function redirectTo(url: string, target?: string): void;
117
+ declare function dialsPhone(phoneNumber: string): void;
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
122
+ declare const isBrowser: () => boolean;
123
+ declare const isWeex: () => boolean;
124
+ declare const isIE: () => boolean | "";
125
+ declare const isIE9: () => boolean | "";
126
+ declare const isIE11: () => boolean;
127
+ declare const isEdge: () => boolean | "";
128
+ declare const isAndroid: () => boolean;
129
+ declare const isIOS: () => boolean;
130
+ declare const isChrome: () => boolean | "";
131
+ declare const isPhantomJS: () => boolean | "";
132
+ declare const isFF: () => false | RegExpMatchArray | null;
133
+ declare const isMobile: () => boolean;
134
+ declare const isFormData: (value: any) => value is FormData;
135
+ declare const isWindow: (value: any) => value is Window;
136
+ declare const isTruthy: <T>(value: T) => value is NonNullable<T>;
137
+ //#endregion
138
+ //#region ../../node_modules/.pnpm/change-case@5.4.4/node_modules/change-case/dist/index.d.ts
139
+ /**
140
+ * Supported locale values. Use `false` to ignore locale.
141
+ * Defaults to `undefined`, which uses the host environment.
142
+ */
143
+ type Locale = string[] | string | false | undefined;
144
+ /**
145
+ * Options used for converting strings to pascal/camel case.
146
+ */
147
+ interface PascalCaseOptions extends Options {
148
+ mergeAmbiguousCharacters?: boolean;
149
+ }
150
+ /**
151
+ * Options used for converting strings to any case.
152
+ */
153
+ interface Options {
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;
161
+ }
162
+ /**
163
+ * Convert a string to space separated lower case (`foo bar`).
164
+ */
165
+ declare function noCase(input: string, options?: Options): string;
166
+ /**
167
+ * Convert a string to camel case (`fooBar`).
168
+ */
169
+ declare function camelCase(input: string, options?: PascalCaseOptions): string;
170
+ /**
171
+ * Convert a string to pascal case (`FooBar`).
172
+ */
173
+ declare function pascalCase(input: string, options?: PascalCaseOptions): string;
174
+ /**
175
+ * Convert a string to pascal snake case (`Foo_Bar`).
176
+ */
177
+ declare function pascalSnakeCase(input: string, options?: Options): string;
178
+ /**
179
+ * Convert a string to capital case (`Foo Bar`).
180
+ */
181
+ declare function capitalCase(input: string, options?: Options): string;
182
+ /**
183
+ * Convert a string to constant case (`FOO_BAR`).
184
+ */
185
+ declare function constantCase(input: string, options?: Options): string;
186
+ /**
187
+ * Convert a string to dot case (`foo.bar`).
188
+ */
189
+ declare function dotCase(input: string, options?: Options): string;
190
+ /**
191
+ * Convert a string to kebab case (`foo-bar`).
192
+ */
193
+ declare function kebabCase(input: string, options?: Options): string;
194
+ /**
195
+ * Convert a string to path case (`foo/bar`).
196
+ */
197
+ declare function pathCase(input: string, options?: Options): string;
198
+ /**
199
+ * Convert a string to path case (`Foo bar`).
200
+ */
201
+ declare function sentenceCase(input: string, options?: Options): string;
202
+ /**
203
+ * Convert a string to snake case (`foo_bar`).
204
+ */
205
+ declare function snakeCase(input: string, options?: Options): string;
206
+ /**
207
+ * Convert a string to header case (`Foo-Bar`).
208
+ */
209
+ declare function trainCase(input: string, options?: Options): string;
210
+ //#endregion
211
+ //#region src/number/index.d.ts
212
+ declare const DEFAULT_BIGNUM_CONFIG: _Bignumber.Config;
213
+ declare namespace Bignumber {
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;
219
+ }
220
+ declare const Bignumber: typeof _Bignumber;
221
+ /**
222
+ * export bignumber.js
223
+ *
224
+ * do not use Bignumber directly, use bignumber function instead
225
+ */
226
+ declare const BIG_INTS: {
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
+ };
247
+ };
248
+ type Delimiter = 'k' | 'm' | 'b' | 't';
249
+ interface DecimalOptions {
250
+ d?: number;
251
+ r?: Bignumber.RoundingMode;
252
+ }
253
+ interface FormatGroupOptions {
254
+ size?: number;
255
+ symbol?: string;
256
+ }
257
+ interface FormatNumericOptions {
258
+ delimiters?: Delimiter[] | false;
259
+ rounding?: Bignumber.RoundingMode;
260
+ decimals?: number;
261
+ decimalsZero?: boolean;
262
+ default?: string;
263
+ format?: Bignumber.Format;
264
+ }
265
+ declare function bignumber(n?: Numberish, base?: number): _Bignumber;
266
+ declare namespace bignumber {
267
+ var clone: (config: Bignumber.Config) => typeof _Bignumber;
268
+ }
269
+ declare function gte(a: Numberish, b: Numberish): boolean;
270
+ declare function gt(a: Numberish, b: Numberish): boolean;
271
+ declare function lte(a: Numberish, b: Numberish): boolean;
272
+ declare function lt(a: Numberish, b: Numberish): boolean;
273
+ declare function plus(array: Numberish[], options?: DecimalOptions): string;
274
+ declare function divide(array: Numberish[], options?: DecimalOptions): string;
275
+ declare function multiply(array: Numberish[], options?: DecimalOptions): string;
276
+ declare function average(array: Numberish[], options?: DecimalOptions): string;
277
+ /**
278
+ * calculate percentage
279
+ * @param total
280
+ * @param count
281
+ */
282
+ declare function percentage(total: Numberish, count: Numberish, options?: DecimalOptions): string;
283
+ /**
284
+ * leading zeros
285
+ * @param value
286
+ * @param n
287
+ * @param type
288
+ */
289
+ declare function zerofill(value: Numberish, n?: number, type?: 'positive' | 'reverse'): Numberish;
290
+ declare function zeroRemove(value: Numberish, convert?: boolean): string;
291
+ /**
292
+ * format as a positive integer
293
+ * @param value
294
+ */
295
+ declare function integer(value: Numberish): string;
296
+ /**
297
+ * retain n decimal places
298
+ * @param value
299
+ * @param n
300
+ */
301
+ declare function decimal(value: Numberish, n?: number): string;
302
+ declare function parseNumeric(num: Numberish, delimiters?: Delimiter[]): {
303
+ v: number;
304
+ d: number;
305
+ n: string;
306
+ };
307
+ /**
308
+ * format number thousand separator and unit
309
+ * @param value
310
+ * @param options
311
+ */
312
+ declare function formatNumeric(value?: Numberish, options?: FormatNumericOptions): string;
313
+ //#endregion
314
+ //#region src/string/index.d.ts
315
+ /**
316
+ * Intercept front and back characters, hide middle characters
317
+ * @param value
318
+ * @param mode
319
+ * @param symbol
320
+ */
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;
333
+ /**
334
+ * Replace backslash to slash
335
+ *
336
+ * @category String
337
+ */
338
+ declare function slash(str: string): string;
339
+ /**
340
+ * Ensure prefix of a string
341
+ *
342
+ * @category String
343
+ */
344
+ declare function ensurePrefix(prefix: string, str: string): string;
345
+ /**
346
+ * Ensure suffix of a string
347
+ *
348
+ * @category String
349
+ */
350
+ declare function ensureSuffix(suffix: string, str: string): string;
351
+ /**
352
+ * Dead simple template engine, just like Python's `.format()`
353
+ * Support passing variables as either in index based or object/name based approach
354
+ * While using object/name based approach, you can pass a fallback value as the third argument
355
+ *
356
+ * @category String
357
+ * @example
358
+ * ```
359
+ * const result = template(
360
+ * 'Hello {0}! My name is {1}.',
361
+ * 'Inès',
362
+ * 'Anthony'
363
+ * ) // Hello Inès! My name is Anthony.
364
+ * ```
365
+ *
366
+ * ```
367
+ * const result = namedTemplate(
368
+ * '{greet}! My name is {name}.',
369
+ * { greet: 'Hello', name: 'Anthony' }
370
+ * ) // Hello! My name is Anthony.
371
+ * ```
372
+ *
373
+ * const result = namedTemplate(
374
+ * '{greet}! My name is {name}.',
375
+ * { greet: 'Hello' }, // name isn't passed hence fallback will be used for name
376
+ * 'placeholder'
377
+ * ) // Hello! My name is placeholder.
378
+ * ```
379
+ */
380
+ declare function template(str: string, object: Record<string | number, any>, fallback?: string | ((key: string) => string)): string;
381
+ declare function template(str: string, ...args: (string | number | bigint | undefined | null)[]): string;
382
+ /**
383
+ * Remove common leading whitespace from a template string.
384
+ * Will also remove empty lines at the beginning and end.
385
+ * @category string
386
+ * @example
387
+ * ```ts
388
+ * const str = unindent`
389
+ * if (a) {
390
+ * b()
391
+ * }
392
+ * `
393
+ */
394
+ declare function unindent(str: TemplateStringsArray | string): string;
395
+ //#endregion
396
+ //#region src/util/compose-promise.d.ts
397
+ type UF$1<VT, RT> = (value: VT) => RT | PromiseLike<RT>;
398
+ type Composed<VT, RT> = (value?: VT) => Promise<RT>;
399
+ /**
400
+ * Compose promise-returning & async fns into a reusable pipeline.
401
+ *
402
+ * @param ...fns - Iterated over sequentially when returned `function` is called.
403
+ * @returns The `fns` are applied from right to left.
404
+ *
405
+ * @example
406
+ * ```
407
+ * const addUnicorn = async string => `${string} Unicorn`;
408
+ * const addRainbow = async string => `${string} Rainbow`;
409
+ *
410
+ * const pipeline = pCompose(addRainbow, addUnicorn);
411
+ *
412
+ * console.log(await pipeline('❤️'));
413
+ * //=> '❤️ Unicorn Rainbow'
414
+ * ```
415
+ */
416
+ declare function pCompose<VT, RT>(f1: UF$1<VT, RT>): Composed<VT, RT>;
417
+ declare function pCompose<VT, R1, RT>(f1: UF$1<R1, RT>, f2: UF$1<VT, R1>): Composed<VT, RT>;
418
+ declare function pCompose<VT, R1, R2, RT>(f1: UF$1<R2, RT>, f2: UF$1<R1, R2>, f3: UF$1<VT, R1>): Composed<VT, RT>;
419
+ declare function pCompose<VT, R1, R2, R3, RT>(f1: UF$1<R3, RT>, f2: UF$1<R2, R3>, f3: UF$1<R1, R2>, f4: UF$1<VT, R1>): Composed<VT, RT>;
420
+ declare function pCompose<VT, R1, R2, R3, R4, RT>(f1: UF$1<R4, RT>, f2: UF$1<R3, R4>, f3: UF$1<R2, R3>, f4: UF$1<R1, R2>, f5: UF$1<VT, R1>): Composed<VT, RT>;
421
+ declare function pCompose<VT, R1, R2, R3, R4, R5, RT>(f1: UF$1<R5, RT>, f2: UF$1<R4, R5>, f3: UF$1<R3, R4>, f4: UF$1<R2, R3>, f5: UF$1<R1, R2>, f6: UF$1<VT, R1>): Composed<VT, RT>;
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>;
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>;
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>;
425
+ //#endregion
426
+ //#region src/util/compose.d.ts
427
+ type Fn$1<V, R> = (x: V) => R;
428
+ type Q<T, V> = (...args: T) => V;
429
+ /**
430
+ * Performs function composition in RTL (Right To Left) direction.
431
+ *
432
+ * Our `compose` and `compose.promise` implementation supports N arguments. But you can use only 10 in
433
+ * TypeScript, because it doesn't support **Variadic Kinds** and we explicitly
434
+ * have to define the type of all the possible usages as method overloads.
435
+ *
436
+ * @example
437
+ * const normalizeWhiteSpaces = text => name.replace(/\s+/g, ' ').trim();
438
+ *
439
+ * const getInitials = compose(
440
+ * initials => initials.join('').toLocaleUpperCase(),
441
+ * name => name.split(' ').map(name => name.charAt(0)),
442
+ * normalizeWhiteSpaces
443
+ * );
444
+ *
445
+ * getInitials('Vitor Luiz Cavalcanti');
446
+ * //=> "VLC"
447
+ *
448
+ * @param fn - An arity 1 function, except the last one which can have arity N.
449
+ * @param fns - Functions of arity 1. Each one's result is next's argument.
450
+ *
451
+ * @example
452
+ *
453
+ * const addUnicorn = async string => `${string} Unicorn`;
454
+ * const addRainbow = async string => `${string} Rainbow`;
455
+ *
456
+ * const pipeline = compose.promise(addRainbow, addUnicorn);
457
+ *
458
+ * console.log(await pipeline('❤️'));
459
+ * //=> '❤️ Unicorn Rainbow'
460
+ * @param ...fns - Iterated over sequentially when returned `function` is called.
461
+ * @returns The `fns` functions are applied from right to left.
462
+ */
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>;
473
+ declare namespace compose {
474
+ var promise: typeof pCompose;
475
+ }
476
+ //#endregion
477
+ //#region src/util/deferred.d.ts
478
+ /**
479
+ * A deferred promise.
480
+ * @param T - The type of the value.
481
+ * @returns The deferred promise.
482
+ * @example
483
+ * ```ts
484
+ * const deferred = new Deferred()
485
+ * deferred.resolve('value')
486
+ */
487
+ declare class Deferred<T> extends Promise<T> {
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);
491
+ }
492
+ //#endregion
493
+ //#region src/util/delay.d.ts
494
+ /**
495
+ * Delay for a given number of milliseconds.
496
+ * @param ms - The number of milliseconds to delay.
497
+ * @returns A promise that resolves after the given number of milliseconds.
498
+ * @example
499
+ * ```ts
500
+ * delay(1000).then(() => { console.log('1 second') })
501
+ */
502
+ declare function delay(ms: number): Promise<void>;
503
+ //#endregion
504
+ //#region src/util/json.d.ts
505
+ declare function tryParseJson<T = any>(text: string | undefined | null): T | undefined;
506
+ //#endregion
507
+ //#region src/util/loop.d.ts
508
+ /**
509
+ * A function that performs a loop operation with delay control.
510
+ * @template T - The return type of the loop function (defaults to void)
511
+ * @param next - A function that schedules the next iteration after a delay (in milliseconds)
512
+ * @returns A promise that resolves with the result of type T
513
+ */
514
+ type Looper<T = void> = (next: (ms: number) => Promise<T>) => Promise<T>;
515
+ declare function loop_return<T = void>(fn: Looper<T>): Promise<T>;
516
+ /**
517
+ * Creates a cancellable loop that executes repeatedly with delays.
518
+ * Returns a cancel function that can be called to stop the loop.
519
+ * The loop will not execute further iterations after cancellation.
520
+ *
521
+ * @param fn - The loop function that receives a `next` callback to schedule the next iteration
522
+ * @returns A cancel function that stops the loop when called
523
+ *
524
+ * @example loop
525
+ * ```ts
526
+ * const cancel = loop(async (next) => {
527
+ * console.log('tick')
528
+ * await next(1000) // Wait 1 second before next iteration
529
+ * })
530
+ *
531
+ * // Stop the loop after 5 seconds
532
+ * setTimeout(cancel, 5000)
533
+ *```
534
+ * @example loop.return
535
+ * ```ts
536
+ * const result = await loop.return(async (next) => {
537
+ * if (condition) {
538
+ * return 'done'
539
+ * }
540
+ * await next(1000)
541
+ * })
542
+ * console.log(result)
543
+ * ```
544
+ */
545
+ declare function loop(fn: Looper<void>): Fn;
546
+ declare namespace loop {
547
+ var _a: typeof loop_return;
548
+ export { _a as return };
549
+ }
550
+ //#endregion
551
+ //#region src/util/noop.d.ts
552
+ declare const noop: (...args: any) => any;
553
+ //#endregion
554
+ //#region src/util/pipe-promise.d.ts
555
+ type UF<VT, RT> = (value: VT) => RT | PromiseLike<RT>;
556
+ type Pipeline<VT, RT> = (value?: VT) => Promise<RT>;
557
+ /**
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
+ * ```
573
+ */
574
+ declare function pPipe<VT, RT>(f1: UF<VT, RT>): Pipeline<VT, RT>;
575
+ declare function pPipe<VT, R1, RT>(f1: UF<VT, R1>, f2: UF<R1, RT>): Pipeline<VT, RT>;
576
+ declare function pPipe<VT, R1, R2, RT>(f1: UF<VT, R1>, f2: UF<R1, R2>, f3: UF<R2, RT>): Pipeline<VT, RT>;
577
+ declare function pPipe<VT, R1, R2, R3, RT>(f1: UF<VT, R1>, f2: UF<R1, R2>, f3: UF<R2, R3>, f4: UF<R3, RT>): Pipeline<VT, RT>;
578
+ declare function pPipe<VT, R1, R2, R3, R4, RT>(f1: UF<VT, R1>, f2: UF<R1, R2>, f3: UF<R2, R3>, f4: UF<R3, R4>, f5: UF<R4, RT>): Pipeline<VT, RT>;
579
+ declare function pPipe<VT, R1, R2, R3, R4, R5, RT>(f1: UF<VT, R1>, f2: UF<R1, R2>, f3: UF<R2, R3>, f4: UF<R3, R4>, f5: UF<R4, R5>, f6: UF<R5, RT>): Pipeline<VT, RT>;
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>;
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>;
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>;
583
+ //#endregion
584
+ //#region src/util/pipe.d.ts
585
+ /**
586
+ * Performs function composition in LTR (Left To Right) direction.
587
+ *
588
+ * Our `pipe` and `pipe.promise` implementation supports N arguments. But you can use only 10 in
589
+ * TypeScript, because it doesn't support **Variadic Kinds** and we explicitly
590
+ * have to define the type of all the possible usages as method overloads.
591
+ *
592
+ * @example pipe
593
+ *
594
+ * const normalizeWhiteSpaces = text => name.replace(/\s+/g, ' ').trim();
595
+ *
596
+ * const getInitials = pipe(
597
+ * normalizeWhiteSpaces,
598
+ * name => name.split(' ').map(name => name.charAt(0)),
599
+ * initials => initials.join('').toLocaleUpperCase()
600
+ * );
601
+ *
602
+ * getInitials('Vitor Luiz Cavalcanti');
603
+ * //=> "VLC"
604
+ *
605
+ * @param fn - An arity N function. Its result is the argument of next one.
606
+ * @param fns - Functions of arity 1. Each one's result is next's argument.
607
+ *
608
+ * @example pipe.promise
609
+ *
610
+ * const addUnicorn = async string => `${string} Unicorn`;
611
+ * const addRainbow = async string => `${string} Rainbow`;
612
+ *
613
+ * const pipeline = pipe.promise(addUnicorn, addRainbow);
614
+ *
615
+ * console.log(await pipeline('❤️'));
616
+ * //=> '❤️ Unicorn Rainbow'
617
+ * @param ...input - Iterated over sequentially when returned `function` is called.
618
+ * @returns The `input` functions are applied from left to right.
619
+ */
620
+ declare function pipe<Args extends unknown[], T0>(...fns: [(...xs: Args) => T0]): (...xs: Args) => T0;
621
+ declare function pipe<Args extends unknown[], T0, T1>(...fns: [(...xs: Args) => T0, (x: T0) => T1]): (...xs: Args) => T1;
622
+ declare function pipe<Args extends unknown[], T0, T1, T2>(...fns: [(...xs: Args) => T0, (x: T0) => T1, (x: T1) => T2]): (...xs: Args) => T2;
623
+ declare function pipe<Args extends unknown[], T0, T1, T2, T3>(...fns: [(...xs: Args) => T0, (x: T0) => T1, (x: T1) => T2, (x: T2) => T3]): (...xs: Args) => T3;
624
+ declare function pipe<Args extends unknown[], T0, T1, T2, T3, T4>(...fns: [(...xs: Args) => T0, (x: T0) => T1, (x: T1) => T2, (x: T2) => T3, (x: T3) => T4]): (...xs: Args) => T4;
625
+ declare function pipe<Args extends unknown[], T0, T1, T2, T3, T4, T5>(...fns: [(...xs: Args) => T0, (x: T0) => T1, (x: T1) => T2, (x: T2) => T3, (x: T3) => T4, (x: T4) => T5]): (...xs: Args) => T5;
626
+ declare function pipe<Args extends unknown[], T0, T1, T2, T3, T4, T5, T6>(...fns: [(...xs: Args) => T0, (x: T0) => T1, (x: T1) => T2, (x: T2) => T3, (x: T3) => T4, (x: T4) => T5, (x: T5) => T6]): (...xs: Args) => T6;
627
+ declare function pipe<Args extends unknown[], T0, T1, T2, T3, T4, T5, T6, T7>(...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]): (...xs: Args) => T7;
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;
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;
630
+ declare namespace pipe {
631
+ var promise: typeof pPipe;
632
+ }
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;
641
+ /**
642
+ * Creates a proxy object that updates the original object when the proxy is updated.
643
+ * @param initObject - The initial object to proxy.
644
+ * @returns The proxy object.
645
+ *
646
+ * @example
647
+ * ```ts
648
+ * const obj = proxy({ name: 'John' })
649
+ * console.log(obj.name) // John
650
+ *
651
+ * obj.proxy.update({ name: 'Jane' })
652
+ * console.log(obj.name) // Jane
653
+ *
654
+ * const obj2 = proxy()
655
+ *
656
+ * obj2.any // Error: Proxy not updated. Call object.proxy.update() to update the proxy.
657
+ *
658
+ * obj2.proxy.source // undefined
659
+ * obj2.update({ name: 'John' })
660
+ *
661
+ * // get the original object
662
+ * obj2.proxy.source // { name: 'John' }
663
+ * ```
664
+ */
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
670
+ /**
671
+ * Get a random item from an array.
672
+ * @param array - The array to get a random item from.
673
+ * @returns The random item.
674
+ * @example
675
+ * ```ts
676
+ * randomItem(['a', 'b', 'c']) // 'a' | 'b' | 'c'
677
+ */
678
+ declare function randomItem<T>(array: T[]): T;
679
+ /**
680
+ * Get a random number between a minimum and maximum value.
681
+ * @param min - The minimum value.
682
+ * @param max - The maximum value.
683
+ * @returns The random number.
684
+ * @example
685
+ * ```ts
686
+ * randomNumber(0, 100) // 0-100
687
+ */
688
+ declare function randomNumber(min: number, max: number): number;
689
+ /**
690
+ * Get a random string of a given size.
691
+ * @param size - The size of the string.
692
+ * @param chars - The characters to use in the string.
693
+ * @returns The random string.
694
+ * @example
695
+ * ```ts
696
+ * randomString() // 10 characters long
697
+ * randomString(20) // 20 characters long
698
+ * randomString(20, 'abcdefghijklmnopqrstuvwxyz') // 20 characters long
699
+ */
700
+ declare function randomString(size?: number, chars?: string): string;
701
+ //#endregion
702
+ //#region src/util/serialized.d.ts
703
+ /**
704
+ * formData to object
705
+ * @param formData
706
+ */
707
+ declare function formdataToObject(formData: FormData): Record<string, string>;
708
+ /**
709
+ * Object to formData
710
+ * @param object
711
+ */
712
+ declare function objectToFormdata(object: Record<string, string | File>): FormData;
713
+ /**
714
+ * Check if a value is not NaN.
715
+ * @param value - The value to check.
716
+ * @returns The value if it is not NaN, otherwise undefined.
717
+ */
718
+ declare function nonnanable<T>(value: T): T | undefined;
719
+ /**
720
+ * Convert a value to a number.
721
+ * @param value - The value to convert to a number.
722
+ * @returns The number value.
723
+ */
724
+ declare function numberify(value: any): number;
725
+ /**
726
+ * Convert a value to a string.
727
+ * @param value - The value to convert to a string.
728
+ * @returns The string value.
729
+ */
730
+ declare function stringify(value: any): string;
731
+ /**
732
+ * Convert a value to a numberish value.
733
+ * @param value - The value to convert to a numberish value.
734
+ * @returns The numberish value.
735
+ */
736
+ declare function numberish(value: Numberish): string;
737
+ //#endregion
738
+ //#region src/util/to.d.ts
739
+ /**
740
+ * Convert a promise to a tuple of [error, data].
741
+ * @param promise - The promise to convert.
742
+ * @param error - The error to return if the promise fails.
743
+ * @returns The tuple of [error, data].
744
+ * @example
745
+ * ```ts
746
+ * to(Promise.resolve('data')) // Promise<[null, 'data']>
747
+ * to(Promise.reject(new Error('error'))) // Promise<[Error, undefined]>
748
+ */
749
+ declare function to<T, U = Error>(promise: Promise<T> | (() => Promise<T>), error?: object): Promise<[U, undefined] | [null, T]>;
750
+ //#endregion
751
+ //#region src/util/to-array.d.ts
752
+ /**
753
+ * Convert a value to an array.
754
+ * @param value - The value to convert.
755
+ * @param required - Whether the array is required.
756
+ * @returns The array.
757
+ * @example
758
+ * ```ts
759
+ * toArray(arrorOrItemOrUndefined) // item[] | undefined
760
+ * toArray(arrayOrItemOrUndefined, true) // item[]
761
+ */
762
+ declare function toArray<T, R extends boolean>(value?: T | T[], required?: R): R extends true ? T[] : T[] | undefined;
763
+ //#endregion
764
+ //#region src/util/unit.d.ts
765
+ type Dimension = Numeric | [Numeric, Numeric] | {
766
+ width: Numeric;
767
+ height: Numeric;
768
+ };
769
+ declare function unit(value: Numeric, unit?: string): string;
770
+ declare function size(dimension: Dimension, unit?: string): {
771
+ width: string;
772
+ height: string;
773
+ };
774
+ //#endregion
775
+ //#region src/util/util.d.ts
776
+ /** @deprecated Use range instead */
777
+ declare const arange: {
778
+ (start: number, end?: number, step?: number): number[];
779
+ (end: number, index: string | number, guard: object): number[];
780
+ };
781
+ /**
782
+ * Select a value based on a condition.
783
+ * @param args - The arguments to select from.
784
+ * @returns The selected value.
785
+ * @example
786
+ * ```ts
787
+ * select(
788
+ * [condition1, value],
789
+ * [condition2, value2],
790
+ * // default value
791
+ * [true, value3],
792
+ * ...
793
+ * ) // value
794
+ * ```
795
+ */
796
+ declare function select<T>(...args: [cond: boolean, value: T][]): T;
797
+ /**
798
+ * @deprecated Use select instead
799
+ */
800
+ declare const riposte: typeof select;
801
+ /**
802
+ * Unwrap a value or a function that returns a value.
803
+ * @param value - The value or function to unwrap.
804
+ * @returns The unwrapped value.
805
+ * @example
806
+ * ```ts
807
+ * unwrap({ name: 'John' }) // { name: 'John' }
808
+ * unwrap(() => { return { name: 'John' } }) // { name: 'John' }
809
+ */
810
+ declare function unwrap<T extends object>(value: T | (() => T)): T;
811
+ /**
812
+ * Call a callback if a value is not null or undefined.
813
+ * @param value - The value to check.
814
+ * @param callback - The callback to call.
815
+ * @returns The result of the callback.
816
+ * @example
817
+ * ```ts
818
+ * whenever(value, (value) => { return 'value' }) // value
819
+ */
820
+ declare function whenever<T, C extends (value: Exclude<T, null | undefined>) => any>(value: T, callback: C): ReturnType<C> | undefined;
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 };