radashi 12.1.0-pr11.e33bd36

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,746 @@
1
+ /**
2
+ * Sort an array without modifying it and return the newly sorted
3
+ * value. Allows for a string sorting value.
4
+ */
5
+ declare const alphabetical: <T>(array: readonly T[], getter: (item: T) => string, dir?: 'asc' | 'desc') => T[];
6
+
7
+ /**
8
+ * Go through a list of items, starting with the first item, and
9
+ * comparing with the second. Keep the one you want then compare that
10
+ * to the next item in the list with the same
11
+ *
12
+ * Ex. const greatest = () => boil(numbers, (a, b) => a > b)
13
+ */
14
+ declare const boil: <T>(array: readonly T[], compareFunc: (a: T, b: T) => T) => T | null;
15
+
16
+ /**
17
+ * Splits a single list into many lists of the desired size. If given
18
+ * a list of 10 items and a size of 2, it will return 5 lists with 2
19
+ * items each
20
+ */
21
+ declare const cluster: <T>(list: readonly T[], size?: number) => T[][];
22
+
23
+ declare const counting: <T, TId extends string | number | symbol>(list: readonly T[], identity: (item: T) => TId) => Record<TId, number>;
24
+
25
+ /**
26
+ * Returns all items from the first list that do not exist in the
27
+ * second list.
28
+ */
29
+ declare const diff: <T>(root: readonly T[], other: readonly T[], identity?: (item: T) => string | number | symbol) => T[];
30
+
31
+ /**
32
+ * Get the first item in an array or a default value
33
+ */
34
+ declare const first: <T>(array: readonly T[], defaultValue?: T | null | undefined) => T | null | undefined;
35
+
36
+ /**
37
+ * Given an array of arrays, returns a single dimensional array with
38
+ * all items in it.
39
+ */
40
+ declare const flat: <T>(lists: readonly T[][]) => T[];
41
+
42
+ /**
43
+ * Split an array into two array based on a true/false condition
44
+ * function
45
+ */
46
+ declare const fork: <T>(list: readonly T[], condition: (item: T) => boolean) => [T[], T[]];
47
+
48
+ /**
49
+ * Sorts an array of items into groups. The return value is a map
50
+ * where the keys are the group ids the given getGroupId function
51
+ * produced and the value is an array of each item in that group.
52
+ */
53
+ declare const group: <T, Key extends string | number | symbol>(array: readonly T[], getGroupId: (item: T) => Key) => Partial<Record<Key, T[]>>;
54
+
55
+ /**
56
+ * Given two arrays, returns true if any elements intersect
57
+ */
58
+ declare const intersects: <T, K>(listA: readonly T[], listB: readonly T[], identity?: ((t: T) => K) | undefined) => boolean;
59
+
60
+ /**
61
+ * Like a reduce but does not require an array. Only need a number and
62
+ * will iterate the function as many times as specified.
63
+ *
64
+ * NOTE: This is NOT zero indexed. If you pass count=5 you will get 1,
65
+ * 2, 3, 4, 5 iteration in the callback function
66
+ */
67
+ declare const iterate: <T>(count: number, func: (currentValue: T, iteration: number) => T, initValue: T) => T;
68
+
69
+ /**
70
+ * Get the last item in an array or a default value
71
+ */
72
+ declare const last: <T>(array: readonly T[], defaultValue?: T | null | undefined) => T | null | undefined;
73
+
74
+ /**
75
+ * Creates a list of given start, end, value, and step parameters.
76
+ *
77
+ * @example
78
+ * list(3) // 0, 1, 2, 3
79
+ * list(0, 3) // 0, 1, 2, 3
80
+ * list(0, 3, 'y') // y, y, y, y
81
+ * list(0, 3, () => 'y') // y, y, y, y
82
+ * list(0, 3, i => i) // 0, 1, 2, 3
83
+ * list(0, 3, i => `y${i}`) // y0, y1, y2, y3
84
+ * list(0, 3, obj) // obj, obj, obj, obj
85
+ * list(0, 6, i => i, 2) // 0, 2, 4, 6
86
+ */
87
+ declare const list: <T = number>(startOrLength: number, end?: number, valueOrMapper?: T | ((i: number) => T) | undefined, step?: number) => T[];
88
+
89
+ /**
90
+ * Max gets the greatest value from a list
91
+ *
92
+ * @example
93
+ * max([ 2, 3, 5]) == 5
94
+ * max([{ num: 1 }, { num: 2 }], x => x.num) == { num: 2 }
95
+ */
96
+ declare function max(array: readonly [number, ...number[]]): number;
97
+ declare function max(array: readonly number[]): number | null;
98
+ declare function max<T>(array: readonly T[], getter: (item: T) => number): T | null;
99
+
100
+ /**
101
+ * Given two lists of the same type, iterate the first list and
102
+ * replace items matched by the matcher func in the first place.
103
+ */
104
+ declare const merge: <T>(root: readonly T[], others: readonly T[], matcher: (item: T) => any) => readonly T[];
105
+
106
+ /**
107
+ * Min gets the smallest value from a list
108
+ *
109
+ * @example
110
+ * min([1, 2, 3, 4]) == 1
111
+ * min([{ num: 1 }, { num: 2 }], x => x.num) == { num: 1 }
112
+ */
113
+ declare function min(array: readonly [number, ...number[]]): number;
114
+ declare function min(array: readonly number[]): number | null;
115
+ declare function min<T>(array: readonly T[], getter: (item: T) => number): T | null;
116
+
117
+ /**
118
+ * Convert an array to a dictionary by mapping each item into a
119
+ * dictionary key & value
120
+ */
121
+ 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>;
122
+
123
+ /**
124
+ * Creates a generator that will produce an iteration through the
125
+ * range of number as requested.
126
+ *
127
+ * @example
128
+ * range(3) // yields 0, 1, 2, 3
129
+ * range(0, 3) // yields 0, 1, 2, 3
130
+ * range(0, 3, 'y') // yields y, y, y, y
131
+ * range(0, 3, () => 'y') // yields y, y, y, y
132
+ * range(0, 3, i => i) // yields 0, 1, 2, 3
133
+ * range(0, 3, i => `y${i}`) // yields y0, y1, y2, y3
134
+ * range(0, 3, obj) // yields obj, obj, obj, obj
135
+ * range(0, 6, i => i, 2) // yields 0, 2, 4, 6
136
+ */
137
+ declare function range<T = number>(startOrLength: number, end?: number, valueOrMapper?: T | ((i: number) => T), step?: number): Generator<T>;
138
+
139
+ /**
140
+ * Replace an element in an array with a new item without modifying
141
+ * the array and return the new value
142
+ */
143
+ declare const replace: <T>(list: readonly T[], newItem: T, match: (item: T, idx: number) => boolean) => T[];
144
+
145
+ /**
146
+ * Replace an item in an array by a match function condition. If no
147
+ * items match the function condition, appends the new item to the end
148
+ * of the list.
149
+ */
150
+ declare const replaceOrAppend: <T>(list: readonly T[], newItem: T, match: (a: T, idx: number) => boolean) => T[];
151
+
152
+ /**
153
+ * Select performs a filter and a mapper inside of a reduce, only
154
+ * iterating the list one time.
155
+ *
156
+ * @example
157
+ * select([1, 2, 3, 4], x => x*x, x > 2) == [9, 16]
158
+ */
159
+ declare const select: <T, K>(array: readonly T[], mapper: (item: T, index: number) => K, condition: (item: T, index: number) => boolean) => K[];
160
+
161
+ /**
162
+ * Shift array items by n steps If n > 0 items will shift n steps to
163
+ * the right If n < 0 items will shift n steps to the left
164
+ */
165
+ declare function shift<T>(arr: Array<T>, n: number): T[];
166
+
167
+ type Falsy = null | undefined | false | '' | 0 | 0n;
168
+ /**
169
+ * Given a list returns a new list with only truthy values
170
+ */
171
+ declare const sift: <T>(list: readonly (Falsy | T)[]) => T[];
172
+
173
+ /**
174
+ * Sort an array without modifying it and return the newly sorted
175
+ * value
176
+ */
177
+ declare const sort: <T>(array: readonly T[], getter: (item: T) => number, desc?: boolean) => T[];
178
+
179
+ /**
180
+ * Sum all numbers in an array. Optionally provide a function to
181
+ * convert objects in the array to number values.
182
+ */
183
+ declare function sum<T extends number>(array: readonly T[]): number;
184
+ declare function sum<T extends object>(array: readonly T[], fn: (item: T) => number): number;
185
+
186
+ /**
187
+ * If the item matching the condition already exists in the list it
188
+ * will be removed. If it does not it will be added.
189
+ */
190
+ declare const toggle: <T>(list: readonly T[], item: T, toKey?: ((item: T, idx: number) => number | string | symbol) | null | undefined, options?: {
191
+ strategy?: 'prepend' | 'append';
192
+ }) => T[];
193
+
194
+ /**
195
+ * Given a list of items returns a new list with only unique items.
196
+ * Accepts an optional identity function to convert each item in the
197
+ * list to a comparable identity value
198
+ */
199
+ declare const unique: <T, K extends string | number | symbol>(array: readonly T[], toKey?: ((item: T) => K) | undefined) => T[];
200
+
201
+ /**
202
+ * Creates an array of grouped elements, the first of which contains
203
+ * the first elements of the given arrays, the second of which
204
+ * contains the second elements of the given arrays, and so on.
205
+ *
206
+ * Ex. const zipped = zip(['a', 'b'], [1, 2], [true, false]) // [['a',
207
+ * 1, true], ['b', 2, false]]
208
+ */
209
+ declare function zip<T1, T2, T3, T4, T5>(array1: T1[], array2: T2[], array3: T3[], array4: T4[], array5: T5[]): [T1, T2, T3, T4, T5][];
210
+ declare function zip<T1, T2, T3, T4>(array1: T1[], array2: T2[], array3: T3[], array4: T4[]): [T1, T2, T3, T4][];
211
+ declare function zip<T1, T2, T3>(array1: T1[], array2: T2[], array3: T3[]): [T1, T2, T3][];
212
+ declare function zip<T1, T2>(array1: T1[], array2: T2[]): [T1, T2][];
213
+
214
+ /**
215
+ * Creates an object mapping the specified keys to their corresponding
216
+ * values
217
+ *
218
+ * Ex. const zipped = zipToObject(['a', 'b'], [1, 2]) // { a: 1, b: 2
219
+ * } Ex. const zipped = zipToObject(['a', 'b'], (k, i) => k + i) // {
220
+ * a: 'a0', b: 'b1' } Ex. const zipped = zipToObject(['a', 'b'], 1) //
221
+ * { a: 1, b: 1 }
222
+ */
223
+ declare function zipToObject<K extends string | number | symbol, V>(keys: K[], values: V | ((key: K, idx: number) => V) | V[]): Record<K, V>;
224
+
225
+ /**
226
+ * Support for the built-in AggregateError is still new. Node < 15
227
+ * doesn't have it so patching here.
228
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AggregateError#browser_compatibility
229
+ */
230
+ declare class AggregateError extends Error {
231
+ errors: Error[];
232
+ constructor(errors?: Error[]);
233
+ }
234
+
235
+ type PromiseValues<T extends Promise<any>[]> = {
236
+ [K in keyof T]: T[K] extends Promise<infer U> ? U : never;
237
+ };
238
+ /**
239
+ * Functionally similar to Promise.all or Promise.allSettled. If any
240
+ * errors are thrown, all errors are gathered and thrown in an
241
+ * AggregateError.
242
+ *
243
+ * @example
244
+ * const [user] = await all([
245
+ * api.users.create(...),
246
+ * s3.buckets.create(...),
247
+ * slack.customerSuccessChannel.sendMessage(...)
248
+ * ])
249
+ */
250
+ declare function all<T extends [Promise<any>, ...Promise<any>[]]>(promises: T): Promise<PromiseValues<T>>;
251
+ declare function all<T extends Promise<any>[]>(promises: T): Promise<PromiseValues<T>>;
252
+ /**
253
+ * Functionally similar to Promise.all or Promise.allSettled. If any
254
+ * errors are thrown, all errors are gathered and thrown in an
255
+ * AggregateError.
256
+ *
257
+ * @example
258
+ * const { user } = await all({
259
+ * user: api.users.create(...),
260
+ * bucket: s3.buckets.create(...),
261
+ * message: slack.customerSuccessChannel.sendMessage(...)
262
+ * })
263
+ */
264
+ declare function all<T extends Record<string, Promise<any>>>(promises: T): Promise<{
265
+ [K in keyof T]: Awaited<T[K]>;
266
+ }>;
267
+
268
+ /**
269
+ * Useful when for script like things where cleanup should be done on
270
+ * fail or sucess no matter.
271
+ *
272
+ * You can call defer many times to register many defered functions
273
+ * that will all be called when the function exits in any state.
274
+ */
275
+ declare const defer: <TResponse>(func: (register: (fn: (error?: any) => any, options?: {
276
+ rethrow?: boolean;
277
+ }) => void) => Promise<TResponse>) => Promise<TResponse>;
278
+
279
+ /**
280
+ * A helper to try an async function that returns undefined if it
281
+ * fails.
282
+ *
283
+ * @example
284
+ * const result = await guard(fetchUsers)() ?? [];
285
+ */
286
+ 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;
287
+
288
+ /**
289
+ * An async map function. Works like the built-in Array.map function
290
+ * but handles an async mapper function
291
+ */
292
+ declare const map: <T, K>(array: readonly T[], asyncMapFunc: (item: T, index: number) => Promise<K>) => Promise<K[]>;
293
+
294
+ /**
295
+ * Executes many async functions in parallel. Returns the results from
296
+ * all functions as an array. After all functions have resolved, if
297
+ * any errors were thrown, they are rethrown in an instance of
298
+ * AggregateError
299
+ */
300
+ declare const parallel: <T, K>(limit: number, array: readonly T[], func: (item: T) => Promise<K>) => Promise<K[]>;
301
+
302
+ /**
303
+ * An async reduce function. Works like the built-in Array.reduce
304
+ * function but handles an async reducer function
305
+ */
306
+ declare const reduce: <T, K>(array: readonly T[], asyncReducer: (acc: K, item: T, index: number) => Promise<K>, initValue?: K | undefined) => Promise<K>;
307
+
308
+ type RetryOptions = {
309
+ times?: number;
310
+ delay?: number | null;
311
+ backoff?: (count: number) => number;
312
+ };
313
+ /**
314
+ * Retries the given function the specified number of times.
315
+ */
316
+ declare const retry: <TResponse>(options: RetryOptions, func: (exit: (err: any) => void) => Promise<TResponse>) => Promise<TResponse>;
317
+
318
+ /**
319
+ * Async wait
320
+ */
321
+ declare const sleep: (milliseconds: number) => Promise<void>;
322
+
323
+ /**
324
+ * A helper to try an async function without forking the control flow.
325
+ * Returns an error-first callback-_like_ array response as `[Error,
326
+ * result]`
327
+ */
328
+ 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];
329
+
330
+ /**
331
+ * Make an object callable. Given an object and a function the
332
+ * returned object will be a function with all the objects properties.
333
+ *
334
+ * @example
335
+ * ```typescript
336
+ * const car = callable({
337
+ * wheels: 2
338
+ * }, self => () => {
339
+ * return 'driving'
340
+ * })
341
+ *
342
+ * car.wheels // => 2
343
+ * car() // => 'driving'
344
+ * ```
345
+ */
346
+ declare const callable: <TValue, TObj extends Record<string | number | symbol, TValue>, TFunc extends (...args: any) => any>(obj: TObj, fn: (self: TObj) => TFunc) => TObj & TFunc;
347
+
348
+ declare function chain<T1 extends any[], T2, T3>(f1: (...arg: T1) => T2, f2: (arg: T2) => T3): (...arg: T1) => T3;
349
+ declare function chain<T1 extends any[], T2, T3, T4>(f1: (...arg: T1) => T2, f2: (arg: T2) => T3, f3: (arg: T3) => T4): (...arg: T1) => T4;
350
+ 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;
351
+ 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;
352
+ 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;
353
+ 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;
354
+ 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;
355
+ 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;
356
+ 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;
357
+
358
+ 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;
359
+ 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;
360
+ 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;
361
+ 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;
362
+ 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;
363
+ 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;
364
+ 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;
365
+ 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;
366
+ 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;
367
+
368
+ type DebounceFunction<TArgs extends any[]> = {
369
+ (...args: TArgs): void;
370
+ /**
371
+ * Cancels the debounced function
372
+ */
373
+ cancel(): void;
374
+ /**
375
+ * Checks if there is any invocation debounced
376
+ */
377
+ isPending(): boolean;
378
+ /**
379
+ * Runs the debounced function immediately
380
+ */
381
+ flush(...args: TArgs): void;
382
+ };
383
+ /**
384
+ * Given a delay and a function returns a new function that will only
385
+ * call the source function after delay milliseconds have passed
386
+ * without any invocations.
387
+ *
388
+ * The debounce function comes with a `cancel` method to cancel
389
+ * delayed `func` invocations and a `flush` method to invoke them
390
+ * immediately
391
+ */
392
+ declare const debounce: <TArgs extends any[]>({ delay }: {
393
+ delay: number;
394
+ }, func: (...args: TArgs) => any) => DebounceFunction<TArgs>;
395
+
396
+ /**
397
+ * Creates a memoized function. The returned function will only
398
+ * execute the source function when no value has previously been
399
+ * computed. If a ttl (milliseconds) is given previously computed
400
+ * values will be checked for expiration before being returned.
401
+ */
402
+ declare const memo: <TArgs extends any[], TResult>(func: (...args: TArgs) => TResult, options?: {
403
+ key?: ((...args: TArgs) => string) | undefined;
404
+ ttl?: number | undefined;
405
+ }) => (...args: TArgs) => TResult;
406
+
407
+ /**
408
+ * This type produces the type array of TItems with all the type items
409
+ * in TItemsToRemove removed from the start of the array type.
410
+ *
411
+ * @example
412
+ * ```
413
+ * RemoveItemsInFront<[number, number], [number]> = [number]
414
+ * RemoveItemsInFront<[File, number, string], [File, number]> = [string]
415
+ * ```
416
+ */
417
+ type RemoveItemsInFront<TItems extends any[], TItemsToRemove extends any[]> = TItems extends [...TItemsToRemove, ...infer TRest] ? TRest : TItems;
418
+ declare const partial: <T extends any[], TA extends Partial<T>, R>(fn: (...args: T) => R, ...args: TA) => (...rest: RemoveItemsInFront<T, TA>) => R;
419
+
420
+ /**
421
+ * Like partial but for unary functions that accept a single object
422
+ * argument
423
+ */
424
+ declare const partob: <T, K, PartialArgs extends Partial<T>>(fn: (args: T) => K, argobj: PartialArgs) => (restobj: Omit<T, keyof PartialArgs>) => K;
425
+
426
+ /**
427
+ * Creates a Proxy object that will dynamically call the handler
428
+ * argument when attributes are accessed
429
+ */
430
+ declare const proxied: <T, K>(handler: (propertyName: T) => K) => Record<string, K>;
431
+
432
+ type ThrottledFunction<TArgs extends any[]> = {
433
+ (...args: TArgs): void;
434
+ /**
435
+ * Checks if there is any invocation throttled
436
+ */
437
+ isThrottled(): boolean;
438
+ };
439
+ /**
440
+ * Given an interval and a function returns a new function that will
441
+ * only call the source function if interval milliseconds have passed
442
+ * since the last invocation
443
+ */
444
+ declare const throttle: <TArgs extends any[]>({ interval }: {
445
+ interval: number;
446
+ }, func: (...args: TArgs) => any) => ThrottledFunction<TArgs>;
447
+
448
+ /**
449
+ * Checks if the given number is between zero (0) and the ending
450
+ * 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. @returns
457
+ * {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
467
+ * order.
468
+ *
469
+ * @param {number} number The number to check.
470
+ * @param {number} start The start of the range. Inclusive. @param
471
+ * {number} end The end of the range. Exclusive. @returns {boolean}
472
+ * Returns `true` if `number` is in the range, else `false`.
473
+ */
474
+ declare function inRange(number: number, start: number, end: number): boolean;
475
+
476
+ declare const toInt: <T extends number | null = number>(value: any, defaultValue?: T | undefined) => number | T;
477
+
478
+ declare const toFloat: <T extends number | null = number>(value: any, defaultValue?: T | undefined) => number | T;
479
+
480
+ /**
481
+ * Merges two objects together recursivly into a new object applying
482
+ * values from right to left. Recursion only applies to child object
483
+ * properties.
484
+ */
485
+ declare const assign: <X extends Record<string | number | symbol, any>>(initial: X, override: X) => X;
486
+
487
+ /**
488
+ * Creates a shallow copy of the given obejct/value.
489
+ * @param {*} obj value to clone @returns {*} shallow clone of the
490
+ * given value
491
+ */
492
+ declare const clone: <T>(obj: T) => T;
493
+
494
+ /**
495
+ * The opposite of crush, given an object that was crushed into key
496
+ * paths and values will return the original object reconstructed.
497
+ *
498
+ * @example
499
+ * construct({ name: 'ra', 'children.0.name': 'hathor' })
500
+ * // { name: 'ra', children: [{ name: 'hathor' }] }
501
+ */
502
+ declare const construct: <TObject extends object>(obj: TObject) => object;
503
+
504
+ /**
505
+ * Flattens a deep object to a single demension, converting the keys
506
+ * to dot notation.
507
+ *
508
+ * @example
509
+ * crush({ name: 'ra', children: [{ name: 'hathor' }] })
510
+ * // { name: 'ra', 'children.0.name': 'hathor' }
511
+ */
512
+ declare const crush: <TValue extends object>(value: TValue) => object;
513
+
514
+ /**
515
+ * Dynamically get a nested value from an array or object with a
516
+ * string.
517
+ *
518
+ * @example get(person, 'friends[0].name')
519
+ */
520
+ declare const get: <TDefault = unknown>(value: any, path: string, defaultValue?: TDefault | undefined) => TDefault;
521
+
522
+ /**
523
+ * Returns a new object whose keys are the values of the given object
524
+ * and its values are the keys of the given object.
525
+ */
526
+ declare const invert: <TKey extends string | number | symbol, TValue extends string | number | symbol>(obj: Record<TKey, TValue>) => Record<TValue, TKey>;
527
+
528
+ /**
529
+ * Get a string list of all key names that exist in an object (deep).
530
+ *
531
+ * @example
532
+ * keys({ name: 'ra' }) // ['name']
533
+ * keys({ name: 'ra', children: [{ name: 'hathor' }] }) // ['name', 'children.0.name']
534
+ */
535
+ declare const keys: <TValue extends object>(value: TValue) => string[];
536
+
537
+ /**
538
+ * Convert an object to a list, mapping each entry into a list item
539
+ */
540
+ declare const listify: <TValue, TKey extends string | number | symbol, KResult>(obj: Record<TKey, TValue>, toItem: (key: TKey, value: TValue) => KResult) => KResult[];
541
+
542
+ type LowercasedKeys<T extends Record<string, any>> = {
543
+ [P in keyof T & string as Lowercase<P>]: T[P];
544
+ };
545
+ /**
546
+ * Convert all keys in an object to lower case
547
+ */
548
+ declare const lowerize: <T extends Record<string, any>>(obj: T) => LowercasedKeys<T>;
549
+
550
+ /**
551
+ * Map over all the keys to create a new object
552
+ */
553
+ 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>;
554
+
555
+ /**
556
+ * Map over all the keys of an object to return a new object
557
+ */
558
+ 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>;
559
+
560
+ /**
561
+ * Map over all the keys to create a new object
562
+ */
563
+ declare const mapValues: <TValue, TKey extends string | number | symbol, TNewValue>(obj: Record<TKey, TValue>, mapFunc: (value: TValue, key: TKey) => TNewValue) => Record<TKey, TNewValue>;
564
+
565
+ /**
566
+ * Omit a list of properties from an object returning a new object
567
+ * with the properties that remain
568
+ */
569
+ declare const omit: <T, TKeys extends keyof T>(obj: T, keys: TKeys[]) => Omit<T, TKeys>;
570
+
571
+ /**
572
+ * Pick a list of properties from an object into a new object
573
+ */
574
+ declare const pick: <T extends object, TKeys extends keyof T>(obj: T, keys: TKeys[]) => Pick<T, TKeys>;
575
+
576
+ /**
577
+ * Opposite of get, dynamically set a nested value into an object
578
+ * using a key path. Does not modify the given initial object.
579
+ *
580
+ * @example
581
+ * set({}, 'name', 'ra') // => { name: 'ra' }
582
+ * set({}, 'cards[0].value', 2) // => { cards: [{ value: 2 }] }
583
+ */
584
+ declare const set: <T extends object, K>(initial: T, path: string, value: K) => T;
585
+
586
+ /**
587
+ * Removes (shakes out) undefined entries from an object. Optional
588
+ * second argument shakes out values by custom evaluation.
589
+ */
590
+ declare const shake: <T extends object>(obj: T, filter?: (value: T[keyof T]) => boolean) => T;
591
+
592
+ type UppercasedKeys<T extends Record<string, any>> = {
593
+ [P in keyof T & string as Uppercase<P>]: T[P];
594
+ };
595
+ /**
596
+ * Convert all keys in an object to upper case
597
+ */
598
+ declare const upperize: <T extends Record<string, any>>(obj: T) => UppercasedKeys<T>;
599
+
600
+ /**
601
+ * Draw a random item from a list. Returns null if the list is empty
602
+ */
603
+ declare const draw: <T>(array: readonly T[]) => T | null;
604
+
605
+ /**
606
+ * Generates a random number between min and max
607
+ */
608
+ declare const random: (min: number, max: number) => number;
609
+
610
+ declare const shuffle: <T>(array: readonly T[]) => T[];
611
+
612
+ declare const uid: (length: number, specials?: string) => string;
613
+
614
+ /**
615
+ * Creates a series object around a list of values that should be
616
+ * treated with order.
617
+ */
618
+ declare const series: <T>(items: readonly T[], toKey?: (item: T) => string | symbol) => {
619
+ min: (a: T, b: T) => T;
620
+ max: (a: T, b: T) => T;
621
+ first: () => T;
622
+ last: () => T;
623
+ next: (current: T, defaultValue?: T | undefined) => T;
624
+ previous: (current: T, defaultValue?: T | undefined) => T;
625
+ spin: (current: T, num: number) => T;
626
+ };
627
+
628
+ /**
629
+ * Formats the given string in camel case fashion
630
+ *
631
+ * camel('hello world') -> 'helloWorld' camel('va va-VOOM') ->
632
+ * 'vaVaVoom' camel('helloWorld') -> 'helloWorld'
633
+ */
634
+ declare const camel: (str: string) => string;
635
+
636
+ /**
637
+ * Capitalize the first word of the string
638
+ *
639
+ * capitalize('hello') -> 'Hello' capitalize('va va voom') -> 'Va va
640
+ * voom'
641
+ */
642
+ declare const capitalize: (str: string) => string;
643
+
644
+ /**
645
+ * Formats the given string in dash case fashion
646
+ *
647
+ * dash('hello world') -> 'hello-world' dash('va va_VOOM') ->
648
+ * 'va-va-voom' dash('helloWord') -> 'hello-word'
649
+ */
650
+ declare const dash: (str: string) => string;
651
+
652
+ /**
653
+ * Formats the given string in pascal case fashion
654
+ *
655
+ * pascal('hello world') -> 'HelloWorld' pascal('va va boom') ->
656
+ * 'VaVaBoom'
657
+ */
658
+ declare const pascal: (str: string) => string;
659
+
660
+ /**
661
+ * Formats the given string in snake case fashion
662
+ *
663
+ * snake('hello world') -> 'hello_world' snake('va va-VOOM') ->
664
+ * 'va_va_voom' snake('helloWord') -> 'hello_world'
665
+ */
666
+ declare const snake: (str: string, options?: {
667
+ splitOnNumber?: boolean;
668
+ }) => string;
669
+
670
+ /**
671
+ * template is used to replace data by name in template strings. The
672
+ * default expression looks for {{name}} to identify names.
673
+ *
674
+ * Ex. template('Hello, {{name}}', { name: 'ray' }) Ex.
675
+ * template('Hello, <name>', { name: 'ray' }, /<(.+?)>/g)
676
+ */
677
+ declare const template: (str: string, data: Record<string, any>, regex?: RegExp) => string;
678
+
679
+ /**
680
+ * Formats the given string in title case fashion
681
+ *
682
+ * title('hello world') -> 'Hello World' title('va_va_boom') -> 'Va Va
683
+ * Boom' title('root-hook') -> 'Root Hook' title('queryItems') ->
684
+ * 'Query Items'
685
+ */
686
+ declare const title: (str: string | null | undefined) => string;
687
+
688
+ /**
689
+ * Trims all prefix and suffix characters from the given string. Like
690
+ * the builtin trim function but accepts other characters you would
691
+ * like to trim and trims multiple characters.
692
+ *
693
+ * ```typescript
694
+ * trim(' hello ') // => 'hello'
695
+ * trim('__hello__', '_') // => 'hello'
696
+ * trim('/repos/:owner/:repo/', '/') // => 'repos/:owner/:repo'
697
+ * trim('222222__hello__1111111', '12_') // => 'hello'
698
+ * ```
699
+ */
700
+ declare const trim: (str: string | null | undefined, charsToTrim?: string) => string;
701
+
702
+ declare const isArray: (arg: any) => arg is any[];
703
+
704
+ declare const isDate: (value: any) => value is Date;
705
+
706
+ declare const isEmpty: (value: any) => boolean;
707
+
708
+ declare const isEqual: <TType>(x: TType, y: TType) => boolean;
709
+
710
+ declare const isFloat: (value: any) => value is number;
711
+
712
+ declare const isFunction: (value: any) => value is Function;
713
+
714
+ declare const isInt: (value: any) => value is number;
715
+
716
+ declare const isIntString: (value: any) => value is string;
717
+
718
+ declare const isNumber: (value: any) => value is number;
719
+
720
+ declare const isObject: (value: any) => value is object;
721
+
722
+ declare const isPlainObject: (value: any) => value is object;
723
+
724
+ /**
725
+ * Checks if the given value is primitive.
726
+ *
727
+ * Primitive Types: number , string , boolean , symbol, bigint,
728
+ * undefined, null
729
+ *
730
+ * @param {*} value value to check
731
+ * @returns {boolean} result
732
+ */
733
+ declare const isPrimitive: (value: any) => boolean;
734
+
735
+ /**
736
+ * This is really a _best guess_ promise checking. You should probably
737
+ * use Promise.resolve(value) to be 100% sure you're handling it
738
+ * correctly.
739
+ */
740
+ declare const isPromise: (value: any) => value is Promise<any>;
741
+
742
+ declare const isString: (value: any) => value is string;
743
+
744
+ declare const isSymbol: (value: any) => value is symbol;
745
+
746
+ export { AggregateError, type DebounceFunction, type RetryOptions, type ThrottledFunction, all, alphabetical, assign, boil, callable, camel, capitalize, chain, clone, cluster, compose, construct, counting, crush, dash, debounce, defer, diff, draw, first, flat, fork, get, group, guard, inRange, intersects, invert, isArray, isDate, isEmpty, isEqual, isFloat, isFunction, isInt, isIntString, isNumber, isObject, isPlainObject, isPrimitive, isPromise, isString, isSymbol, iterate, keys, last, list, listify, lowerize, map, mapEntries, mapKeys, mapValues, max, memo, merge, min, objectify, omit, parallel, partial, partob, pascal, pick, proxied, random, range, reduce, replace, replaceOrAppend, retry, select, series, set, shake, shift, shuffle, sift, sleep, snake, sort, sum, template, throttle, title, toFloat, toInt, toggle, trim, tryit as try, tryit, uid, unique, upperize, zip, zipToObject };