radashi 12.1.0 → 12.2.0-beta.0dc9c8a

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