@noah-libjs/utils 0.0.23 → 0.0.43

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,942 @@
1
+ import dayjs, { ConfigType, QUnitType, OpUnitType } from 'dayjs';
2
+ export { default as dayjs } from 'dayjs';
3
+
4
+ interface ICommonOption {
5
+ value?: any;
6
+ label?: string;
7
+ tip?: string;
8
+ prefix?: string;
9
+ sufix?: string;
10
+ suffix?: string;
11
+ props?: any;
12
+ warning?: boolean;
13
+ parentheses?: boolean;
14
+ exclusive?: boolean;
15
+ inputType?: string;
16
+ id?: any;
17
+ text?: any;
18
+ code?: any;
19
+ disabled?: boolean;
20
+ }
21
+
22
+ type PropertyKey$1 = string | number | symbol;
23
+ type PartialAll<T> = {
24
+ [P in keyof T]?: T[P] extends Array<any> ? Partial<T[P][number]>[] : Partial<T[P]>;
25
+ };
26
+ type PartialSome<T, K extends keyof T> = {
27
+ [P in K]?: T[P];
28
+ } & Pick<T, Exclude<keyof T, K>>;
29
+ type AnyObject<T = any> = {
30
+ [x: string]: T;
31
+ };
32
+
33
+ /**
34
+ * Sorts an array of items into groups. The return value is a map where the keys are
35
+ * the group ids the given getGroupId function produced and the value is an array of
36
+ * each item in that group.
37
+ */
38
+ declare const group: <T, Key extends string | number | symbol>(array: readonly T[], getGroupId: (item: T) => Key) => Partial<Record<Key, T[]>>;
39
+ /**
40
+ * Creates an array of grouped elements, the first of which contains the
41
+ * first elements of the given arrays, the second of which contains the
42
+ * second elements of the given arrays, and so on.
43
+ *
44
+ * Ex. const zipped = zip(['a', 'b'], [1, 2], [true, false]) // [['a', 1, true], ['b', 2, false]]
45
+ */
46
+ declare function zip<T1, T2, T3, T4, T5>(array1: T1[], array2: T2[], array3: T3[], array4: T4[], array5: T5[]): [T1, T2, T3, T4, T5][];
47
+ declare function zip<T1, T2, T3, T4>(array1: T1[], array2: T2[], array3: T3[], array4: T4[]): [T1, T2, T3, T4][];
48
+ declare function zip<T1, T2, T3>(array1: T1[], array2: T2[], array3: T3[]): [T1, T2, T3][];
49
+ declare function zip<T1, T2>(array1: T1[], array2: T2[]): [T1, T2][];
50
+ /**
51
+ * Creates an object mapping the specified keys to their corresponding values
52
+ *
53
+ * Ex. const zipped = zipToObject(['a', 'b'], [1, 2]) // { a: 1, b: 2 }
54
+ * Ex. const zipped = zipToObject(['a', 'b'], (k, i) => k + i) // { a: 'a0', b: 'b1' }
55
+ * Ex. const zipped = zipToObject(['a', 'b'], 1) // { a: 1, b: 1 }
56
+ */
57
+ declare function zipToObject<K extends string | number | symbol, V>(keys: K[], values: V | ((key: K, idx: number) => V) | V[]): Record<K, V>;
58
+ /**
59
+ * Go through a list of items, starting with the first item,
60
+ * and comparing with the second. Keep the one you want then
61
+ * compare that to the next item in the list with the same
62
+ *
63
+ * Ex. const greatest = () => boil(numbers, (a, b) => a > b)
64
+ */
65
+ declare const boil: <T>(array: readonly T[], compareFunc: (a: T, b: T) => T) => T | null;
66
+ /**
67
+ * Sum all numbers in an array. Optionally provide a function
68
+ * to convert objects in the array to number values.
69
+ */
70
+ declare function sum<T extends number>(array: readonly T[]): number;
71
+ declare function sum<T extends object>(array: readonly T[], fn: (item: T) => number): number;
72
+ /**
73
+ * Get the first item in an array or a default value
74
+ */
75
+ declare const first: <T>(array: readonly T[], defaultValue?: T | null | undefined) => T | null | undefined;
76
+ /**
77
+ * Get the last item in an array or a default value
78
+ */
79
+ declare const last: <T>(array: readonly T[], defaultValue?: T | null | undefined) => T | null | undefined;
80
+ /**
81
+ * Sort an array without modifying it and return
82
+ * the newly sorted value
83
+ */
84
+ declare const sort: <T>(array: readonly T[], getter: (item: T) => number, desc?: boolean) => T[];
85
+ /**
86
+ * Sort an array without modifying it and return
87
+ * the newly sorted value. Allows for a string
88
+ * sorting value.
89
+ */
90
+ declare const alphabetical: <T>(array: readonly T[], getter: (item: T) => string, dir?: 'asc' | 'desc') => T[];
91
+ declare const counting: <T, TId extends string | number | symbol>(list: readonly T[], identity: (item: T) => TId) => Record<TId, number>;
92
+ /**
93
+ * Replace an element in an array with a new
94
+ * item without modifying the array and return
95
+ * the new value
96
+ */
97
+ declare const replace: <T>(list: readonly T[], newItem: T, match: (item: T, idx: number) => boolean) => T[];
98
+ /**
99
+ * Convert an array to a dictionary by mapping each item
100
+ * into a dictionary key & value
101
+ */
102
+ declare const objectify: <T, Key extends string | number | symbol, Value = T>(array: readonly T[], getKey: (item: T) => Key, getValue?: (item: T) => Value) => Record<Key, Value>;
103
+ /**
104
+ * Select performs a filter and a mapper inside of a reduce,
105
+ * only iterating the list one time.
106
+ *
107
+ * @example
108
+ * select([1, 2, 3, 4], x => x*x, x > 2) == [9, 16]
109
+ */
110
+ declare const select: <T, K>(array: readonly T[], mapper: (item: T, index: number) => K, condition: (item: T, index: number) => boolean) => K[];
111
+ /**
112
+ * Max gets the greatest value from a list
113
+ *
114
+ * @example
115
+ * max([ 2, 3, 5]) == 5
116
+ * max([{ num: 1 }, { num: 2 }], x => x.num) == { num: 2 }
117
+ */
118
+ declare function max(array: readonly [number, ...number[]]): number;
119
+ declare function max(array: readonly number[]): number | null;
120
+ declare function max<T>(array: readonly T[], getter: (item: T) => number): T | null;
121
+ /**
122
+ * Min gets the smallest value from a list
123
+ *
124
+ * @example
125
+ * min([1, 2, 3, 4]) == 1
126
+ * min([{ num: 1 }, { num: 2 }], x => x.num) == { num: 1 }
127
+ */
128
+ declare function min(array: readonly [number, ...number[]]): number;
129
+ declare function min(array: readonly number[]): number | null;
130
+ declare function min<T>(array: readonly T[], getter: (item: T) => number): T | null;
131
+ /**
132
+ * Splits a single list into many lists of the desired size. If
133
+ * given a list of 10 items and a size of 2, it will return 5
134
+ * lists with 2 items each
135
+ */
136
+ declare const cluster: <T>(list: readonly T[], size?: number) => T[][];
137
+ /**
138
+ * Given a list of items returns a new list with only
139
+ * unique items. Accepts an optional identity function
140
+ * to convert each item in the list to a comparable identity
141
+ * value
142
+ */
143
+ declare const unique: <T, K extends string | number | symbol>(array: readonly T[], toKey?: ((item: T) => K) | undefined) => T[];
144
+ /**
145
+ * Creates a generator that will produce an iteration through
146
+ * the range of number as requested.
147
+ *
148
+ * @example
149
+ * range(3) // yields 0, 1, 2, 3
150
+ * range(0, 3) // yields 0, 1, 2, 3
151
+ * range(0, 3, 'y') // yields y, y, y, y
152
+ * range(0, 3, () => 'y') // yields y, y, y, y
153
+ * range(0, 3, i => i) // yields 0, 1, 2, 3
154
+ * range(0, 3, i => `y${i}`) // yields y0, y1, y2, y3
155
+ * range(0, 3, obj) // yields obj, obj, obj, obj
156
+ * range(0, 6, i => i, 2) // yields 0, 2, 4, 6
157
+ */
158
+ declare function range<T = number>(startOrLength: number, end?: number, valueOrMapper?: T | ((i: number) => T), step?: number): Generator<T>;
159
+ /**
160
+ * Creates a list of given start, end, value, and
161
+ * step parameters.
162
+ *
163
+ * @example
164
+ * list(3) // 0, 1, 2, 3
165
+ * list(0, 3) // 0, 1, 2, 3
166
+ * list(0, 3, 'y') // y, y, y, y
167
+ * list(0, 3, () => 'y') // y, y, y, y
168
+ * list(0, 3, i => i) // 0, 1, 2, 3
169
+ * list(0, 3, i => `y${i}`) // y0, y1, y2, y3
170
+ * list(0, 3, obj) // obj, obj, obj, obj
171
+ * list(0, 6, i => i, 2) // 0, 2, 4, 6
172
+ */
173
+ declare const list: <T = number>(startOrLength: number, end?: number, valueOrMapper?: T | ((i: number) => T) | undefined, step?: number) => T[];
174
+ /**
175
+ * Given an array of arrays, returns a single
176
+ * dimentional array with all items in it.
177
+ */
178
+ declare const flat: <T>(lists: readonly T[][]) => T[];
179
+ /**
180
+ * Given two arrays, returns true if any
181
+ * elements intersect
182
+ */
183
+ declare const intersects: <T, K extends string | number | symbol>(listA: readonly T[], listB: readonly T[], identity?: ((t: T) => K) | undefined) => boolean;
184
+ /**
185
+ * Split an array into two array based on
186
+ * a true/false condition function
187
+ */
188
+ declare const fork: <T>(list: readonly T[], condition: (item: T) => boolean) => [T[], T[]];
189
+ /**
190
+ * Given two lists of the same type, iterate the first list
191
+ * and replace items matched by the matcher func in the
192
+ * first place.
193
+ */
194
+ declare const merge: <T>(root: readonly T[], others: readonly T[], matcher: (item: T) => any) => readonly T[];
195
+ /**
196
+ * Replace an item in an array by a match function condition. If
197
+ * no items match the function condition, appends the new item to
198
+ * the end of the list.
199
+ */
200
+ declare const replaceOrAppend: <T>(list: readonly T[], newItem: T, match: (a: T, idx: number) => boolean) => T[];
201
+ /**
202
+ * If the item matching the condition already exists
203
+ * in the list it will be removed. If it does not it
204
+ * will be added.
205
+ */
206
+ declare const toggle: <T>(list: readonly T[], item: T, toKey?: ((item: T, idx: number) => number | string | symbol) | null | undefined, options?: {
207
+ strategy?: 'prepend' | 'append';
208
+ }) => T[];
209
+ type Falsy = null | undefined | false | '' | 0 | 0n;
210
+ /**
211
+ * Given a list returns a new list with
212
+ * only truthy values
213
+ */
214
+ declare const sift: <T>(list: readonly (Falsy | T)[]) => T[];
215
+ /**
216
+ * Like a reduce but does not require an array.
217
+ * Only need a number and will iterate the function
218
+ * as many times as specified.
219
+ *
220
+ * NOTE: This is NOT zero indexed. If you pass count=5
221
+ * you will get 1, 2, 3, 4, 5 iteration in the callback
222
+ * function
223
+ */
224
+ declare const iterate: <T>(count: number, func: (currentValue: T, iteration: number) => T, initValue: T) => T;
225
+ /**
226
+ * Returns all items from the first list that
227
+ * do not exist in the second list.
228
+ */
229
+ declare const diff: <T>(root: readonly T[], other: readonly T[], identity?: (item: T) => string | number | symbol) => T[];
230
+ /**
231
+ * Shift array items by n steps
232
+ * If n > 0 items will shift n steps to the right
233
+ * If n < 0 items will shift n steps to the left
234
+ */
235
+ declare function shift<T>(arr: Array<T>, n: number): T[];
236
+
237
+ /**
238
+ * An async reduce function. Works like the
239
+ * built-in Array.reduce function but handles
240
+ * an async reducer function
241
+ */
242
+ declare const reduce: <T, K>(array: readonly T[], asyncReducer: (acc: K, item: T, index: number) => Promise<K>, initValue?: K | undefined) => Promise<K>;
243
+ /**
244
+ * An async map function. Works like the
245
+ * built-in Array.map function but handles
246
+ * an async mapper function
247
+ */
248
+ declare const map: <T, K>(array: readonly T[], asyncMapFunc: (item: T, index: number) => Promise<K>) => Promise<K[]>;
249
+ /**
250
+ * Useful when for script like things where cleanup
251
+ * should be done on fail or sucess no matter.
252
+ *
253
+ * You can call defer many times to register many
254
+ * defered functions that will all be called when
255
+ * the function exits in any state.
256
+ */
257
+ declare const defer: <TResponse>(func: (register: (fn: (error?: any) => any, options?: {
258
+ rethrow?: boolean;
259
+ }) => void) => Promise<TResponse>) => Promise<TResponse>;
260
+ /**
261
+ * Support for the built-in AggregateError
262
+ * is still new. Node < 15 doesn't have it
263
+ * so patching here.
264
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AggregateError#browser_compatibility
265
+ */
266
+ declare class AggregateError extends Error {
267
+ errors: Error[];
268
+ constructor(errors?: Error[]);
269
+ }
270
+ /**
271
+ * Executes many async functions in parallel. Returns the
272
+ * results from all functions as an array. After all functions
273
+ * have resolved, if any errors were thrown, they are rethrown
274
+ * in an instance of AggregateError
275
+ */
276
+ declare const parallel: <T, K>(limit: number, array: readonly T[], func: (item: T) => Promise<K>) => Promise<K[]>;
277
+ type PromiseValues<T extends Promise<any>[]> = {
278
+ [K in keyof T]: T[K] extends Promise<infer U> ? U : never;
279
+ };
280
+ /**
281
+ * Functionally similar to Promise.all or Promise.allSettled. If any
282
+ * errors are thrown, all errors are gathered and thrown in an
283
+ * AggregateError.
284
+ *
285
+ * @example
286
+ * const [user] = await all([
287
+ * api.users.create(...),
288
+ * s3.buckets.create(...),
289
+ * slack.customerSuccessChannel.sendMessage(...)
290
+ * ])
291
+ */
292
+ declare function all<T extends [Promise<any>, ...Promise<any>[]]>(promises: T): Promise<PromiseValues<T>>;
293
+ declare function all<T extends Promise<any>[]>(promises: T): Promise<PromiseValues<T>>;
294
+ /**
295
+ * Functionally similar to Promise.all or Promise.allSettled. If any
296
+ * errors are thrown, all errors are gathered and thrown in an
297
+ * AggregateError.
298
+ *
299
+ * @example
300
+ * const { user } = await all({
301
+ * user: api.users.create(...),
302
+ * bucket: s3.buckets.create(...),
303
+ * message: slack.customerSuccessChannel.sendMessage(...)
304
+ * })
305
+ */
306
+ declare function all<T extends Record<string, Promise<any>>>(promises: T): Promise<{
307
+ [K in keyof T]: Awaited<T[K]>;
308
+ }>;
309
+ /**
310
+ * Retries the given function the specified number
311
+ * of times.
312
+ */
313
+ declare const retry: <TResponse>(options: {
314
+ times?: number | undefined;
315
+ delay?: number | null | undefined;
316
+ backoff?: ((count: number) => number) | undefined;
317
+ }, func: (exit: (err: any) => void) => Promise<TResponse>) => Promise<TResponse>;
318
+ /**
319
+ * Async wait
320
+ */
321
+ declare const sleep: (milliseconds: number) => Promise<unknown>;
322
+ /**
323
+ * A helper to try an async function without forking
324
+ * the control flow. Returns an error first callback _like_
325
+ * array response as [Error, result]
326
+ */
327
+ declare const tryit: <Args extends any[], Return>(func: (...args: Args) => Return) => (...args: Args) => Return extends Promise<any> ? Promise<[Error, undefined] | [undefined, Awaited<Return>]> : [Error, undefined] | [undefined, Return];
328
+ /**
329
+ * A helper to try an async function that returns undefined
330
+ * if it fails.
331
+ *
332
+ * e.g. const result = await guard(fetchUsers)() ?? [];
333
+ */
334
+ declare const guard: <TFunction extends () => any>(func: TFunction, shouldGuard?: ((err: any) => boolean) | undefined) => ReturnType<TFunction> extends Promise<any> ? Promise<Awaited<ReturnType<TFunction>> | undefined> : ReturnType<TFunction> | undefined;
335
+
336
+ declare function chain<T1 extends any[], T2, T3>(f1: (...arg: T1) => T2, f2: (arg: T2) => T3): (...arg: T1) => T3;
337
+ declare function chain<T1 extends any[], T2, T3, T4>(f1: (...arg: T1) => T2, f2: (arg: T2) => T3, f3: (arg: T3) => T4): (...arg: T1) => T4;
338
+ declare function chain<T1 extends any[], T2, T3, T4, T5>(f1: (...arg: T1) => T2, f2: (arg: T2) => T3, f3: (arg: T3) => T4, f4: (arg: T3) => T5): (...arg: T1) => T5;
339
+ declare function chain<T1 extends any[], T2, T3, T4, T5, T6>(f1: (...arg: T1) => T2, f2: (arg: T2) => T3, f3: (arg: T3) => T4, f4: (arg: T3) => T5, f5: (arg: T3) => T6): (...arg: T1) => T6;
340
+ declare function chain<T1 extends any[], T2, T3, T4, T5, T6, T7>(f1: (...arg: T1) => T2, f2: (arg: T2) => T3, f3: (arg: T3) => T4, f4: (arg: T3) => T5, f5: (arg: T3) => T6, f6: (arg: T3) => T7): (...arg: T1) => T7;
341
+ declare function chain<T1 extends any[], T2, T3, T4, T5, T6, T7, T8>(f1: (...arg: T1) => T2, f2: (arg: T2) => T3, f3: (arg: T3) => T4, f4: (arg: T3) => T5, f5: (arg: T3) => T6, f6: (arg: T3) => T7, f7: (arg: T3) => T8): (...arg: T1) => T8;
342
+ declare function chain<T1 extends any[], T2, T3, T4, T5, T6, T7, T8, T9>(f1: (...arg: T1) => T2, f2: (arg: T2) => T3, f3: (arg: T3) => T4, f4: (arg: T3) => T5, f5: (arg: T3) => T6, f6: (arg: T3) => T7, f7: (arg: T3) => T8, f8: (arg: T3) => T9): (...arg: T1) => T9;
343
+ declare function chain<T1 extends any[], T2, T3, T4, T5, T6, T7, T8, T9, T10>(f1: (...arg: T1) => T2, f2: (arg: T2) => T3, f3: (arg: T3) => T4, f4: (arg: T3) => T5, f5: (arg: T3) => T6, f6: (arg: T3) => T7, f7: (arg: T3) => T8, f8: (arg: T3) => T9, f9: (arg: T3) => T10): (...arg: T1) => T10;
344
+ declare function chain<T1 extends any[], T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(f1: (...arg: T1) => T2, f2: (arg: T2) => T3, f3: (arg: T3) => T4, f4: (arg: T3) => T5, f5: (arg: T3) => T6, f6: (arg: T3) => T7, f7: (arg: T3) => T8, f8: (arg: T3) => T9, f9: (arg: T3) => T10, f10: (arg: T3) => T11): (...arg: T1) => T11;
345
+ declare function compose<F1Result, F1Args extends any[], F1NextArgs extends any[], LastResult>(f1: (next: (...args: F1NextArgs) => LastResult) => (...args: F1Args) => F1Result, last: (...args: F1NextArgs) => LastResult): (...args: F1Args) => F1Result;
346
+ declare function compose<F1Result, F1Args extends any[], F1NextArgs extends any[], F2Result, F2NextArgs extends any[], LastResult>(f1: (next: (...args: F1NextArgs) => F2Result) => (...args: F1Args) => F1Result, f2: (next: (...args: F2NextArgs) => LastResult) => (...args: F1NextArgs) => F2Result, last: (...args: F2NextArgs) => LastResult): (...args: F1Args) => F1Result;
347
+ declare function compose<F1Result, F1Args extends any[], F1NextArgs extends any[], F2NextArgs extends any[], F2Result, F3NextArgs extends any[], F3Result, LastResult>(f1: (next: (...args: F1NextArgs) => F2Result) => (...args: F1Args) => F1Result, f2: (next: (...args: F2NextArgs) => F3Result) => (...args: F1NextArgs) => F2Result, f3: (next: (...args: F3NextArgs) => LastResult) => (...args: F2NextArgs) => F3Result, last: (...args: F3NextArgs) => LastResult): (...args: F1Args) => F1Result;
348
+ declare function compose<F1Result, F1Args extends any[], F1NextArgs extends any[], F2NextArgs extends any[], F2Result, F3NextArgs extends any[], F3Result, F4NextArgs extends any[], F4Result, LastResult>(f1: (next: (...args: F1NextArgs) => F2Result) => (...args: F1Args) => F1Result, f2: (next: (...args: F2NextArgs) => F3Result) => (...args: F1NextArgs) => F2Result, f3: (next: (...args: F3NextArgs) => F4Result) => (...args: F2NextArgs) => F3Result, f4: (next: (...args: F4NextArgs) => LastResult) => (...args: F3NextArgs) => F4Result, last: (...args: F4NextArgs) => LastResult): (...args: F1Args) => F1Result;
349
+ declare function compose<F1Result, F1Args extends any[], F1NextArgs extends any[], F2NextArgs extends any[], F2Result, F3NextArgs extends any[], F3Result, F4NextArgs extends any[], F4Result, F5NextArgs extends any[], F5Result, LastResult>(f1: (next: (...args: F1NextArgs) => F2Result) => (...args: F1Args) => F1Result, f2: (next: (...args: F2NextArgs) => F3Result) => (...args: F1NextArgs) => F2Result, f3: (next: (...args: F3NextArgs) => F4Result) => (...args: F2NextArgs) => F3Result, f4: (next: (...args: F4NextArgs) => F5Result) => (...args: F3NextArgs) => F4Result, f5: (next: (...args: F5NextArgs) => LastResult) => (...args: F4NextArgs) => F5Result, last: (...args: F5NextArgs) => LastResult): (...args: F1Args) => F1Result;
350
+ declare function compose<F1Result, F1Args extends any[], F1NextArgs extends any[], F2NextArgs extends any[], F2Result, F3NextArgs extends any[], F3Result, F4NextArgs extends any[], F4Result, F5NextArgs extends any[], F5Result, F6NextArgs extends any[], F6Result, LastResult>(f1: (next: (...args: F1NextArgs) => F2Result) => (...args: F1Args) => F1Result, f2: (next: (...args: F2NextArgs) => F3Result) => (...args: F1NextArgs) => F2Result, f3: (next: (...args: F3NextArgs) => F4Result) => (...args: F2NextArgs) => F3Result, f4: (next: (...args: F4NextArgs) => F5Result) => (...args: F3NextArgs) => F4Result, f5: (next: (...args: F5NextArgs) => F6Result) => (...args: F4NextArgs) => F5Result, f6: (next: (...args: F6NextArgs) => LastResult) => (...args: F5NextArgs) => F6Result, last: (...args: F6NextArgs) => LastResult): (...args: F1Args) => F1Result;
351
+ declare function compose<F1Result, F1Args extends any[], F1NextArgs extends any[], F2NextArgs extends any[], F2Result, F3NextArgs extends any[], F3Result, F4NextArgs extends any[], F4Result, F5NextArgs extends any[], F5Result, F6NextArgs extends any[], F6Result, F7NextArgs extends any[], F7Result, LastResult>(f1: (next: (...args: F1NextArgs) => F2Result) => (...args: F1Args) => F1Result, f2: (next: (...args: F2NextArgs) => F3Result) => (...args: F1NextArgs) => F2Result, f3: (next: (...args: F3NextArgs) => F4Result) => (...args: F2NextArgs) => F3Result, f4: (next: (...args: F4NextArgs) => F5Result) => (...args: F3NextArgs) => F4Result, f5: (next: (...args: F5NextArgs) => F6Result) => (...args: F4NextArgs) => F5Result, f6: (next: (...args: F6NextArgs) => F7Result) => (...args: F5NextArgs) => F6Result, f7: (next: (...args: F7NextArgs) => LastResult) => (...args: F6NextArgs) => F7Result, last: (...args: F7NextArgs) => LastResult): (...args: F1Args) => F1Result;
352
+ declare function compose<F1Result, F1Args extends any[], F1NextArgs extends any[], F2NextArgs extends any[], F2Result, F3NextArgs extends any[], F3Result, F4NextArgs extends any[], F4Result, F5NextArgs extends any[], F5Result, F6NextArgs extends any[], F6Result, F7NextArgs extends any[], F7Result, F8NextArgs extends any[], F8Result, LastResult>(f1: (next: (...args: F1NextArgs) => F2Result) => (...args: F1Args) => F1Result, f2: (next: (...args: F2NextArgs) => F3Result) => (...args: F1NextArgs) => F2Result, f3: (next: (...args: F3NextArgs) => F4Result) => (...args: F2NextArgs) => F3Result, f4: (next: (...args: F4NextArgs) => F5Result) => (...args: F3NextArgs) => F4Result, f5: (next: (...args: F5NextArgs) => F6Result) => (...args: F4NextArgs) => F5Result, f6: (next: (...args: F6NextArgs) => F7Result) => (...args: F5NextArgs) => F6Result, f7: (next: (...args: F7NextArgs) => LastResult) => (...args: F6NextArgs) => F7Result, f8: (next: (...args: F8NextArgs) => LastResult) => (...args: F7NextArgs) => F8Result, last: (...args: F8NextArgs) => LastResult): (...args: F1Args) => F1Result;
353
+ declare function compose<F1Result, F1Args extends any[], F1NextArgs extends any[], F2NextArgs extends any[], F2Result, F3NextArgs extends any[], F3Result, F4NextArgs extends any[], F4Result, F5NextArgs extends any[], F5Result, F6NextArgs extends any[], F6Result, F7NextArgs extends any[], F7Result, F8NextArgs extends any[], F8Result, F9NextArgs extends any[], F9Result, LastResult>(f1: (next: (...args: F1NextArgs) => F2Result) => (...args: F1Args) => F1Result, f2: (next: (...args: F2NextArgs) => F3Result) => (...args: F1NextArgs) => F2Result, f3: (next: (...args: F3NextArgs) => F4Result) => (...args: F2NextArgs) => F3Result, f4: (next: (...args: F4NextArgs) => F5Result) => (...args: F3NextArgs) => F4Result, f5: (next: (...args: F5NextArgs) => F6Result) => (...args: F4NextArgs) => F5Result, f6: (next: (...args: F6NextArgs) => F7Result) => (...args: F5NextArgs) => F6Result, f7: (next: (...args: F7NextArgs) => LastResult) => (...args: F6NextArgs) => F7Result, f8: (next: (...args: F8NextArgs) => LastResult) => (...args: F7NextArgs) => F8Result, f9: (next: (...args: F9NextArgs) => LastResult) => (...args: F8NextArgs) => F9Result, last: (...args: F9NextArgs) => LastResult): (...args: F1Args) => F1Result;
354
+ /**
355
+ * This type produces the type array of TItems with all the type items
356
+ * in TItemsToRemove removed from the start of the array type.
357
+ *
358
+ * @example
359
+ * ```
360
+ * RemoveItemsInFront<[number, number], [number]> = [number]
361
+ * RemoveItemsInFront<[File, number, string], [File, number]> = [string]
362
+ * ```
363
+ */
364
+ type RemoveItemsInFront<TItems extends any[], TItemsToRemove extends any[]> = TItems extends [...TItemsToRemove, ...infer TRest] ? TRest : TItems;
365
+ declare const partial: <T extends any[], TA extends Partial<T>, R>(fn: (...args: T) => R, ...args: TA) => (...rest: RemoveItemsInFront<T, TA>) => R;
366
+ /**
367
+ * Like partial but for unary functions that accept
368
+ * a single object argument
369
+ */
370
+ declare const partob: <T, K, PartialArgs extends Partial<T>>(fn: (args: T) => K, argobj: PartialArgs) => (restobj: Omit<T, keyof PartialArgs>) => K;
371
+ /**
372
+ * Creates a Proxy object that will dynamically
373
+ * call the handler argument when attributes are
374
+ * accessed
375
+ */
376
+ declare const proxied: <T, K>(handler: (propertyName: T) => K) => Record<string, K>;
377
+ /**
378
+ * Creates a memoized function. The returned function
379
+ * will only execute the source function when no value
380
+ * has previously been computed. If a ttl (milliseconds)
381
+ * is given previously computed values will be checked
382
+ * for expiration before being returned.
383
+ */
384
+ declare const memo: <TArgs extends any[], TResult>(func: (...args: TArgs) => TResult, options?: {
385
+ key?: ((...args: TArgs) => string) | undefined;
386
+ ttl?: number | undefined;
387
+ }) => (...args: TArgs) => TResult;
388
+ type DebounceFunction<TArgs extends any[]> = {
389
+ (...args: TArgs): void;
390
+ /**
391
+ * Cancels the debounced function
392
+ */
393
+ cancel(): void;
394
+ /**
395
+ * Checks if there is any invocation debounced
396
+ */
397
+ isPending(): boolean;
398
+ /**
399
+ * Runs the debounced function immediately
400
+ */
401
+ flush(...args: TArgs): void;
402
+ };
403
+ type ThrottledFunction<TArgs extends any[]> = {
404
+ (...args: TArgs): void;
405
+ /**
406
+ * Checks if there is any invocation throttled
407
+ */
408
+ isThrottled(): boolean;
409
+ };
410
+ /**
411
+ * Given a delay and a function returns a new function
412
+ * that will only call the source function after delay
413
+ * milliseconds have passed without any invocations.
414
+ *
415
+ * The debounce function comes with a `cancel` method
416
+ * to cancel delayed `func` invocations and a `flush`
417
+ * method to invoke them immediately
418
+ */
419
+ declare const debounce: <TArgs extends any[]>({ delay }: {
420
+ delay: number;
421
+ }, func: (...args: TArgs) => any) => DebounceFunction<TArgs>;
422
+ /**
423
+ * Given an interval and a function returns a new function
424
+ * that will only call the source function if interval milliseconds
425
+ * have passed since the last invocation
426
+ */
427
+ declare const throttle: <TArgs extends any[]>({ interval }: {
428
+ interval: number;
429
+ }, func: (...args: TArgs) => any) => ThrottledFunction<TArgs>;
430
+ /**
431
+ * Make an object callable. Given an object and a function
432
+ * the returned object will be a function with all the
433
+ * objects properties.
434
+ *
435
+ * @example
436
+ * ```typescript
437
+ * const car = callable({
438
+ * wheels: 2
439
+ * }, self => () => {
440
+ * return 'driving'
441
+ * })
442
+ *
443
+ * car.wheels // => 2
444
+ * car() // => 'driving'
445
+ * ```
446
+ */
447
+ declare const callable: <TValue, TObj extends Record<string | number | symbol, TValue>, TFunc extends (...args: any) => any>(obj: TObj, fn: (self: TObj) => TFunc) => TObj & TFunc;
448
+
449
+ /**
450
+ * Checks if the given number is between zero (0) and the ending number. 0 is inclusive.
451
+ *
452
+ * * Numbers can be negative or positive.
453
+ * * Ending number is exclusive.
454
+ *
455
+ * @param {number} number The number to check.
456
+ * @param {number} end The end of the range. Exclusive.
457
+ * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
458
+ */
459
+ declare function inRange(number: number, end: number): boolean;
460
+ /**
461
+ * Checks if the given number is between two numbers.
462
+ *
463
+ * * Numbers can be negative or positive.
464
+ * * Starting number is inclusive.
465
+ * * Ending number is exclusive.
466
+ * * The start and the end of the range can be ascending OR descending order.
467
+ *
468
+ * @param {number} number The number to check.
469
+ * @param {number} start The start of the range. Inclusive.
470
+ * @param {number} end The end of the range. Exclusive.
471
+ * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
472
+ */
473
+ declare function inRange(number: number, start: number, end: number): boolean;
474
+ declare const toFloat: <T extends number | null = number>(value: any, defaultValue?: T | undefined) => number | T;
475
+ declare const toInt: <T extends number | null = number>(value: any, defaultValue?: T | undefined) => number | T;
476
+
477
+ type LowercasedKeys<T extends Record<string, any>> = {
478
+ [P in keyof T & string as Lowercase<P>]: T[P];
479
+ };
480
+ type UppercasedKeys<T extends Record<string, any>> = {
481
+ [P in keyof T & string as Uppercase<P>]: T[P];
482
+ };
483
+ /**
484
+ * Removes (shakes out) undefined entries from an
485
+ * object. Optional second argument shakes out values
486
+ * by custom evaluation.
487
+ */
488
+ declare const shake: <RemovedKeys extends string, T>(obj: T, filter?: (value: any) => boolean) => Omit<T, RemovedKeys>;
489
+ /**
490
+ * Map over all the keys of an object to return
491
+ * a new object
492
+ */
493
+ declare const mapKeys: <TValue, TKey extends string | number | symbol, TNewKey extends string | number | symbol>(obj: Record<TKey, TValue>, mapFunc: (key: TKey, value: TValue) => TNewKey) => Record<TNewKey, TValue>;
494
+ /**
495
+ * Map over all the keys to create a new object
496
+ */
497
+ declare const mapValues: <TValue, TKey extends string | number | symbol, TNewValue>(obj: Record<TKey, TValue>, mapFunc: (value: TValue, key: TKey) => TNewValue) => Record<TKey, TNewValue>;
498
+ /**
499
+ * Map over all the keys to create a new object
500
+ */
501
+ declare const mapEntries: <TKey extends string | number | symbol, TValue, TNewKey extends string | number | symbol, TNewValue>(obj: Record<TKey, TValue>, toEntry: (key: TKey, value: TValue) => [TNewKey, TNewValue]) => Record<TNewKey, TNewValue>;
502
+ /**
503
+ * Returns an object with { [keys]: value }
504
+ * inverted as { [value]: key }
505
+ */
506
+ declare const invert: <TKey extends string | number | symbol, TValue extends string | number | symbol>(obj: Record<TKey, TValue>) => Record<TValue, TKey>;
507
+ /**
508
+ * Convert all keys in an object to lower case
509
+ */
510
+ declare const lowerize: <T extends Record<string, any>>(obj: T) => LowercasedKeys<T>;
511
+ /**
512
+ * Convert all keys in an object to upper case
513
+ */
514
+ declare const upperize: <T extends Record<string, any>>(obj: T) => UppercasedKeys<T>;
515
+ /**
516
+ * Creates a shallow copy of the given obejct/value.
517
+ * @param {*} obj value to clone
518
+ * @returns {*} shallow clone of the given value
519
+ */
520
+ declare const clone: <T>(obj: T) => T;
521
+ /**
522
+ * Convert an object to a list, mapping each entry
523
+ * into a list item
524
+ */
525
+ declare const listify: <TValue, TKey extends string | number | symbol, KResult>(obj: Record<TKey, TValue>, toItem: (key: TKey, value: TValue) => KResult) => KResult[];
526
+ /**
527
+ * Pick a list of properties from an object
528
+ * into a new object
529
+ */
530
+ declare const pick: <T extends object, TKeys extends keyof T>(obj: T, keys: TKeys[]) => Pick<T, TKeys>;
531
+ /**
532
+ * Omit a list of properties from an object
533
+ * returning a new object with the properties
534
+ * that remain
535
+ */
536
+ declare const omit: <T, TKeys extends keyof T>(obj: T, keys: TKeys[]) => Omit<T, TKeys>;
537
+ /**
538
+ * Opposite of get, dynamically set a nested value into
539
+ * an object using a key path. Does not modify the given
540
+ * initial object.
541
+ *
542
+ * @example
543
+ * set({}, 'name', 'ra') // => { name: 'ra' }
544
+ * set({}, 'cards[0].value', 2) // => { cards: [{ value: 2 }] }
545
+ */
546
+ declare const set: <T extends object, K>(initial: T, path: string, value: K) => T;
547
+ /**
548
+ * Merges two objects together recursivly into a new
549
+ * object applying values from right to left.
550
+ * Recursion only applies to child object properties.
551
+ */
552
+ declare const assign: <X extends Record<string | number | symbol, any>>(initial: X, override: X) => X;
553
+ /**
554
+ * Get a string list of all key names that exist in
555
+ * an object (deep).
556
+ *
557
+ * @example
558
+ * keys({ name: 'ra' }) // ['name']
559
+ * keys({ name: 'ra', children: [{ name: 'hathor' }] }) // ['name', 'children.0.name']
560
+ */
561
+ declare const keys: <TValue extends object>(value: TValue) => string[];
562
+ /**
563
+ * Flattens a deep object to a single demension, converting
564
+ * the keys to dot notation.
565
+ *
566
+ * @example
567
+ * crush({ name: 'ra', children: [{ name: 'hathor' }] })
568
+ * // { name: 'ra', 'children.0.name': 'hathor' }
569
+ */
570
+ declare const crush: <TValue extends object>(value: TValue) => object;
571
+ /**
572
+ * The opposite of crush, given an object that was
573
+ * crushed into key paths and values will return
574
+ * the original object reconstructed.
575
+ *
576
+ * @example
577
+ * construct({ name: 'ra', 'children.0.name': 'hathor' })
578
+ * // { name: 'ra', children: [{ name: 'hathor' }] }
579
+ */
580
+ declare const construct: <TObject extends object>(obj: TObject) => object;
581
+
582
+ /**
583
+ * Generates a random number between min and max
584
+ */
585
+ declare const random: (min: number, max: number) => number;
586
+ /**
587
+ * Draw a random item from a list. Returns
588
+ * null if the list is empty
589
+ */
590
+ declare const draw: <T>(array: readonly T[]) => T | null;
591
+ declare const shuffle: <T>(array: readonly T[]) => T[];
592
+ declare const uid: (length: number, specials?: string) => string;
593
+
594
+ /**
595
+ * Creates a series object around a list of values
596
+ * that should be treated with order.
597
+ */
598
+ declare const series: <T>(items: T[], toKey?: (item: T) => string | symbol) => {
599
+ min: (a: T, b: T) => T;
600
+ max: (a: T, b: T) => T;
601
+ first: () => T;
602
+ last: () => T;
603
+ next: (current: T, defaultValue?: T | undefined) => T;
604
+ previous: (current: T, defaultValue?: T | undefined) => T;
605
+ spin: (current: T, num: number) => T;
606
+ };
607
+
608
+ /**
609
+ * Capitalize the first word of the string
610
+ *
611
+ * capitalize('hello') -> 'Hello'
612
+ * capitalize('va va voom') -> 'Va va voom'
613
+ */
614
+ declare const capitalize: (str: string) => string;
615
+ /**
616
+ * Formats the given string in camel case fashion
617
+ *
618
+ * camel('hello world') -> 'helloWorld'
619
+ * camel('va va-VOOM') -> 'vaVaVoom'
620
+ * camel('helloWorld') -> 'helloWorld'
621
+ */
622
+ declare const camel: (str: string) => string;
623
+ /**
624
+ * Formats the given string in snake case fashion
625
+ *
626
+ * snake('hello world') -> 'hello_world'
627
+ * snake('va va-VOOM') -> 'va_va_voom'
628
+ * snake('helloWord') -> 'hello_world'
629
+ */
630
+ declare const snake: (str: string, options?: {
631
+ splitOnNumber?: boolean;
632
+ }) => string;
633
+ /**
634
+ * Formats the given string in dash case fashion
635
+ *
636
+ * dash('hello world') -> 'hello-world'
637
+ * dash('va va_VOOM') -> 'va-va-voom'
638
+ * dash('helloWord') -> 'hello-word'
639
+ */
640
+ declare const dash: (str: string) => string;
641
+ /**
642
+ * Formats the given string in pascal case fashion
643
+ *
644
+ * pascal('hello world') -> 'HelloWorld'
645
+ * pascal('va va boom') -> 'VaVaBoom'
646
+ */
647
+ declare const pascal: (str: string) => string;
648
+ /**
649
+ * Formats the given string in title case fashion
650
+ *
651
+ * title('hello world') -> 'Hello World'
652
+ * title('va_va_boom') -> 'Va Va Boom'
653
+ * title('root-hook') -> 'Root Hook'
654
+ * title('queryItems') -> 'Query Items'
655
+ */
656
+ declare const title: (str: string | null | undefined) => string;
657
+ /**
658
+ * template is used to replace data by name in template strings.
659
+ * The default expression looks for {{name}} to identify names.
660
+ *
661
+ * Ex. template('Hello, {{name}}', { name: 'ray' })
662
+ * Ex. template('Hello, <name>', { name: 'ray' }, /<(.+?)>/g)
663
+ */
664
+ declare const template: (str: string, data: Record<string, any>, regex?: RegExp) => string;
665
+ /**
666
+ * Trims all prefix and suffix characters from the given
667
+ * string. Like the builtin trim function but accepts
668
+ * other characters you would like to trim and trims
669
+ * multiple characters.
670
+ *
671
+ * ```typescript
672
+ * trim(' hello ') // => 'hello'
673
+ * trim('__hello__', '_') // => 'hello'
674
+ * trim('/repos/:owner/:repo/', '/') // => 'repos/:owner/:repo'
675
+ * trim('222222__hello__1111111', '12_') // => 'hello'
676
+ * ```
677
+ */
678
+ declare const trim: (str: string | null | undefined, charsToTrim?: string) => string;
679
+
680
+ declare const isSymbol: (value: any) => value is symbol;
681
+ declare const isArray: (arg: any) => arg is any[];
682
+ declare const isObject: (value: any) => value is object;
683
+ /**
684
+ * Checks if the given value is primitive.
685
+ *
686
+ * Primitive Types: number , string , boolean , symbol, bigint, undefined, null
687
+ *
688
+ * @param {*} value value to check
689
+ * @returns {boolean} result
690
+ */
691
+ declare const isPrimitive: (value: any) => boolean;
692
+ declare const isFunction: (value: any) => value is Function;
693
+ declare const isString: (value: any) => value is string;
694
+ declare const isInt: (value: any) => value is number;
695
+ declare const isFloat: (value: any) => value is number;
696
+ declare const isNumber: (value: any) => value is number;
697
+ declare const isDate: (value: any) => value is Date;
698
+ /**
699
+ * This is really a _best guess_ promise checking. You
700
+ * should probably use Promise.resolve(value) to be 100%
701
+ * sure you're handling it correctly.
702
+ */
703
+ declare const isPromise: (value: any) => value is Promise<any>;
704
+ declare const isEmpty: (value: any) => boolean;
705
+ declare const isEqual: <TType>(x: TType, y: TType) => boolean;
706
+
707
+ declare function get<T = any>(value: any, path: string, defaultValue?: T | undefined): T;
708
+ declare function identity<T>(value: T): T;
709
+ declare function isBoolean(value: any): value is boolean;
710
+ declare function isObjectLike(value: any): boolean;
711
+ declare function isNull(value: any): value is null;
712
+ declare function size(value: any): number;
713
+ declare function isNil(value: any): value is null | undefined;
714
+ declare function toString(value: any): string;
715
+ declare function cloneDeep<T>(value: T): T | null;
716
+ declare function hasOwn(obj: AnyObject, key: PropertyKey): boolean;
717
+
718
+ declare function safe_json_parse<T = any>(str?: any, retOnErr?: T | null): T | null;
719
+ declare function safe_json_stringify(obj?: any): string;
720
+ declare function safe_json_parse_arr<T = any>(str?: any, retOnErr?: T[]): T[];
721
+
722
+ type TCommonFileType = 'application/vnd.ms-excel' | 'text/csv;charset=utf-8' | 'application/msword';
723
+ declare function get_global(): typeof globalThis;
724
+ declare function getSearchParamsValue(key: string): string | null;
725
+ declare function getSearchParamsAll(url?: URL): AnyObject<string>;
726
+ declare function setSearchParamsValue(key: string, value: string | number): URL;
727
+ declare function setSearchParamsAll(data: AnyObject<string | number>): URL;
728
+ declare function scrollIntoView(symbol: string, finder?: (selectors: string) => Element | null): void;
729
+ declare function base64ToBinary(data: string, type: TCommonFileType): Blob;
730
+ declare function downloadFile(content: string | Blob, filename?: string, type?: TCommonFileType, isBase64?: boolean): void;
731
+ declare function uuid(): string;
732
+ declare function randomHex(): number;
733
+ declare function charToUTF8(char: string): number[];
734
+ declare function charToUnicode(char: string): number;
735
+ declare function unicodeToChar(u: number): string | null;
736
+ declare function unicode_to_UTF8(u: number): number[] | null;
737
+ declare function getFilledArray(n: number): any[];
738
+ declare function copyText(text: string): boolean;
739
+ declare function dyn_cb<T>(cb: (ctx: T) => void, g_ctx: () => T): boolean;
740
+ declare function safeExec<T extends (...args: any) => any>(fn?: T, ...args: Parameters<T>): any;
741
+ declare function safeGetFromFuncOrData(fn: any, default_v?: any): any;
742
+ declare function numberLikeCompare(a: number | string | boolean | null, b: number | string | boolean | null): boolean;
743
+ declare function warpBase64Type(str: string, type: 'img' | 'pdf'): string;
744
+ declare function safe_number_parse(value: any, defaultValue?: number): number;
745
+ declare function expect_array<T>(value?: T[] | null, default_v?: T[]): T[];
746
+ declare function gen_encoded_char_svg(props: {
747
+ char: string;
748
+ size?: number;
749
+ color?: string;
750
+ }): string;
751
+ declare function base64_to_image(base64img: string): Promise<HTMLImageElement | null>;
752
+ declare function image_to_base64(img_el: HTMLImageElement): string | null;
753
+ declare function filter_obj_to_url_search(obj: Object | any[]): any;
754
+ declare function safe_async_call<T extends (...args: any) => any>(cb?: T, ...args: Parameters<T>): Promise<ReturnType<T> | null>;
755
+ declare function cache_fetch<T = any>(key: string, cb: () => Promise<T>, deep?: boolean): Promise<T>;
756
+ declare function speculate_on_display(value?: any): string;
757
+ declare function getFuckTimeInterval(star_hour?: number, end_hour?: number, min_interval?: 1 | 2 | 3 | 4 | 5 | 6 | 10 | 15 | 20 | 30): string[];
758
+ declare function random_word(): string[];
759
+ declare function confirm_operation(): boolean;
760
+ declare function simple_encrypt(data: AnyObject | any[]): number[] | null;
761
+ declare function simple_decrypt(code: number[]): AnyObject | null;
762
+ declare function simple_encrypt_str(data: string, sp?: string): string | null;
763
+ declare function simple_decrypt_str(code: string, sp?: string): string | null;
764
+ declare function text_ellipsis(text: string, max: number): string;
765
+ declare function calc_number(data: AnyObject | any[] | number | string | boolean): number;
766
+
767
+ interface ILL {
768
+ log?(...optionalParams: any[]): void;
769
+ warn?(...optionalParams: any[]): void;
770
+ error?(...optionalParams: any[]): void;
771
+ }
772
+ declare class MyLog {
773
+ private _logMsg;
774
+ logBig(t: string): void;
775
+ private env;
776
+ private static _handler;
777
+ static set handler(v: ILL);
778
+ constructor(e: string);
779
+ log(...msg: any[]): void;
780
+ warn(...msg: any[]): void;
781
+ error(...msg: any[]): void;
782
+ }
783
+
784
+ declare class EventEmitter<TypeMapInterface extends {
785
+ [x: string]: any[];
786
+ }> {
787
+ events: {
788
+ [x in keyof TypeMapInterface]?: Array<(...args: TypeMapInterface[x]) => void>;
789
+ };
790
+ constructor();
791
+ addListener<T extends keyof TypeMapInterface>(event: T, listener: (...args: TypeMapInterface[T]) => void): this;
792
+ on<T extends keyof TypeMapInterface>(event: T, listener: (...args: TypeMapInterface[T]) => void): this;
793
+ on_cb<T extends keyof TypeMapInterface>(event: T, listener: (...args: TypeMapInterface[T]) => void): (...args: TypeMapInterface[T]) => void;
794
+ on_rm<T extends keyof TypeMapInterface>(event: T, listener: (...args: TypeMapInterface[T]) => void): () => void;
795
+ static logger: MyLog;
796
+ emit<T extends keyof TypeMapInterface>(event: T, ...args: TypeMapInterface[T]): boolean;
797
+ removeAllListeners<T extends keyof TypeMapInterface>(event: T): this;
798
+ off<T extends keyof TypeMapInterface>(event: T, listener: (...args: TypeMapInterface[T]) => void): this;
799
+ once<T extends keyof TypeMapInterface>(event: T, listener: (...args: TypeMapInterface[T]) => void): this;
800
+ prependListener<T extends keyof TypeMapInterface>(event: keyof TypeMapInterface, listener: (...args: any[]) => void): this;
801
+ prependOnceListener<T extends keyof TypeMapInterface>(event: keyof TypeMapInterface, listener: (...args: any[]) => void): this;
802
+ removeListener<T extends keyof TypeMapInterface>(event: keyof TypeMapInterface, listener: (...args: any[]) => void): this;
803
+ setMaxListeners(n: number): this;
804
+ getMaxListeners(): number;
805
+ listeners<T extends keyof TypeMapInterface>(event: keyof TypeMapInterface): Function[];
806
+ rawListeners<T extends keyof TypeMapInterface>(event: keyof TypeMapInterface): Function[];
807
+ eventNames(): Array<keyof TypeMapInterface>;
808
+ listenerCount(type: string): number;
809
+ }
810
+
811
+ declare const EMPTY_PLACEHOLDER = "-";
812
+ declare const TOKEN_KEY = "\u03A3(\u3063 \u00B0\u0414 \u00B0;)\u3063";
813
+ declare const ARG_URS1_KEY = "usr1";
814
+ declare const ARG_URS2_KEY = "usr2";
815
+ declare const noop: () => void;
816
+ declare const ROMAN_NUMERALS: {
817
+ 1: string;
818
+ 2: string;
819
+ 3: string;
820
+ 4: string;
821
+ 5: string;
822
+ 6: string;
823
+ 7: string;
824
+ 8: string;
825
+ 9: string;
826
+ 10: string;
827
+ };
828
+
829
+ type Dayjs = dayjs.Dayjs;
830
+ type DayjsConfigType = dayjs.ConfigType;
831
+ declare function getMomentObj(s: DayjsConfigType): Dayjs;
832
+ declare const formatDate: ((s?: any) => string | null) & {
833
+ format: "YYYY-MM-DD";
834
+ };
835
+ declare const formatDateTime: ((s?: any) => string | null) & {
836
+ format: "YYYY-MM-DD HH:mm:ss";
837
+ };
838
+ declare const formatDateTimeNoSecond: ((s?: any) => string | null) & {
839
+ format: "YYYY-MM-DD HH:mm";
840
+ };
841
+ declare const formatTime: ((s?: any) => string | null) & {
842
+ format: "HH:mm:ss";
843
+ };
844
+ declare function getMomentRange(m?: any): {
845
+ 昨天: [dayjs.Dayjs, dayjs.Dayjs];
846
+ 今天: [dayjs.Dayjs, dayjs.Dayjs];
847
+ 明天: [dayjs.Dayjs, dayjs.Dayjs];
848
+ 上周: [dayjs.Dayjs, dayjs.Dayjs];
849
+ 近一周: [dayjs.Dayjs, dayjs.Dayjs];
850
+ 下周: [dayjs.Dayjs, dayjs.Dayjs];
851
+ 上月: [dayjs.Dayjs, dayjs.Dayjs];
852
+ 近一月: [dayjs.Dayjs, dayjs.Dayjs];
853
+ 下月: [dayjs.Dayjs, dayjs.Dayjs];
854
+ 近一年: [dayjs.Dayjs, dayjs.Dayjs];
855
+ 年初至今: [dayjs.Dayjs, dayjs.Dayjs];
856
+ };
857
+ declare function presets_date(): {
858
+ label: string;
859
+ value: any;
860
+ }[];
861
+ declare function isMoment(m: any): boolean;
862
+ /**
863
+ * 获取若干天后的日期
864
+ */
865
+ declare function getFutureDate(num: number): any;
866
+ declare function dayjs_quarter(input: Dayjs, which_quarter?: number): [Dayjs, number];
867
+ declare function diff_between(a: ConfigType, b: ConfigType, unit: QUnitType | OpUnitType, float?: boolean): number;
868
+
869
+ interface ISpectialOption {
870
+ sp?: ICommonOption[];
871
+ start?: number;
872
+ useString?: boolean;
873
+ useDefault?: boolean;
874
+ }
875
+ declare const optionKey其他 = 99;
876
+ declare const optionKey不详 = 100;
877
+ declare const optionKey否 = 0;
878
+ type TOptionKey = string[] | string;
879
+ type TGetOptionKey = () => TOptionKey;
880
+ type TOptions<T extends TOptionKey | TGetOptionKey> = T extends TOptionKey ? ICommonOption[] : () => ICommonOption[];
881
+ declare function getSimpleOptions<T extends TOptionKey | TGetOptionKey>(_arr: T, options?: ISpectialOption): TOptions<T>;
882
+ declare function getSameOptions<T extends TOptionKey | TGetOptionKey>(_arr: T): TOptions<T>;
883
+ declare function getDualModeOptions<T extends TOptionKey | TGetOptionKey>(arr: T, options?: ISpectialOption): readonly [TOptions<T>, TOptions<T>];
884
+ declare function getPresetOptions(key: string, pure?: boolean): ICommonOption[];
885
+ declare function getOptionLabel(k: string, value: any, defaultLabel?: string): string;
886
+ declare function getOptionValue(k: string, label: any): any;
887
+ declare function merge_preset_options(ops: AnyObject<() => ICommonOption[]>): void;
888
+
889
+ interface IDictionary {
890
+ id: number;
891
+ module: string;
892
+ type: number;
893
+ key: string;
894
+ name: string;
895
+ note: string;
896
+ enumerations: Partial<IEnumeration>[];
897
+ }
898
+ interface IEnumeration {
899
+ id: number;
900
+ label: string;
901
+ note: string;
902
+ value: number;
903
+ }
904
+ declare function getDictionaries(): AnyObject<IDictionary>;
905
+ /**
906
+ *
907
+ * @param value 枚举值value
908
+ * @param type string 字典类型
909
+ */
910
+ declare function getDictionariesEnumerations(type: string): Partial<IEnumeration>[];
911
+ /**
912
+ *
913
+ * @param value 枚举值value
914
+ * @param type string 字典类型
915
+ */
916
+ declare function getDictionaryLabel(type: string, value: string | number): string | null | undefined;
917
+ /**
918
+ *
919
+ * @param label 枚举值value
920
+ * @param type string 字典类型
921
+ */
922
+ declare function getDictionaryValue(type: string, label: string): number | null | undefined;
923
+ declare function merge_dict(ops: AnyObject<IDictionary>): void;
924
+
925
+ interface IOpt {
926
+ id?: string;
927
+ text?: string;
928
+ url?: string;
929
+ debug?: boolean;
930
+ allowExternal?: boolean;
931
+ cache?: boolean;
932
+ async?: boolean;
933
+ type?: 'text/css' | 'text/javascript';
934
+ charset?: string;
935
+ }
936
+ type TMixOpt = IOpt | string;
937
+ declare function create_load_src(): (items: TMixOpt | TMixOpt[], node?: HTMLHeadElement) => Promise<Element> | Promise<Element[]>;
938
+ declare function load_src(items: TMixOpt, node?: HTMLHeadElement): Promise<Element>;
939
+ declare function load_src(items: TMixOpt[], node?: HTMLHeadElement): Promise<Element[]>;
940
+
941
+ export { ARG_URS1_KEY, ARG_URS2_KEY, AggregateError, EMPTY_PLACEHOLDER, EventEmitter, MyLog, ROMAN_NUMERALS, TOKEN_KEY, all, alphabetical, assign, base64ToBinary, base64_to_image, boil, cache_fetch, calc_number, callable, camel, capitalize, chain, charToUTF8, charToUnicode, clone, cloneDeep, cluster, compose, confirm_operation, construct, copyText, counting, create_load_src, crush, dash, dayjs_quarter, debounce, defer, diff, diff_between, downloadFile, draw, dyn_cb, expect_array, filter_obj_to_url_search, first, flat, fork, formatDate, formatDateTime, formatDateTimeNoSecond, formatTime, gen_encoded_char_svg, get, getDictionaries, getDictionariesEnumerations, getDictionaryLabel, getDictionaryValue, getDualModeOptions, getFilledArray, getFuckTimeInterval, getFutureDate, getMomentObj, getMomentRange, getOptionLabel, getOptionValue, getPresetOptions, getSameOptions, getSearchParamsAll, getSearchParamsValue, getSimpleOptions, get_global, group, guard, hasOwn, identity, image_to_base64, inRange, intersects, invert, isArray, isBoolean, isDate, isEmpty, isEqual, isFloat, isFunction, isInt, isMoment, isNil, isNull, isNumber, isObject, isObjectLike, isPrimitive, isPromise, isString, isSymbol, iterate, keys, last, list, listify, load_src, lowerize, map, mapEntries, mapKeys, mapValues, max, memo, merge, merge_dict, merge_preset_options, min, noop, numberLikeCompare, objectify, omit, optionKey不详, optionKey其他, optionKey否, parallel, partial, partob, pascal, pick, presets_date, proxied, random, randomHex, random_word, range, reduce, replace, replaceOrAppend, retry, safeExec, safeGetFromFuncOrData, safe_async_call, safe_json_parse, safe_json_parse_arr, safe_json_stringify, safe_number_parse, scrollIntoView, select, series, set, setSearchParamsAll, setSearchParamsValue, shake, shift, shuffle, sift, simple_decrypt, simple_decrypt_str, simple_encrypt, simple_encrypt_str, size, sleep, snake, sort, speculate_on_display, sum, template, text_ellipsis, throttle, title, toFloat, toInt, toString, toggle, trim, tryit as try, tryit, uid, unicodeToChar, unicode_to_UTF8, unique, upperize, uuid, warpBase64Type, zip, zipToObject };
942
+ export type { AnyObject, Dayjs, DayjsConfigType, ICommonOption, PartialAll, PartialSome, PropertyKey$1 as PropertyKey, TCommonFileType };