@welshman/lib 0.0.32 → 0.0.33

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 (42) hide show
  1. package/README.md +10 -8
  2. package/build/src/Context.cjs +17 -0
  3. package/build/src/Context.cjs.map +1 -1
  4. package/build/src/Context.d.ts +17 -0
  5. package/build/src/Context.mjs +17 -0
  6. package/build/src/Context.mjs.map +1 -1
  7. package/build/src/Deferred.cjs +9 -0
  8. package/build/src/Deferred.cjs.map +1 -1
  9. package/build/src/Deferred.d.ts +11 -0
  10. package/build/src/Deferred.mjs +9 -0
  11. package/build/src/Deferred.mjs.map +1 -1
  12. package/build/src/Emitter.cjs +9 -0
  13. package/build/src/Emitter.cjs.map +1 -1
  14. package/build/src/Emitter.d.ts +9 -0
  15. package/build/src/Emitter.mjs +9 -0
  16. package/build/src/Emitter.mjs.map +1 -1
  17. package/build/src/LRUCache.cjs +16 -0
  18. package/build/src/LRUCache.cjs.map +1 -1
  19. package/build/src/LRUCache.d.ts +16 -0
  20. package/build/src/LRUCache.mjs +16 -0
  21. package/build/src/LRUCache.mjs.map +1 -1
  22. package/build/src/Tools.cjs +463 -12
  23. package/build/src/Tools.cjs.map +1 -1
  24. package/build/src/Tools.d.ts +458 -17
  25. package/build/src/Tools.mjs +459 -9
  26. package/build/src/Tools.mjs.map +1 -1
  27. package/build/src/Worker.cjs +27 -1
  28. package/build/src/Worker.cjs.map +1 -1
  29. package/build/src/Worker.d.ts +25 -0
  30. package/build/src/Worker.mjs +27 -1
  31. package/build/src/Worker.mjs.map +1 -1
  32. package/build/src/index.cjs +0 -1
  33. package/build/src/index.cjs.map +1 -1
  34. package/build/src/index.d.ts +0 -1
  35. package/build/src/index.mjs +0 -1
  36. package/build/src/index.mjs.map +1 -1
  37. package/package.json +1 -1
  38. package/build/src/Fluent.cjs +0 -47
  39. package/build/src/Fluent.cjs.map +0 -1
  40. package/build/src/Fluent.d.ts +0 -34
  41. package/build/src/Fluent.mjs +0 -43
  42. package/build/src/Fluent.mjs.map +0 -1
@@ -1,136 +1,577 @@
1
+ /** Type representing null or undefined */
1
2
  export type Nil = null | undefined;
3
+ /** Checks if a value is null or undefined */
2
4
  export declare const isNil: (x: any) => boolean;
5
+ /** Type representing an optional value */
3
6
  export type Maybe<T> = T | undefined;
7
+ /**
8
+ * Executes a function if the value is defined
9
+ * @param x - The value to check
10
+ * @param f - Function to execute if x is defined
11
+ * @returns Result of f(x) if x is defined, undefined otherwise
12
+ */
4
13
  export declare const ifLet: <T>(x: T | undefined, f: (x: T) => void) => void;
14
+ /** Function that does nothing and returns undefined */
5
15
  export declare const noop: (...args: unknown[]) => undefined;
16
+ /**
17
+ * Returns the first element of an array
18
+ * @param xs - The array
19
+ * @returns First element or undefined
20
+ */
6
21
  export declare const first: <T>(xs: T[], ...args: unknown[]) => T;
22
+ /**
23
+ * Returns the first element of the first array in a nested array
24
+ * @param xs - Array of arrays
25
+ * @returns First element of first array or undefined
26
+ */
7
27
  export declare const ffirst: <T>(xs: T[][], ...args: unknown[]) => T;
28
+ /**
29
+ * Returns the last element of an array
30
+ * @param xs - The array
31
+ * @returns Last element or undefined
32
+ */
8
33
  export declare const last: <T>(xs: T[], ...args: unknown[]) => T;
34
+ /**
35
+ * Returns the input value unchanged
36
+ * @param x - Any value
37
+ * @returns The same value
38
+ */
9
39
  export declare const identity: <T>(x: T, ...args: unknown[]) => T;
40
+ /**
41
+ * Creates a function that always returns the same value
42
+ * @param x - Value to return
43
+ * @returns Function that returns x
44
+ */
10
45
  export declare const always: <T>(x: T, ...args: unknown[]) => () => T;
46
+ /**
47
+ * Returns the logical NOT of a value
48
+ * @param x - Value to negate
49
+ * @returns !x
50
+ */
11
51
  export declare const not: (x: any, ...args: unknown[]) => boolean;
52
+ /** Converts a Maybe<number> to a number, defaulting to 0 */
12
53
  export declare const num: (x: Maybe<number>) => number;
54
+ /** Adds two numbers, handling undefined values */
13
55
  export declare const add: (x: Maybe<number>, y: Maybe<number>) => number;
56
+ /** Subtracts two numbers, handling undefined values */
14
57
  export declare const sub: (x: Maybe<number>, y: Maybe<number>) => number;
58
+ /** Multiplies two numbers, handling undefined values */
15
59
  export declare const mul: (x: Maybe<number>, y: Maybe<number>) => number;
60
+ /** Divides two numbers, handling undefined values */
16
61
  export declare const div: (x: Maybe<number>, y: number) => number;
62
+ /** Increments a number by 1, handling undefined values */
17
63
  export declare const inc: (x: Maybe<number>) => number;
64
+ /** Decrements a number by 1, handling undefined values */
18
65
  export declare const dec: (x: Maybe<number>) => number;
66
+ /** Less than comparison, handling undefined values */
19
67
  export declare const lt: (x: Maybe<number>, y: Maybe<number>) => boolean;
68
+ /** Less than or equal comparison, handling undefined values */
20
69
  export declare const lte: (x: Maybe<number>, y: Maybe<number>) => boolean;
70
+ /** Greater than comparison, handling undefined values */
21
71
  export declare const gt: (x: Maybe<number>, y: Maybe<number>) => boolean;
72
+ /** Greater than or equal comparison, handling undefined values */
22
73
  export declare const gte: (x: Maybe<number>, y: Maybe<number>) => boolean;
74
+ /** Returns maximum value in array, handling undefined values */
23
75
  export declare const max: (xs: Maybe<number>[]) => number;
76
+ /** Returns minimum value in array, handling undefined values */
24
77
  export declare const min: (xs: Maybe<number>[]) => number;
78
+ /** Returns sum of array values, handling undefined values */
25
79
  export declare const sum: (xs: Maybe<number>[]) => number;
80
+ /** Returns average of array values, handling undefined values */
26
81
  export declare const avg: (xs: Maybe<number>[]) => number;
82
+ /**
83
+ * Returns array with first n elements removed
84
+ * @param n - Number of elements to drop
85
+ * @param xs - Input array
86
+ * @returns Array with first n elements removed
87
+ */
27
88
  export declare const drop: <T>(n: number, xs: T[]) => T[];
89
+ /**
90
+ * Returns first n elements of array
91
+ * @param n - Number of elements to take
92
+ * @param xs - Input array
93
+ * @returns Array of first n elements
94
+ */
28
95
  export declare const take: <T>(n: number, xs: T[]) => T[];
96
+ /**
97
+ * Creates new object with specified keys removed
98
+ * @param ks - Keys to remove
99
+ * @param x - Source object
100
+ * @returns New object without specified keys
101
+ */
29
102
  export declare const omit: <T extends Record<string, any>>(ks: string[], x: T) => T;
103
+ /**
104
+ * Creates new object excluding entries with specified values
105
+ * @param xs - Values to exclude
106
+ * @param x - Source object
107
+ * @returns New object without entries containing specified values
108
+ */
30
109
  export declare const omitVals: <T extends Record<string, any>>(xs: any[], x: T) => T;
110
+ /**
111
+ * Creates new object with only specified keys
112
+ * @param ks - Keys to keep
113
+ * @param x - Source object
114
+ * @returns New object with only specified keys
115
+ */
31
116
  export declare const pick: <T extends Record<string, any>>(ks: string[], x: T) => T;
117
+ /**
118
+ * Generates sequence of numbers from a to b
119
+ * @param a - Start number (inclusive)
120
+ * @param b - End number (exclusive)
121
+ * @param step - Increment between numbers
122
+ * @yields Numbers in sequence
123
+ */
32
124
  export declare function range(a: number, b: number, step?: number): Generator<number, void, unknown>;
125
+ /**
126
+ * Creates new object with transformed keys
127
+ * @param f - Function to transform keys
128
+ * @param x - Source object
129
+ * @returns Object with transformed keys
130
+ */
33
131
  export declare const mapKeys: <T extends Record<string, any>>(f: (v: string) => string, x: T) => T;
132
+ /**
133
+ * Creates new object with transformed values
134
+ * @param f - Function to transform values
135
+ * @param x - Source object
136
+ * @returns Object with transformed values
137
+ */
34
138
  export declare const mapVals: <V, U>(f: (v: V) => U, x: Record<string, V>) => Record<string, U>;
139
+ /**
140
+ * Merges two objects, with left object taking precedence
141
+ * @param a - Left object
142
+ * @param b - Right object
143
+ * @returns Merged object with a's properties overriding b's
144
+ */
35
145
  export declare const mergeLeft: <T extends Record<string, any>>(a: T, b: T) => T;
146
+ /**
147
+ * Merges two objects, with right object taking precedence
148
+ * @param a - Left object
149
+ * @param b - Right object
150
+ * @returns Merged object with b's properties overriding a's
151
+ */
36
152
  export declare const mergeRight: <T extends Record<string, any>>(a: T, b: T) => T;
153
+ /**
154
+ * Checks if a number is between two values (exclusive)
155
+ * @param bounds - Lower and upper bounds
156
+ * @param n - Number to check
157
+ * @returns True if n is between low and high
158
+ */
37
159
  export declare const between: ([low, high]: [number, number], n: number) => boolean;
160
+ /**
161
+ * Checks if a number is between two values (inclusive)
162
+ * @param bounds - Lower and upper bounds
163
+ * @param n - Number to check
164
+ * @returns True if n is between low and high
165
+ */
166
+ export declare const within: ([low, high]: [number, number], n: number) => boolean;
167
+ /**
168
+ * Generates random integer between min and max (inclusive)
169
+ * @param min - Minimum value
170
+ * @param max - Maximum value
171
+ * @returns Random integer
172
+ */
38
173
  export declare const randomInt: (min?: number, max?: number) => number;
174
+ /**
175
+ * Generates random string ID
176
+ * @returns Random string suitable for use as an ID
177
+ */
39
178
  export declare const randomId: () => string;
179
+ /**
180
+ * Removes protocol (http://, https://, etc) from URL
181
+ * @param url - URL to process
182
+ * @returns URL without protocol
183
+ */
40
184
  export declare const stripProtocol: (url: string) => string;
185
+ /**
186
+ * Formats URL for display by removing protocol, www, and trailing slash
187
+ * @param url - URL to format
188
+ * @returns Formatted URL
189
+ */
41
190
  export declare const displayUrl: (url: string) => string;
191
+ /**
192
+ * Extracts and formats domain from URL
193
+ * @param url - URL to process
194
+ * @returns Formatted domain name
195
+ */
42
196
  export declare const displayDomain: (url: string) => string;
197
+ /**
198
+ * Creates a promise that resolves after specified time
199
+ * @param t - Time in milliseconds
200
+ * @returns Promise that resolves after t milliseconds
201
+ */
43
202
  export declare const sleep: (t: number) => Promise<unknown>;
203
+ /**
204
+ * Concatenates multiple arrays, filtering out null/undefined
205
+ * @param xs - Arrays to concatenate
206
+ * @returns Combined array
207
+ */
44
208
  export declare const concat: <T>(...xs: T[][]) => T[];
209
+ /**
210
+ * Appends element to array
211
+ * @param x - Element to append
212
+ * @param xs - Array to append to
213
+ * @returns New array with element appended
214
+ */
45
215
  export declare const append: <T>(x: T, xs: T[]) => T[];
216
+ /**
217
+ * Creates union of two arrays
218
+ * @param a - First array
219
+ * @param b - Second array
220
+ * @returns Array containing unique elements from both arrays
221
+ */
46
222
  export declare const union: <T>(a: T[], b: T[]) => T[];
223
+ /**
224
+ * Returns elements common to both arrays
225
+ * @param a - First array
226
+ * @param b - Second array
227
+ * @returns Array of elements present in both inputs
228
+ */
47
229
  export declare const intersection: <T>(a: T[], b: T[]) => T[];
230
+ /**
231
+ * Returns elements in first array not present in second
232
+ * @param a - Source array
233
+ * @param b - Array of elements to exclude
234
+ * @returns Array containing elements unique to first array
235
+ */
48
236
  export declare const difference: <T>(a: T[], b: T[]) => T[];
237
+ /**
238
+ * Removes all instances of an element from array
239
+ * @param a - Element to remove
240
+ * @param xs - Source array
241
+ * @returns New array with element removed
242
+ */
49
243
  export declare const remove: <T>(a: T, xs: T[]) => T[];
244
+ /**
245
+ * Returns elements from second array not present in first
246
+ * @param a - Array of elements to exclude
247
+ * @param b - Source array
248
+ * @returns Filtered array
249
+ */
50
250
  export declare const without: <T>(a: T[], b: T[]) => T[];
251
+ /**
252
+ * Toggles presence of element in array
253
+ * @param x - Element to toggle
254
+ * @param xs - Source array
255
+ * @returns New array with element added or removed
256
+ */
51
257
  export declare const toggle: <T>(x: T, xs: T[]) => T[];
258
+ /**
259
+ * Constrains number between min and max values
260
+ * @param bounds - Minimum and maximum allowed values
261
+ * @param n - Number to clamp
262
+ * @returns Clamped value
263
+ */
52
264
  export declare const clamp: ([min, max]: [number, number], n: number) => number;
265
+ /**
266
+ * Safely parses JSON string
267
+ * @param json - JSON string to parse
268
+ * @returns Parsed object or null if invalid
269
+ */
53
270
  export declare const parseJson: (json: string | Nil) => any;
271
+ /**
272
+ * Gets and parses JSON from localStorage
273
+ * @param k - Storage key
274
+ * @returns Parsed value or undefined if invalid/missing
275
+ */
54
276
  export declare const getJson: (k: string) => any;
277
+ /**
278
+ * Stringifies and stores value in localStorage
279
+ * @param k - Storage key
280
+ * @param v - Value to store
281
+ */
55
282
  export declare const setJson: (k: string, v: any) => void;
283
+ /**
284
+ * Safely executes function and handles errors
285
+ * @param f - Function to execute
286
+ * @param onError - Optional error handler
287
+ * @returns Function result or undefined if error
288
+ */
56
289
  export declare const tryCatch: <T>(f: () => T, onError?: ((e: Error) => void) | undefined) => T | undefined;
290
+ /**
291
+ * Truncates string to length, breaking at word boundaries
292
+ * @param s - String to truncate
293
+ * @param l - Maximum length
294
+ * @param suffix - String to append if truncated
295
+ * @returns Truncated string
296
+ */
57
297
  export declare const ellipsize: (s: string, l: number, suffix?: string) => string;
298
+ /**
299
+ * Checks if value is a plain object
300
+ * @param obj - Value to check
301
+ * @returns True if value is a plain object
302
+ */
58
303
  export declare const isPojo: (obj: any) => boolean;
304
+ /**
305
+ * Deep equality comparison
306
+ * @param a - First value
307
+ * @param b - Second value
308
+ * @returns True if values are deeply equal
309
+ */
59
310
  export declare const equals: (a: any, b: any) => boolean;
311
+ /** Returns a function that gets the nth element of an array */
60
312
  export declare const nth: (i: number) => <T>(xs: T[], ...args: unknown[]) => T;
313
+ /** Returns a function that checks if nth element equals value */
61
314
  export declare const nthEq: (i: number, v: any) => (xs: any[], ...args: unknown[]) => boolean;
315
+ /** Returns a function that checks if nth element does not equal value */
62
316
  export declare const nthNe: (i: number, v: any) => (xs: any[], ...args: unknown[]) => boolean;
317
+ /** Returns a function that checks equality with value */
63
318
  export declare const eq: <T>(v: T) => (x: T) => boolean;
319
+ /** Returns a function that checks inequality with value */
64
320
  export declare const ne: <T>(v: T) => (x: T) => boolean;
321
+ /** Returns a function that gets property value from object */
65
322
  export declare const prop: (k: string) => <T>(x: Record<string, T>) => T;
323
+ /** Returns a function that adds/updates property on object */
66
324
  export declare const assoc: <K extends string, T, U>(k: K, v: T) => (o: U) => U & Record<K, T>;
325
+ /** Generates a hash string from input string */
67
326
  export declare const hash: (s: string) => string;
327
+ /** Splits array into two parts at index */
68
328
  export declare const splitAt: <T>(n: number, xs: T[]) => T[][];
329
+ /** Inserts element into array at index */
69
330
  export declare const insert: <T>(n: number, x: T, xs: T[]) => T[];
331
+ /** Returns random element from array */
70
332
  export declare const choice: <T>(xs: T[]) => T;
333
+ /** Returns shuffled copy of iterable */
71
334
  export declare const shuffle: <T>(xs: Iterable<T>) => T[];
335
+ /** Returns n random elements from array */
72
336
  export declare const sample: <T>(n: number, xs: T[]) => T[];
337
+ /** Checks if value is iterable */
73
338
  export declare const isIterable: (x: any) => boolean;
339
+ /** Ensures value is iterable by wrapping in array if needed */
74
340
  export declare const toIterable: (x: any) => any;
341
+ /** Ensures value is array by wrapping if needed */
75
342
  export declare const ensurePlural: <T>(x: T | T[]) => T[];
343
+ /** Converts string or number to number */
76
344
  export declare const ensureNumber: (x: number | string) => number;
345
+ /**
346
+ * Creates object from array of key-value pairs
347
+ * @param pairs - Array of [key, value] tuples
348
+ * @returns Object with keys and values from pairs
349
+ */
77
350
  export declare const fromPairs: <T>(pairs: [k?: string | undefined, v?: T | undefined, ...args: unknown[]][]) => Record<string, T>;
351
+ /**
352
+ * Flattens array of arrays into single array
353
+ * @param xs - Array of arrays to flatten
354
+ * @returns Flattened array
355
+ */
78
356
  export declare const flatten: <T>(xs: T[][]) => T[];
357
+ /**
358
+ * Splits array into two arrays based on predicate
359
+ * @param f - Function to test elements
360
+ * @param xs - Array to partition
361
+ * @returns Tuple of [matching, non-matching] arrays
362
+ */
79
363
  export declare const partition: <T>(f: (x: T) => boolean, xs: T[]) => T[][];
364
+ /**
365
+ * Returns array with duplicate elements removed
366
+ * @param xs - Array with possible duplicates
367
+ * @returns Array with unique elements
368
+ */
80
369
  export declare const uniq: <T>(xs: T[]) => T[];
370
+ /**
371
+ * Returns array with elements unique by key function
372
+ * @param f - Function to generate key for each element
373
+ * @param xs - Input array
374
+ * @returns Array with elements unique by key
375
+ */
81
376
  export declare const uniqBy: <T>(f: (x: T) => any, xs: T[]) => T[];
377
+ /**
378
+ * Returns sorted copy of array
379
+ * @param xs - Array to sort
380
+ * @returns New sorted array
381
+ */
82
382
  export declare const sort: <T>(xs: T[]) => T[];
383
+ /**
384
+ * Returns array sorted by key function
385
+ * @param f - Function to generate sort key
386
+ * @param xs - Array to sort
387
+ * @returns Sorted array
388
+ */
83
389
  export declare const sortBy: <T>(f: (x: T) => any, xs: T[]) => T[];
390
+ /**
391
+ * Groups array elements by key function
392
+ * @param f - Function to generate group key
393
+ * @param xs - Array to group
394
+ * @returns Map of groups
395
+ */
84
396
  export declare const groupBy: <T, K>(f: (x: T) => K, xs: T[]) => Map<K, T[]>;
397
+ /**
398
+ * Creates map from array using key function
399
+ * @param f - Function to generate key
400
+ * @param xs - Array to index
401
+ * @returns Map of values by key
402
+ */
85
403
  export declare const indexBy: <T, K>(f: (x: T) => K, xs: T[]) => Map<K, T>;
404
+ /**
405
+ * Creates array of specified length using generator function
406
+ * @param n - Length of array
407
+ * @param f - Function to generate each element
408
+ * @returns Generated array
409
+ */
86
410
  export declare const initArray: <T>(n: number, f: () => T) => T[];
411
+ /**
412
+ * Splits array into chunks of specified length
413
+ * @param chunkLength - Maximum length of each chunk
414
+ * @param xs - Array to split
415
+ * @returns Array of chunks
416
+ */
87
417
  export declare const chunk: <T>(chunkLength: number, xs: T[]) => T[][];
418
+ /**
419
+ * Splits array into specified number of chunks
420
+ * @param n - Number of chunks
421
+ * @param xs - Array to split
422
+ * @returns Array of n chunks
423
+ */
88
424
  export declare const chunks: <T>(n: number, xs: T[]) => T[][];
425
+ /**
426
+ * Creates function that only executes once
427
+ * @param f - Function to wrap
428
+ * @returns Function that executes f only on first call
429
+ */
89
430
  export declare const once: (f: (...args: any) => void) => (...args: any) => void;
431
+ /**
432
+ * Memoizes function results based on arguments
433
+ * @param f - Function to memoize
434
+ * @returns Memoized function
435
+ */
90
436
  export declare const memoize: <T>(f: (...args: any[]) => T) => (...args: any[]) => T;
437
+ /**
438
+ * Creates throttled version of function
439
+ * @param ms - Minimum time between calls
440
+ * @param f - Function to throttle
441
+ * @returns Throttled function
442
+ */
91
443
  export declare const throttle: <F extends (...args: any[]) => any>(ms: number, f: F) => F | ((...thisArgs: Parameters<F>) => void);
444
+ /**
445
+ * Creates throttled function that returns cached value
446
+ * @param ms - Minimum time between updates
447
+ * @param f - Function to throttle
448
+ * @returns Function returning latest value
449
+ */
92
450
  export declare const throttleWithValue: <T>(ms: number, f: () => T) => () => T;
451
+ /**
452
+ * Creates batching function that collects items
453
+ * @param t - Time window for batching
454
+ * @param f - Function to process batch
455
+ * @returns Function that adds items to batch
456
+ */
93
457
  export declare const batch: <T>(t: number, f: (xs: T[]) => void) => (x: T) => void;
458
+ /**
459
+ * Creates batching function that returns results
460
+ * @param t - Time window for batching
461
+ * @param execute - Function to process batch
462
+ * @returns Function that returns promise of result
463
+ */
94
464
  export declare const batcher: <T, U>(t: number, execute: (request: T[]) => U[] | Promise<U[]>) => (request: T) => Promise<U>;
465
+ /**
466
+ * Adds value to Set at key in object
467
+ * @param m - Object mapping keys to Sets
468
+ * @param k - Key to add to
469
+ * @param v - Value to add
470
+ */
95
471
  export declare const addToKey: <T>(m: Record<string, Set<T>>, k: string, v: T) => void;
472
+ /**
473
+ * Pushes value to array at key in object
474
+ * @param m - Object mapping keys to arrays
475
+ * @param k - Key to push to
476
+ * @param v - Value to push
477
+ */
96
478
  export declare const pushToKey: <T>(m: Record<string, T[]>, k: string, v: T) => void;
479
+ /**
480
+ * Adds value to Set at key in Map
481
+ * @param m - Map of Sets
482
+ * @param k - Key to add to
483
+ * @param v - Value to add
484
+ */
97
485
  export declare const addToMapKey: <K, T>(m: Map<K, Set<T>>, k: K, v: T) => void;
486
+ /**
487
+ * Pushes value to array at key in Map
488
+ * @param m - Map of arrays
489
+ * @param k - Key to push to
490
+ * @param v - Value to push
491
+ */
98
492
  export declare const pushToMapKey: <K, T>(m: Map<K, T[]>, k: K, v: T) => void;
493
+ /**
494
+ * Switches on key in object, with default fallback
495
+ * @param k - Key to look up
496
+ * @param m - Object with values and optional default
497
+ * @returns Value at key or default value
498
+ */
99
499
  export declare const switcher: <T>(k: string, m: Record<string, T>) => T;
500
+ /** One minute in seconds */
100
501
  export declare const MINUTE = 60;
502
+ /** One hour in seconds */
101
503
  export declare const HOUR: number;
504
+ /** One day in seconds */
102
505
  export declare const DAY: number;
506
+ /** One week in seconds */
103
507
  export declare const WEEK: number;
508
+ /** One month in seconds (approximate) */
104
509
  export declare const MONTH: number;
510
+ /** One quarter in seconds (approximate) */
105
511
  export declare const QUARTER: number;
512
+ /** One year in seconds (approximate) */
106
513
  export declare const YEAR: number;
514
+ /**
515
+ * Multiplies time unit by count
516
+ * @param unit - Time unit in seconds
517
+ * @param count - Number of units
518
+ * @returns Total seconds
519
+ */
107
520
  export declare const int: (unit: number, count?: number) => number;
521
+ /** Returns current Unix timestamp in seconds */
108
522
  export declare const now: () => number;
523
+ /**
524
+ * Returns Unix timestamp from specified time ago
525
+ * @param unit - Time unit in seconds
526
+ * @param count - Number of units
527
+ * @returns Timestamp in seconds
528
+ */
109
529
  export declare const ago: (unit: number, count?: number) => number;
530
+ /**
531
+ * Converts seconds to milliseconds
532
+ * @param seconds - Time in seconds
533
+ * @returns Time in milliseconds
534
+ */
110
535
  export declare const ms: (seconds: number) => number;
536
+ /** Options for fetch requests */
111
537
  type FetchOpts = {
112
538
  method?: string;
113
539
  headers?: Record<string, string | boolean>;
114
540
  body?: string | FormData;
115
541
  };
542
+ /**
543
+ * Fetches JSON from URL with options
544
+ * @param url - URL to fetch from
545
+ * @param opts - Fetch options
546
+ * @returns Promise of parsed JSON response
547
+ */
116
548
  export declare const fetchJson: (url: string, opts?: FetchOpts) => Promise<any>;
549
+ /**
550
+ * Posts JSON data to URL
551
+ * @param url - URL to post to
552
+ * @param data - Data to send
553
+ * @param opts - Additional fetch options
554
+ * @returns Promise of parsed JSON response
555
+ */
117
556
  export declare const postJson: <T>(url: string, data: T, opts?: FetchOpts) => Promise<any>;
118
- export declare const uploadFile: (url: string, fileObj: File) => Promise<any>;
119
- export declare const hexToBech32: (prefix: string, url: string) => `${Lowercase<string>}1${string}`;
557
+ /**
558
+ * Uploads file to URL
559
+ * @param url - Upload URL
560
+ * @param file - File to upload
561
+ * @returns Promise of parsed JSON response
562
+ */
563
+ export declare const uploadFile: (url: string, file: File) => Promise<any>;
564
+ /**
565
+ * Converts hex string to bech32 format
566
+ * @param prefix - Bech32 prefix
567
+ * @param hex - Hex string to convert
568
+ * @returns Bech32 encoded string
569
+ */
570
+ export declare const hexToBech32: (prefix: string, hex: string) => `${Lowercase<string>}1${string}`;
571
+ /**
572
+ * Converts bech32 string to hex format
573
+ * @param b32 - Bech32 string to convert
574
+ * @returns Hex encoded string
575
+ */
120
576
  export declare const bech32ToHex: (b32: string) => string;
121
- export type OmitStatics<T, S extends string> = T extends {
122
- new (...args: infer A): infer R;
123
- } ? {
124
- new (...args: A): R;
125
- } & Omit<T, S> : Omit<T, S>;
126
- export type OmitAllStatics<T extends {
127
- new (...args: any[]): any;
128
- prototype: any;
129
- }> = T extends {
130
- new (...args: infer A): infer R;
131
- prototype: infer P;
132
- } ? {
133
- new (...args: A): R;
134
- prototype: P;
135
- } : never;
136
577
  export {};