deverything 3.3.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,861 @@
1
+ type Coords = {
2
+ lat: number;
3
+ lng: number;
4
+ };
5
+
6
+ type DateLike = Date | string | number;
7
+ type Datey = Date | string;
8
+ /**
9
+ * @example "2021-01-01T00:00:00.000Z"
10
+ */
11
+ type ISODate = string;
12
+ /**
13
+ * @example "2021-01-01"
14
+ */
15
+ type ISODay = string;
16
+ /**
17
+ * @example "2021-01"
18
+ */
19
+ type ISOMonth = string;
20
+ /**
21
+ * @example "2021"
22
+ */
23
+ type ISOYear = string;
24
+ /**
25
+ * @example "America/New_York"
26
+ */
27
+ type Timezone = string;
28
+ type DateRange<T extends DateLike = DateLike> = {
29
+ startDate: T;
30
+ endDate: T;
31
+ };
32
+ type DateSeries<T extends DateLike = DateLike> = T[];
33
+
34
+ /**
35
+ * Makes all keys required and removes undefined and null from the value types.
36
+ * @example
37
+ * type Example = {
38
+ * a: string;
39
+ * b: string | undefined;
40
+ * c?: string;
41
+ * d?: number | null;
42
+ * };
43
+ * type Result = Defined<Example>;
44
+ * {
45
+ * a: string,
46
+ * b: string,
47
+ * c: string,
48
+ * d: number
49
+ * }
50
+ */
51
+ type Defined<T> = {
52
+ [P in keyof T]-?: NonNullable<T[P]>;
53
+ };
54
+
55
+ type Dimensions = {
56
+ width: number;
57
+ height: number;
58
+ };
59
+
60
+ type VoidFn = () => void;
61
+ declare const noop: VoidFn;
62
+
63
+ type Key = string | number | symbol;
64
+ type PlainKey = string | number;
65
+ type ObjectKey<T> = keyof T;
66
+ type ObjectKeys<T> = ObjectKey<T>[];
67
+ type ObjectValue<T> = T[keyof T];
68
+ type ObjectValues<T> = ObjectValue<T>[];
69
+ type ObjectEntry<T> = {
70
+ [K in keyof T]: [K, T[K]];
71
+ }[keyof T];
72
+ type ObjectEntries<T> = ObjectEntry<T>[];
73
+ /**
74
+ * A plain object is an object that is not an array, does not have a length property, and is not a function.
75
+ * Would have been nice to call it just Object, but that's already taken by the built-in type.
76
+ */
77
+ type PlainObject<T = any> = Record<PlainKey, T> & {
78
+ length?: never;
79
+ };
80
+
81
+ type HashMap<T = any> = Record<PlainKey, T>;
82
+ type NumberMap = Record<PlainKey, number>;
83
+ type StringMap = Record<PlainKey, string>;
84
+ type BoolMap = Record<PlainKey, boolean>;
85
+ type TrueMap = Record<PlainKey, true>;
86
+
87
+ type Matrix<T> = T[][];
88
+
89
+ type Maybe<T> = T | null | undefined;
90
+ type MaybePromise<T> = Maybe<Promise<T>>;
91
+ type MaybePromiseOrValue<T> = MaybePromise<T> | T;
92
+ type MaybePromiseOrValueArray<T> = MaybePromiseOrValue<T>[];
93
+
94
+ type NonUndefined<T> = T extends undefined ? never : T;
95
+
96
+ /**
97
+ * Makes picked keys required and defined.
98
+ * @example
99
+ * type Example = {
100
+ * a: string;
101
+ * b: string | undefined;
102
+ * c?: string;
103
+ * d?: number | null;
104
+ * };
105
+ * type Result = PickDefined<Example, "a" | "b" | "d">;
106
+ * {
107
+ * a: string;
108
+ * b: string | undefined;
109
+ * d: number | null;
110
+ * }
111
+ */
112
+ type PickDefined<T, K extends keyof T> = Pick<Defined<T>, K>;
113
+
114
+ /**
115
+ * Makes picked keys required. (does not remove undefined and null from the value types)
116
+ * @example
117
+ * type Example = {
118
+ * a: string;
119
+ * b: string | undefined;
120
+ * c?: string;
121
+ * d?: number | null;
122
+ * };
123
+ * type Result = PickRequired<Example, "a" | "b" | "d">;
124
+ * {
125
+ * a: string;
126
+ * b: string | undefined;
127
+ * d: number | null;
128
+ * }
129
+ */
130
+ type PickRequired<T, K extends keyof T> = Pick<Required<T>, K>;
131
+
132
+ type Point = {
133
+ x: number;
134
+ y: number;
135
+ };
136
+
137
+ type PrismaSelect<T> = Record<keyof T, true>;
138
+
139
+ type Serialized<T> = T extends Date ? string : T extends Array<infer R> ? Array<Serialized<R>> : T extends object ? {
140
+ [K in keyof T]: Serialized<T[K]>;
141
+ } : T;
142
+
143
+ /**
144
+ * Buckets dates into groups based on a date series
145
+ * @param dateSeries Array of dates that define the buckets, must be sorted in ascending order
146
+ * @param dates Array of dates to be bucketed, must be sorted in ascending order
147
+ * @param unit The time unit to use for bucketing ('day', 'hour', 'minute', 'second')
148
+ * @returns Record mapping each bucket date to an array of dates that fall within that bucket
149
+ */
150
+ declare const bucketSortedDates: (dateSeries: ISODate[], dates: ISODate[], unit: "day" | "hour" | "minute" | "second") => Record<ISODate, ISODate[]>;
151
+
152
+ /**
153
+ *
154
+ * @description Generate a series of dates between the start and end dates
155
+ * NOTE: it does NOT include the end date
156
+ */
157
+ declare const getDateRangeSeries: (dateRange: DateRange, unit: "day" | "hour" | "minute" | "second" | "calendarMonth") => ISODate[];
158
+
159
+ /**
160
+ * @description Returns the smallest and biggest dates from an array of dates in DateRange format
161
+ * @param dates - Array of dates to find the range for
162
+ * @returns DateRange object with startDate (smallest) and endDate (biggest)
163
+ * @throws Error if the array is empty or contains invalid dates
164
+ */
165
+ declare const getDateSeriesRange: (dateSeries: DateSeries) => DateRange;
166
+
167
+ declare const isOver18: (birthDate: DateLike) => boolean;
168
+
169
+ /**
170
+ * Note: This function does not use defaults, use startOfToday instead.
171
+ *
172
+ * @param day - The date to get the start of the day for.
173
+ * @returns A new Date object set to the start of the day.
174
+ */
175
+ declare const startOfDay: (day: Date) => Date;
176
+
177
+ declare const startOfNextMonth: () => Date;
178
+
179
+ declare const startOfNextWeek: () => Date;
180
+
181
+ declare const startOfThisWeek: () => Date;
182
+
183
+ declare const startOfToday: () => Date;
184
+
185
+ declare const startOfTomorrow: () => Date;
186
+
187
+ declare const startOfUTCDay: (date: Date) => Date;
188
+
189
+ /**
190
+ * Returns the start of tomorrow (00:00:00.000) in UTC time.
191
+ *
192
+ * @param date - The date to calculate tomorrow from. Defaults to current date if not provided.
193
+ * @returns A new Date object set to the start of tomorrow in UTC time.
194
+ */
195
+ declare const startOfUTCTomorrow: () => Date;
196
+
197
+ declare const formatCamelCase: (str: string) => string;
198
+
199
+ /**
200
+ *
201
+ * @example formatCookies({}) => ""
202
+ * @example formatCookies({ session: "123", _ga: 123 }) => "session=123; _ga=123;"
203
+ */
204
+ declare const formatCookies: (object: PlainObject) => string;
205
+
206
+ /**
207
+ *
208
+ * @example formatIndexProgress(-1, 10) => [1/10] capped
209
+ * @example formatIndexProgress(1, 10) => [2/10]
210
+ * @example formatIndexProgress(11, 10) => [10/10] capped
211
+ */
212
+ declare const formatIndexProgress: (index: number, total: number) => string;
213
+
214
+ /**
215
+ *
216
+ * @example formatNumber(1000, { compact: true }) // 1K
217
+ * @example formatNumber(1111, { maxDigits: 2 }) // 1,100
218
+ * @example formatNumber(111111.123123123) // 111,111.123
219
+ * @example formatNumber(0.12345, { percentage: true, maxDigits: 2 }) // '12.35%' (rounding)
220
+ */
221
+ declare const formatNumber: (value: number, { compact, maxDigits, percentage, }?: {
222
+ compact?: boolean;
223
+ maxDigits?: number;
224
+ percentage?: boolean;
225
+ }) => string;
226
+
227
+ /**
228
+ *
229
+ * @example formatPercentage(1) => 100%
230
+ * @example formatPercentage(0, { digits: 2 }) => 0.00%
231
+ */
232
+ declare const formatPercentage: (value: number, { digits, }?: {
233
+ digits?: number;
234
+ }) => string;
235
+
236
+ declare const stringToCSSUnicode: (text: string) => string;
237
+
238
+ declare const stringToUnicode: (text: string) => string;
239
+
240
+ declare const array: <U extends (...args: any) => any>(length: number, mapFn?: U) => ReturnType<U>[];
241
+
242
+ /**
243
+ * Given 2 arrays, returns the (unique) elements that belong to each but not both at the same time.
244
+ * @example
245
+ * arrayDiff([1, 2, 3], [2, 3, 4]); // [1, 4]
246
+ */
247
+ declare const arrayDiff: (arr1: any[], arr2: any[]) => any[];
248
+
249
+ /**
250
+ * @description Given 2 arrays, returns the (unique) elements that belong to both arrays.
251
+ * @example
252
+ * arrayIntersection([1, 2, 3], [2, 3, 4]); // [2, 3]
253
+ */
254
+ declare const arrayIntersection: <T>(arr1: T[], arr2: T[]) => T[];
255
+
256
+ declare const capitalize: (string: string) => string;
257
+
258
+ declare const chunkArray: <T>(array: T[], size: number) => T[][];
259
+
260
+ declare const chunkedAll: <T>(array: T[], chunkSize: number, fn: (chunk: T[]) => Promise<any>) => Promise<any[]>;
261
+
262
+ /**
263
+ * @description Run a series of (async) functions in order and return the results
264
+ * @param array
265
+ * @param chunkSize
266
+ * @param fn
267
+ * @param options.minChunkTimeMs - Minimum time to process each chunk
268
+ */
269
+ declare const chunkedAsync: <T>(array: T[], chunkSize: number, fn: (chunk: T[], chunkIndex: number, chunks: T[][]) => Promise<any>, { minChunkTimeMs, }?: {
270
+ minChunkTimeMs?: number;
271
+ }) => Promise<any[]>;
272
+
273
+ /**
274
+ * @description Run a series of (async) functions with dynamic chunk sizes
275
+ * @param array - Array to chunk
276
+ * @param initialChunkSize - Size of initial chunk
277
+ * @param fn - Function to run on each chunk
278
+ * @param options.idealChunkDuration - Ideal time to process each chunk, the chunk size will adjust to meet this duration
279
+ * @param options.maxChunkSize - Maximum chunk size (default 200)
280
+ * @param options.minChunkDuration - Minimum time to process each chunk (useful for rate limiting)
281
+ * @param options.minChunkSize - Minimum chunk size (default 1)
282
+ * @param options.sleepTimeMs - Time to sleep between each chunk
283
+ */
284
+ declare const chunkedDynamic: <T>(array: T[], initialChunkSize: number, fn: (chunk: T[], currentChunkIndex: number) => Promise<any>, { idealChunkDuration, maxChunkSize, minChunkDuration, minChunkSize, sleepTimeMs, }?: {
285
+ idealChunkDuration?: number;
286
+ maxChunkSize?: number;
287
+ minChunkDuration?: number;
288
+ minChunkSize?: number;
289
+ sleepTimeMs?: number;
290
+ }) => Promise<any[]>;
291
+
292
+ declare const clamp: ({ number, min, max, }: {
293
+ number: number;
294
+ min: number;
295
+ max: number;
296
+ }) => number;
297
+
298
+ declare const cleanSpaces: (str: string) => string;
299
+
300
+ /**
301
+ * @returns element from array at index, if index is greater than array length, it will loop back to the start of the array
302
+ */
303
+ declare const cyclicalItem: <T>(array: T[], index: number) => T;
304
+
305
+ /**
306
+ * Print or log helper that does not break on circular references, and expands nested objects.
307
+ */
308
+ declare const dir: (arg: any, { maxDepth }?: {
309
+ maxDepth?: number;
310
+ }) => void;
311
+
312
+ declare const enumKeys: <T extends object>(arg: T) => ObjectKeys<T>;
313
+
314
+ declare const enumValues: <T extends object>(enumObject: T) => ObjectValues<T>;
315
+
316
+ /**
317
+ * @returns a string with only alphanumeric characters
318
+ * @example filterAlphanumeric("!abc()") // returns "abc"
319
+ */
320
+ declare const filterAlphanumeric: (string: string) => string;
321
+
322
+ declare const first: <T>(arr: T[]) => T;
323
+
324
+ declare const firstKey: <T extends PlainObject>(arg: T) => ObjectKey<T>;
325
+
326
+ declare const firstValue: <T extends PlainObject>(arg: T) => ObjectValue<T>;
327
+
328
+ /**
329
+ * Get a client cookie by name, works only in the browser
330
+ * @param name
331
+ * @returns the cookie value, if exists
332
+ */
333
+ declare const getCookieByName: (name: string) => string | undefined;
334
+
335
+ declare const getKeys: {
336
+ (o: object): string[];
337
+ (o: {}): string[];
338
+ };
339
+
340
+ declare const getUrlSearchParam: (urlString: Maybe<string>, param: string) => string | undefined;
341
+
342
+ declare const getUrlSearchParams: (urlString: Maybe<string>) => Record<string, string>;
343
+
344
+ /**
345
+ *
346
+ * @param items
347
+ * @param key
348
+ * @returns Record<keyof T, T[]>
349
+ * @example
350
+ * const items = [
351
+ * { externalId: 1, value: 100 },
352
+ * { externalId: 1, value: 50 },
353
+ * { externalId: 2, value: 200 },
354
+ * { externalId: 2, value: 100 },
355
+ * { mis_spelled_externalId: 2, value: 90 }, // not included in any group
356
+ * ];
357
+ * const ordersByInstrument = groupByKey(items, "externalId");
358
+ * // {
359
+ * // 1: [
360
+ * // { externalId: 1, value: 100 },
361
+ * // { externalId: 1, value: 50 },
362
+ * // ],
363
+ * // 2: [
364
+ * // { externalId: 2, value: 200 },
365
+ * // { externalId: 2, value: 100 },
366
+ * // ],
367
+ * // }
368
+ */
369
+ declare const groupByKey: <T, K extends keyof T>(items: T[], key: K) => Record<keyof T, T[]>;
370
+
371
+ declare const incrementalId: () => number;
372
+
373
+ declare const keysLength: <T extends PlainObject>(obj: T) => number;
374
+
375
+ declare const last: <T>(arr: T[]) => T;
376
+
377
+ declare const lastIndex: (array: any[]) => number;
378
+
379
+ /**
380
+ *
381
+ * @description Given an array of objects, returns a record where the key is the value of the object's key
382
+ * NOTE: if two objects have the same key, the last one will be the one kept.
383
+ * Useful for quick lookups by key.
384
+ * @example
385
+ * const items = [{ id: 1, name: "Alice" }, { id: 2, name: "Bob" }];
386
+ * const itemsById = mapByKey(items, "id");
387
+ * itemsById[1]; // { id: 1, name: "Alice" }
388
+ * itemsById[2]; // { id: 2, name: "Bob" }
389
+ */
390
+ declare const mapByKey: <T extends PlainObject>(items: T[], key: keyof T) => Record<Exclude<T[keyof T], null | undefined>, // any value of T, excluding null and undefined
391
+ T>;
392
+
393
+ /**
394
+ * @description Simple merge function that merges two objects, arrays get overwritten, no options
395
+ *
396
+ */
397
+ declare const merge: (target: PlainObject, source: PlainObject) => PlainObject;
398
+
399
+ /**
400
+ * @description Merge two arrays, unique values, no options
401
+ * @example mergeArrays([1,2,3], [2,3,4]) => [1,2,3,4]
402
+ */
403
+ declare const mergeArrays: (arrayA: any[], arrayB: any[]) => any[];
404
+
405
+ declare const moveToFirst: <T>(items: T[], condition: (item: T, i: number, items: T[]) => boolean) => T[];
406
+
407
+ declare const moveToLast: <T>(items: T[], condition: (item: T, i: number, items: T[]) => boolean) => T[];
408
+
409
+ declare const normalizeNumber: ({ value, max, min, }: {
410
+ value: number;
411
+ max: number;
412
+ min: number;
413
+ }) => number;
414
+
415
+ declare const objectDiff: (leftObject: PlainObject, rightObject: PlainObject) => PlainObject;
416
+
417
+ declare const omit: <T extends PlainObject>(obj: T, keys: (keyof T)[]) => Partial<T>;
418
+
419
+ /**
420
+ *
421
+ * @param arg
422
+ * @param options - asUTC: Use this when parsing an incomplete ISO date (e.g. "birth date") where timezone is irrelevant
423
+ * @returns a JS Date object or undefined, by default parsed in local time for incomplete dates
424
+ */
425
+ declare const parseDate: (arg?: Maybe<DateLike>, options?: {
426
+ asUTC?: boolean;
427
+ }) => Date | undefined;
428
+
429
+ /**
430
+ *
431
+ * @description Given an object, returns a new object with only the keys that are in the `keys` array.
432
+ * @example
433
+ * const obj = { a: 1, b: 2, c: 3 };
434
+ * pickObjectKeys(obj, ["a", "c"]); // { a: 1, c: 3 }
435
+ */
436
+ declare const pickObjectKeys: <T extends PlainObject>(obj: T, keys: ObjectKeys<T>) => Partial<T>;
437
+
438
+ /**
439
+ *
440
+ * @description Given an object, returns a new object with only the keys that have the values in the `values` array.
441
+ * @example
442
+ * const obj = { a: 1, b: 2, c: 3 };
443
+ * pickObjectValues(obj, [1, 3]); // { a: 1, c: 3 }
444
+ */
445
+ declare const pickObjectValues: <T extends PlainObject>(obj: T, values: ObjectValues<T>) => Partial<T>;
446
+
447
+ declare const pluck: <T extends PlainObject>(items: T[], key: keyof T) => Exclude<T[keyof T], null | undefined>[];
448
+
449
+ declare const promiseWithTimeout: <T>(promise: () => Promise<T>, timeoutMs: number, error?: Error) => Promise<T>;
450
+
451
+ declare const removeUndefinedValues: (obj: PlainObject) => {
452
+ [k: string]: any;
453
+ };
454
+
455
+ declare const scrambleText: (str: string) => string;
456
+
457
+ /**
458
+ * Serialize shallow object to a deterministic string,
459
+ * for nested objects use [json-stable-stringify](https://www.npmjs.com/package/json-stable-stringify)
460
+ *
461
+ * @example
462
+ * serialize({ b: 1, a: 2 }) // '{"a":1,"b":2}'
463
+ */
464
+ declare const serialize: <T extends PlainObject>(obj: T) => string;
465
+
466
+ type AsyncFunction<T = any> = () => Promise<T>;
467
+ type SeriesResult<T extends readonly AsyncFunction[]> = {
468
+ [K in keyof T]: T[K] extends AsyncFunction<infer U> ? Awaited<U> : never;
469
+ };
470
+ /**
471
+ *
472
+ * @description Run a series of (async) functions in order and return the results
473
+ * @example
474
+ * const results = await seriesAsync([
475
+ * () => Promise.resolve(1),
476
+ * () => sleep(100).then(() => 2),
477
+ * () => Promise.resolve(3),
478
+ * async () => 4,
479
+ * ]); => [1, 2, 3, 4]
480
+ */
481
+ declare const seriesAsync: <T extends readonly AsyncFunction[]>(series: readonly [...T]) => Promise<SeriesResult<T>>;
482
+
483
+ /**
484
+ * Sets a value in an object using a dot-separated path.
485
+ *
486
+ * @param obj The object to set the value in.
487
+ * @param path The path to the key to set, separated by dots.
488
+ * @param value The value to set.
489
+ */
490
+ declare const setObjectPath: (obj: PlainObject, path: string, value: any) => void;
491
+
492
+ declare const setUrlSearchParams: (currentURL: string, searchParams?: Record<string, Maybe<string | number | boolean | PlainObject>>) => string;
493
+
494
+ declare const shuffle: <T>(array: T[]) => T[];
495
+
496
+ declare const sleep: (timeMs: number) => Promise<void>;
497
+
498
+ declare const stringify: (arg?: any) => string;
499
+
500
+ declare const toggleArrayValue: <T>(array: T[], value: T) => T[];
501
+
502
+ declare const truncate: (arg: string, limit: number, { ellipsis, position, }?: {
503
+ ellipsis?: string;
504
+ position?: "start" | "middle" | "end";
505
+ }) => string;
506
+
507
+ declare const uniqueValues: <T>(arr: T[]) => T[];
508
+
509
+ /**
510
+ * Calculates the average of a list of numbers.
511
+ * @example
512
+ * average([1, 2, 3, 4, 5]); // 3
513
+ * average(1, 2, 3, 4, 5); // 3
514
+ */
515
+ declare const average: (numbers: number[]) => number;
516
+
517
+ declare const isBetween: (value: number, min: number, max: number) => boolean;
518
+
519
+ declare const isOutside: (value: number, min: number, max: number) => boolean;
520
+
521
+ declare const isStrictlyBetween: (value: number, min: number, max: number) => boolean;
522
+
523
+ /**
524
+ * Returns the maximum value in an array of numbers.
525
+ * @param values - The array of numbers to find the maximum value of.
526
+ * @returns The maximum value in the array. If the array is empty, returns 0.
527
+ */
528
+ declare const max: (values: number[]) => number;
529
+
530
+ declare const min: (values: number[]) => number;
531
+
532
+ declare const multiply: (numbers: number[]) => number;
533
+
534
+ /**
535
+ * Normalises an array of numbers
536
+ * @example normaliseArray([1, 2, 3]) => [0, 0.5, 1]
537
+ */
538
+ declare const normaliseArray: (values: number[]) => number[];
539
+
540
+ /**
541
+ *
542
+ * @example normaliseNumber(50, 0, 100) => 0.5
543
+ */
544
+ declare const normaliseNumber: (value: number, minValue: number, maxValue: number) => number;
545
+
546
+ /**
547
+ *
548
+ * @param previous Positive percentage i.e. 0.1 for 10%
549
+ * @param current Positive percentage i.e. 0.2 for 20%
550
+ * @returns
551
+ */
552
+ declare const percentageChange: (previous: number, current: number) => number;
553
+
554
+ declare const sum: (numbers: number[]) => number;
555
+
556
+ declare const prismaDateRange: ({ startDate, endDate }: DateRange) => {
557
+ gte: Date;
558
+ lt: Date;
559
+ };
560
+
561
+ type RandomAddress = {
562
+ city: string;
563
+ country: string;
564
+ countryCode: string;
565
+ state?: string;
566
+ street: string;
567
+ line2?: string;
568
+ number: string;
569
+ zip: string;
570
+ };
571
+
572
+ declare const randomAddress: () => RandomAddress;
573
+
574
+ /**
575
+ * Generates a random alphanumeric code that can be used for verification codes, etc.
576
+ * Does not contain 0s or Os as they get confused with each other.
577
+ * @param length The length of the code to generate.
578
+ * @returns A random alphanumeric code.
579
+ * @example
580
+ * randomAlphaNumericCode(); => "A2G4G6"
581
+ */
582
+ declare const randomAlphaNumericCode: ({ length, }?: {
583
+ length?: number;
584
+ }) => string;
585
+
586
+ declare const randomArray: () => (string | number | boolean | symbol | Date | BigInt)[];
587
+
588
+ declare const randomArrayItem: <T>(array: T[], { weights }?: {
589
+ weights?: number[];
590
+ }) => T;
591
+
592
+ type BankAccount = {
593
+ abaNumber?: string;
594
+ accountHolderName: string;
595
+ accountHolderType: "company" | "individual" | "other";
596
+ accountNumber: string;
597
+ accountType?: "checking" | "savings";
598
+ bankName?: string;
599
+ bsbNumber?: string;
600
+ bankAddress?: string;
601
+ bicSwift?: string;
602
+ branchCode?: string;
603
+ iban?: string;
604
+ routingNumber?: string;
605
+ institutionNumber?: string;
606
+ branchTransitNumber?: string;
607
+ sortCode?: string;
608
+ };
609
+
610
+ declare const randomBankAccount: () => BankAccount;
611
+
612
+ declare const randomBool: () => boolean;
613
+
614
+ declare const randomChar: () => string;
615
+
616
+ type Company = {
617
+ name: string;
618
+ vatRegNumber?: string;
619
+ };
620
+
621
+ declare const randomCompany: () => Company;
622
+
623
+ declare const randomCoords: () => Coords;
624
+ declare const randomLat: () => number;
625
+ declare const randomLng: () => number;
626
+
627
+ declare const randomDate: ({ startDate, endDate }?: Partial<DateRange>) => Date;
628
+ declare const randomMaxDate: ({ startDate, endDate }: Partial<DateRange>) => Date;
629
+ declare const randomFutureDate: ({ startDate, endDate, }?: Partial<DateRange>) => Date;
630
+ declare const randomPastDate: ({ startDate, endDate, }?: Partial<DateRange>) => Date;
631
+ declare const randomDateRange: () => {
632
+ endDate: Date;
633
+ startDate: Date;
634
+ };
635
+
636
+ declare const randomEmail: ({ handle, handleSuffix, }?: {
637
+ handle?: string;
638
+ handleSuffix?: string;
639
+ }) => string;
640
+
641
+ declare const randomEmoji: () => string;
642
+
643
+ declare const randomEmptyValue: () => number | null | undefined;
644
+
645
+ declare const randomEnumKey: <T extends object>(arg: T) => ObjectKey<T>;
646
+
647
+ declare const randomEnumValue: <T extends object>(arg: T) => ObjectValue<T>;
648
+
649
+ declare const randomFile: ({ name, extension, }?: {
650
+ name?: string;
651
+ extension?: string;
652
+ }) => File | undefined;
653
+
654
+ declare const JS_MAX_DIGITS = 16;
655
+ declare const randomFloat: (min?: number, max?: number, decimals?: number) => number;
656
+
657
+ /**
658
+ *
659
+ * @returns a unique social-like handle
660
+ * @example "john.doe15"
661
+ */
662
+ declare const randomHandle: ({ suffix }?: {
663
+ suffix?: string;
664
+ }) => string;
665
+
666
+ declare const randomHexColor: () => string;
667
+
668
+ declare const randomHexValue: () => string;
669
+
670
+ declare const randomHtmlColorName: () => string;
671
+
672
+ declare const randomIBAN: () => string;
673
+
674
+ declare const randomInt: ({ min, max, }?: {
675
+ min?: number;
676
+ max?: number;
677
+ }) => number;
678
+ declare const randomBigInt: () => BigInt;
679
+ declare const randomPositiveInt: ({ min, max, }?: {
680
+ min?: number;
681
+ max?: number;
682
+ }) => number;
683
+ declare const randomNegativeInt: ({ min, max, }?: {
684
+ min?: number;
685
+ max?: number;
686
+ }) => number;
687
+ declare const randomMaxSafeInt: () => number;
688
+ declare const randomMaxInt: () => number;
689
+ declare const randomFormattedPercentage: () => string;
690
+
691
+ declare const randomIP: () => string;
692
+
693
+ declare const randomName: () => string;
694
+ declare const randomFirstName: () => string;
695
+ declare const randomLastName: () => string;
696
+ declare const randomFullName: () => string;
697
+
698
+ /**
699
+ * Generates a random numeric code that can be used for verification codes, etc.
700
+ * Does not start with 0.
701
+ * @param length The length of the code to generate.
702
+ * @returns A random numeric code.
703
+ * @example
704
+ * randomNumericCode(); => "123456"
705
+ * @example
706
+ * randomNumericCode({ length: 4 }); => "1234"
707
+ */
708
+ declare const randomNumericCode: ({ length }?: {
709
+ length?: number;
710
+ }) => string;
711
+
712
+ declare const randomObject: ({ maxDepth, circular, }?: {
713
+ maxDepth?: number;
714
+ circular?: boolean;
715
+ }) => PlainObject;
716
+
717
+ /**
718
+ * Generates a random paragraph of text.
719
+ * @param maxCharacters The maximum number of characters. The paragraph will be truncated to this length if it exceeds it. Default is 200.
720
+ * @param words The number of words. Default is 8.
721
+ * @returns A random paragraph of text.
722
+ */
723
+ declare const randomParagraph: ({ maxCharacters, minWords, maxWords, }?: {
724
+ maxCharacters?: number;
725
+ minWords?: number;
726
+ maxWords?: number;
727
+ }) => string;
728
+
729
+ declare const randomPassword: ({ minChars, maxChars, }?: {
730
+ minChars?: number;
731
+ maxChars?: number;
732
+ }) => string;
733
+
734
+ declare const randomPath: ({ depth, }?: {
735
+ depth?: number;
736
+ }) => string;
737
+
738
+ declare const randomPhoneNumber: () => string;
739
+
740
+ declare const randomString: ({ length, }?: {
741
+ length?: number;
742
+ }) => string;
743
+
744
+ declare const randomSymbol: () => symbol;
745
+
746
+ /**
747
+ * This is a light-weight version of the `generateUuid` function
748
+ * To be used only for test purposed and NOT for production
749
+ * Leave 0s, so it gets immediately recognized as a fake uuid
750
+ *
751
+ * /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i
752
+ */
753
+ declare const randomUUID: () => string;
754
+
755
+ declare const randomValue: () => string | number | boolean | symbol | Date | BigInt;
756
+
757
+ declare const randomWord: () => string;
758
+ declare const randomNoun: () => string;
759
+ declare const randomVerb: () => string;
760
+
761
+ declare const formatTrpcInputQueryString: (input: PlainObject) => URLSearchParams;
762
+
763
+ declare const isArray: <T>(arg?: any) => arg is T[];
764
+
765
+ declare const isArrayIncluded: <T>(arr1: T[], arr2: T[]) => boolean;
766
+
767
+ declare const isBoolean: (arg: any) => arg is boolean;
768
+
769
+ declare const isBrowser: () => boolean;
770
+
771
+ declare const isBuffer: (val?: any) => boolean;
772
+
773
+ declare const isClient: () => boolean;
774
+
775
+ declare const isEmail: (arg: string) => boolean;
776
+
777
+ declare const isEmpty: (arg?: Maybe<any>) => boolean;
778
+ declare const isEmptyString: (arg: string) => boolean;
779
+ declare const isEmptyArray: (arg: any[]) => boolean;
780
+ declare const isEmptyObject: (arg: PlainObject) => boolean;
781
+
782
+ declare const isFile: (arg?: any) => arg is File;
783
+
784
+ /**
785
+ * @returns true if the argument can be called like a function -> fn() or await fn()
786
+ */
787
+ declare const isFunction: (arg: any) => arg is Function;
788
+
789
+ declare const isFutureDate: (arg: DateLike) => boolean;
790
+
791
+ declare const isJsDate: (arg: Date) => arg is Date;
792
+
793
+ declare const isKey: <T extends PlainObject>(key: Key, // cannot use PlainKey here because it does not include symbol (keyof T does)
794
+ obj: T) => key is keyof T;
795
+
796
+ declare const isLastIndex: (index: number, array: any[]) => boolean;
797
+
798
+ declare const isNotEmptyString: (arg: any) => boolean;
799
+
800
+ declare const isInt: (arg: any) => boolean;
801
+ declare const isEven: (arg: any) => boolean;
802
+ declare const isOdd: (arg: any) => boolean;
803
+ declare const isPositiveInt: (arg: any) => boolean;
804
+ declare const isNegativeInt: (arg: any) => boolean;
805
+ declare const isNumber: (arg: any) => arg is number;
806
+ declare const isBigInt: (arg: any) => arg is BigInt;
807
+ declare const isBigIntString: (arg: string) => boolean;
808
+ declare const isOutsideInt4: (num: number) => boolean;
809
+
810
+ /**
811
+ *
812
+ * @example isNumeric(1) => true
813
+ * @example isNumeric(10e8) => true
814
+ * @example isNumeric('1') => true
815
+ * @example isNumeric('1.1') => true
816
+ * @example isNumeric('1.1.1') => false
817
+ * @example isNumeric('1-1') => false
818
+ */
819
+ declare const isNumeric: (arg: number | string) => boolean;
820
+
821
+ declare const isNumericId: (id: string) => boolean;
822
+
823
+ declare const isObject: <T>(arg?: any) => arg is PlainObject<T>;
824
+
825
+ declare const isPastDate: (arg: DateLike) => boolean;
826
+
827
+ declare const isPromise: (arg: any) => arg is Promise<any>;
828
+
829
+ declare const isPWA: () => boolean;
830
+
831
+ declare const isReactElement: (value: any) => boolean;
832
+
833
+ declare const isRegExp: (arg: any) => arg is RegExp;
834
+
835
+ declare const isSame: (value1: any, value2: any) => boolean;
836
+
837
+ /**
838
+ * Check if an array of numbers is a sequence
839
+ * @example
840
+ * [1,2,3] = true
841
+ * [0,1,2] = false (starts at 0) TODO: add option to start from different number
842
+ * [1,3,4] = false (the sequence is not continuous, has gaps)
843
+ * [1,1,2] = false (has repeated values)
844
+ */
845
+ declare const isSequence: (numbers: number[]) => boolean;
846
+
847
+ declare const isServer: () => boolean;
848
+
849
+ declare const isSpacedString: (s: string) => boolean;
850
+
851
+ declare const isString: (arg: any) => arg is string;
852
+
853
+ declare const isStringDate: (arg: string) => boolean;
854
+
855
+ declare const isURL: (arg: string) => boolean;
856
+
857
+ declare const isUUID: (arg: string) => boolean;
858
+
859
+ declare const isValue: <T>(arg?: Maybe<T>) => arg is T;
860
+
861
+ export { type BoolMap, type Coords, type DateLike, type DateRange, type DateSeries, type Datey, type Defined, type Dimensions, type HashMap, type ISODate, type ISODay, type ISOMonth, type ISOYear, JS_MAX_DIGITS, type Key, type Matrix, type Maybe, type MaybePromise, type MaybePromiseOrValue, type MaybePromiseOrValueArray, type NonUndefined, type NumberMap, type ObjectEntries, type ObjectEntry, type ObjectKey, type ObjectKeys, type ObjectValue, type ObjectValues, type PickDefined, type PickRequired, type PlainKey, type PlainObject, type Point, type PrismaSelect, type Serialized, type StringMap, type Timezone, type TrueMap, type VoidFn, array, arrayDiff, arrayIntersection, average, bucketSortedDates, capitalize, chunkArray, chunkedAll, chunkedAsync, chunkedDynamic, clamp, cleanSpaces, cyclicalItem, dir, enumKeys, enumValues, filterAlphanumeric, first, firstKey, firstValue, formatCamelCase, formatCookies, formatIndexProgress, formatNumber, formatPercentage, formatTrpcInputQueryString, getCookieByName, getDateRangeSeries, getDateSeriesRange, getKeys, getUrlSearchParam, getUrlSearchParams, groupByKey, incrementalId, isArray, isArrayIncluded, isBetween, isBigInt, isBigIntString, isBoolean, isBrowser, isBuffer, isClient, isEmail, isEmpty, isEmptyArray, isEmptyObject, isEmptyString, isEven, isFile, isFunction, isFutureDate, isInt, isJsDate, isKey, isLastIndex, isNegativeInt, isNotEmptyString, isNumber, isNumeric, isNumericId, isObject, isOdd, isOutside, isOutsideInt4, isOver18, isPWA, isPastDate, isPositiveInt, isPromise, isReactElement, isRegExp, isSame, isSequence, isServer, isSpacedString, isStrictlyBetween, isString, isStringDate, isURL, isUUID, isValue, keysLength, last, lastIndex, mapByKey, max, merge, mergeArrays, min, moveToFirst, moveToLast, multiply, noop, normaliseArray, normaliseNumber, normalizeNumber, objectDiff, omit, parseDate, percentageChange, pickObjectKeys, pickObjectValues, pluck, prismaDateRange, promiseWithTimeout, randomAddress, randomAlphaNumericCode, randomArray, randomArrayItem, randomBankAccount, randomBigInt, randomBool, randomChar, randomCompany, randomCoords, randomDate, randomDateRange, randomEmail, randomEmoji, randomEmptyValue, randomEnumKey, randomEnumValue, randomFile, randomFirstName, randomFloat, randomFormattedPercentage, randomFullName, randomFutureDate, randomHandle, randomHexColor, randomHexValue, randomHtmlColorName, randomIBAN, randomIP, randomInt, randomLastName, randomLat, randomLng, randomMaxDate, randomMaxInt, randomMaxSafeInt, randomName, randomNegativeInt, randomNoun, randomNumericCode, randomObject, randomParagraph, randomPassword, randomPastDate, randomPath, randomPhoneNumber, randomPositiveInt, randomString, randomSymbol, randomUUID, randomValue, randomVerb, randomWord, removeUndefinedValues, scrambleText, serialize, seriesAsync, setObjectPath, setUrlSearchParams, shuffle, sleep, startOfDay, startOfNextMonth, startOfNextWeek, startOfThisWeek, startOfToday, startOfTomorrow, startOfUTCDay, startOfUTCTomorrow, stringToCSSUnicode, stringToUnicode, stringify, sum, toggleArrayValue, truncate, uniqueValues };