@xxanderwp/jstoolkit 1.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,956 @@
1
+ /**
2
+ * Generate a random string of specified length
3
+ * @param length - Length of the string to generate
4
+ * @param characters - Characters to use (default: alphanumeric)
5
+ * @returns Random string
6
+ */
7
+ declare function randomString(length: number, characters?: string): string;
8
+ /**
9
+ * Truncate a string to a specified length and add ellipsis
10
+ * @param str - String to truncate
11
+ * @param maxLength - Maximum length
12
+ * @param ellipsis - Ellipsis string (default: '...')
13
+ * @returns Truncated string
14
+ */
15
+ declare function truncate(str: string, maxLength: number, ellipsis?: string): string;
16
+ /**
17
+ * Capitalize the first letter of a string
18
+ * @param str - String to capitalize
19
+ * @returns Capitalized string
20
+ */
21
+ declare function capitalize(str: string): string;
22
+ /**
23
+ * Convert string to camelCase
24
+ * @param str - String to convert
25
+ * @returns camelCase string
26
+ */
27
+ declare function toCamelCase(str: string): string;
28
+ /**
29
+ * Convert string to snake_case
30
+ * @param str - String to convert
31
+ * @returns snake_case string
32
+ */
33
+ declare function toSnakeCase(str: string): string;
34
+ /**
35
+ * Convert string to kebab-case
36
+ * @param str - String to convert
37
+ * @returns kebab-case string
38
+ */
39
+ declare function toKebabCase(str: string): string;
40
+ /**
41
+ * Remove all whitespace from a string
42
+ * @param str - String to process
43
+ * @returns String without whitespace
44
+ */
45
+ declare function removeWhitespace(str: string): string;
46
+ /**
47
+ * Count occurrences of a substring in a string
48
+ * @param str - String to search in
49
+ * @param substring - Substring to count
50
+ * @returns Number of occurrences
51
+ */
52
+ declare function countOccurrences(str: string, substring: string): number;
53
+
54
+ declare const string_capitalize: typeof capitalize;
55
+ declare const string_countOccurrences: typeof countOccurrences;
56
+ declare const string_randomString: typeof randomString;
57
+ declare const string_removeWhitespace: typeof removeWhitespace;
58
+ declare const string_toCamelCase: typeof toCamelCase;
59
+ declare const string_toKebabCase: typeof toKebabCase;
60
+ declare const string_toSnakeCase: typeof toSnakeCase;
61
+ declare const string_truncate: typeof truncate;
62
+ declare namespace string {
63
+ export {
64
+ string_capitalize as capitalize,
65
+ string_countOccurrences as countOccurrences,
66
+ string_randomString as randomString,
67
+ string_removeWhitespace as removeWhitespace,
68
+ string_toCamelCase as toCamelCase,
69
+ string_toKebabCase as toKebabCase,
70
+ string_toSnakeCase as toSnakeCase,
71
+ string_truncate as truncate,
72
+ };
73
+ }
74
+
75
+ /**
76
+ * Get a random element from an array
77
+ * @param arr - Array to pick from
78
+ * @returns Random element
79
+ */
80
+ declare function randomElement<T>(arr: T[]): T;
81
+ /**
82
+ * Get a random index from an array
83
+ * @param arr - Array to pick from
84
+ * @returns Random index
85
+ */
86
+ declare function randomElementIndex<T>(arr: T[]): number;
87
+ /**
88
+ * Shuffle an array using Fisher-Yates algorithm
89
+ * @param arr - Array to shuffle
90
+ * @returns Shuffled array (new array)
91
+ */
92
+ declare function shuffle<T>(arr: T[]): T[];
93
+ /**
94
+ * Split an array into chunks of specified size
95
+ * @param array - Array to chunk
96
+ * @param size - Size of each chunk
97
+ * @returns Array of chunks
98
+ */
99
+ declare function chunk<T>(array: T[], size: number): T[][];
100
+ /**
101
+ * Remove duplicate values from an array
102
+ * @param arr - Array to deduplicate
103
+ * @returns Array without duplicates
104
+ */
105
+ declare function unique<T>(arr: T[]): T[];
106
+ /**
107
+ * Get the intersection of two arrays
108
+ * @param arr1 - First array
109
+ * @param arr2 - Second array
110
+ * @returns Intersection array
111
+ */
112
+ declare function intersection<T>(arr1: T[], arr2: T[]): T[];
113
+ /**
114
+ * Get the difference of two arrays (elements in arr1 but not in arr2)
115
+ * @param arr1 - First array
116
+ * @param arr2 - Second array
117
+ * @returns Difference array
118
+ */
119
+ declare function difference<T>(arr1: T[], arr2: T[]): T[];
120
+ /**
121
+ * Sort array in ascending or descending order
122
+ * @param array - Array to sort
123
+ * @param order - Sort order ('ASC' or 'DESC')
124
+ * @returns Sorted array
125
+ */
126
+ declare function sort<T>(array: T[], order?: 'ASC' | 'DESC'): T[];
127
+ /**
128
+ * Sort array of objects by multiple properties
129
+ * @param array - Array to sort
130
+ * @param params - Sort parameters
131
+ * @returns Sorted array
132
+ */
133
+ declare function sortBy<T>(array: T[], params: Array<{
134
+ key: keyof T;
135
+ order: 'ASC' | 'DESC';
136
+ }>): T[];
137
+ /**
138
+ * Sort array items by key order priority
139
+ * @param items - Array to sort
140
+ * @param keyOrder - Priority order of keys
141
+ * @returns Sorted array
142
+ */
143
+ declare function sortByKeys(items: string[], keyOrder: string[]): string[];
144
+ /**
145
+ * Group array elements by a key function
146
+ * @param arr - Array to group
147
+ * @param keyFn - Function that returns the group key
148
+ * @returns Object with grouped elements
149
+ */
150
+ declare function groupBy<T>(arr: T[], keyFn: (item: T) => string | number): Record<string | number, T[]>;
151
+ /**
152
+ * Flatten nested arrays to specified depth
153
+ * @param arr - Array to flatten
154
+ * @param depth - Depth to flatten (default: 1)
155
+ * @returns Flattened array
156
+ */
157
+ declare function flatten$1<T>(arr: unknown[], depth?: number): T[];
158
+
159
+ declare const array_chunk: typeof chunk;
160
+ declare const array_difference: typeof difference;
161
+ declare const array_groupBy: typeof groupBy;
162
+ declare const array_intersection: typeof intersection;
163
+ declare const array_randomElement: typeof randomElement;
164
+ declare const array_randomElementIndex: typeof randomElementIndex;
165
+ declare const array_shuffle: typeof shuffle;
166
+ declare const array_sort: typeof sort;
167
+ declare const array_sortBy: typeof sortBy;
168
+ declare const array_sortByKeys: typeof sortByKeys;
169
+ declare const array_unique: typeof unique;
170
+ declare namespace array {
171
+ export {
172
+ array_chunk as chunk,
173
+ array_difference as difference,
174
+ flatten$1 as flatten,
175
+ array_groupBy as groupBy,
176
+ array_intersection as intersection,
177
+ array_randomElement as randomElement,
178
+ array_randomElementIndex as randomElementIndex,
179
+ array_shuffle as shuffle,
180
+ array_sort as sort,
181
+ array_sortBy as sortBy,
182
+ array_sortByKeys as sortByKeys,
183
+ array_unique as unique,
184
+ };
185
+ }
186
+
187
+ /**
188
+ * Generate a random integer between min and max (inclusive)
189
+ * @param min - Minimum value
190
+ * @param max - Maximum value
191
+ * @returns Random integer
192
+ */
193
+ declare function randomInt$1(min: number, max: number): number;
194
+ /**
195
+ * Generate a random float between min and max
196
+ * @param min - Minimum value
197
+ * @param max - Maximum value
198
+ * @returns Random float
199
+ */
200
+ declare function randomFloat$1(min: number, max: number): number;
201
+ /**
202
+ * Round a number to specified decimal places
203
+ * @param value - Value to round
204
+ * @param decimals - Number of decimal places
205
+ * @param mode - Rounding mode ('round' or 'truncate')
206
+ * @returns Rounded number
207
+ */
208
+ declare function round(value: number, decimals: number, mode?: 'round' | 'truncate'): number;
209
+ /**
210
+ * Linear interpolation between two values
211
+ * @param start - Start value
212
+ * @param end - End value
213
+ * @param amount - Interpolation amount (0-1)
214
+ * @returns Interpolated value
215
+ */
216
+ declare function lerp(start: number, end: number, amount: number): number;
217
+ /**
218
+ * Linear interpolation between two 2D points
219
+ * @param point1 - First point
220
+ * @param point2 - Second point
221
+ * @param amount - Interpolation amount (0-1)
222
+ * @returns Interpolated point
223
+ */
224
+ declare function lerp2D(point1: {
225
+ x: number;
226
+ y: number;
227
+ }, point2: {
228
+ x: number;
229
+ y: number;
230
+ }, amount: number): {
231
+ x: number;
232
+ y: number;
233
+ };
234
+ /**
235
+ * Linear interpolation between two 3D vectors
236
+ * @param vec1 - First vector
237
+ * @param vec2 - Second vector
238
+ * @param amount - Interpolation amount (0-1)
239
+ * @returns Interpolated vector
240
+ */
241
+ declare function lerp3D(vec1: {
242
+ x: number;
243
+ y: number;
244
+ z: number;
245
+ }, vec2: {
246
+ x: number;
247
+ y: number;
248
+ z: number;
249
+ }, amount: number): {
250
+ x: number;
251
+ y: number;
252
+ z: number;
253
+ };
254
+ /**
255
+ * Calculate time-based interpolation value
256
+ * @param start - Start timestamp
257
+ * @param end - End timestamp
258
+ * @param current - Current timestamp (default: Date.now())
259
+ * @returns Interpolation value (0-1)
260
+ */
261
+ declare function lerpTime(start: number, end: number, current?: number): number;
262
+ /**
263
+ * Clamp a value between min and max
264
+ * @param value - Value to clamp
265
+ * @param min - Minimum value
266
+ * @param max - Maximum value
267
+ * @returns Clamped value
268
+ */
269
+ declare function clamp(value: number, min: number, max: number): number;
270
+ /**
271
+ * Map a value from one range to another
272
+ * @param value - Value to map
273
+ * @param inMin - Input range minimum
274
+ * @param inMax - Input range maximum
275
+ * @param outMin - Output range minimum
276
+ * @param outMax - Output range maximum
277
+ * @returns Mapped value
278
+ */
279
+ declare function mapRange(value: number, inMin: number, inMax: number, outMin: number, outMax: number): number;
280
+ /**
281
+ * Calculate percentage
282
+ * @param value - Value
283
+ * @param total - Total value
284
+ * @returns Percentage (0-100)
285
+ */
286
+ declare function percentage(value: number, total: number): number;
287
+ /**
288
+ * Calculate average of numbers
289
+ * @param numbers - Array of numbers
290
+ * @returns Average value
291
+ */
292
+ declare function average(numbers: number[]): number;
293
+ /**
294
+ * Calculate sum of numbers
295
+ * @param numbers - Array of numbers
296
+ * @returns Sum
297
+ */
298
+ declare function sum(numbers: number[]): number;
299
+ /**
300
+ * Find minimum value in array
301
+ * @param numbers - Array of numbers
302
+ * @returns Minimum value
303
+ */
304
+ declare function min(numbers: number[]): number;
305
+ /**
306
+ * Find maximum value in array
307
+ * @param numbers - Array of numbers
308
+ * @returns Maximum value
309
+ */
310
+ declare function max(numbers: number[]): number;
311
+
312
+ declare const math_average: typeof average;
313
+ declare const math_clamp: typeof clamp;
314
+ declare const math_lerp: typeof lerp;
315
+ declare const math_lerp2D: typeof lerp2D;
316
+ declare const math_lerp3D: typeof lerp3D;
317
+ declare const math_lerpTime: typeof lerpTime;
318
+ declare const math_mapRange: typeof mapRange;
319
+ declare const math_max: typeof max;
320
+ declare const math_min: typeof min;
321
+ declare const math_percentage: typeof percentage;
322
+ declare const math_round: typeof round;
323
+ declare const math_sum: typeof sum;
324
+ declare namespace math {
325
+ export {
326
+ math_average as average,
327
+ math_clamp as clamp,
328
+ math_lerp as lerp,
329
+ math_lerp2D as lerp2D,
330
+ math_lerp3D as lerp3D,
331
+ math_lerpTime as lerpTime,
332
+ math_mapRange as mapRange,
333
+ math_max as max,
334
+ math_min as min,
335
+ math_percentage as percentage,
336
+ randomFloat$1 as randomFloat,
337
+ randomInt$1 as randomInt,
338
+ math_round as round,
339
+ math_sum as sum,
340
+ };
341
+ }
342
+
343
+ /**
344
+ * Get current Unix timestamp in seconds
345
+ * @returns Current timestamp
346
+ */
347
+ declare function timestamp(): number;
348
+ /**
349
+ * Get current Unix timestamp in milliseconds
350
+ * @returns Current timestamp in ms
351
+ */
352
+ declare function timestampMs(): number;
353
+ /**
354
+ * Format a number with leading zero
355
+ * @param num - Number to format
356
+ * @returns Formatted string
357
+ */
358
+ declare function padZero(num: number | string): string;
359
+ /**
360
+ * Get full date and time string
361
+ * @param date - Date object (default: current date)
362
+ * @returns Formatted date string (DD.MM.YYYY HH:MM)
363
+ */
364
+ declare function formatDateTime(date?: Date): string;
365
+ /**
366
+ * Get full date and time string with seconds
367
+ * @param date - Date object (default: current date)
368
+ * @returns Formatted date string (DD.MM.YYYY HH:MM:SS)
369
+ */
370
+ declare function formatDateTimeSeconds(date?: Date): string;
371
+ /**
372
+ * Get date without time
373
+ * @param date - Date object (default: current date)
374
+ * @returns Formatted date string (DD.MM.YYYY)
375
+ */
376
+ declare function formatDate(date?: Date): string;
377
+ /**
378
+ * Format timestamp to readable date/time string
379
+ * Shows only time if date is today, otherwise shows date and time
380
+ * @param time - Unix timestamp in seconds (default: current time)
381
+ * @param alwaysShowDate - Always show date even if today
382
+ * @returns Formatted string
383
+ */
384
+ declare function formatTimestamp(time?: number, alwaysShowDate?: boolean): string;
385
+ /**
386
+ * Convert seconds to formatted duration string (HH:MM:SS or D:HH:MM:SS)
387
+ * @param seconds - Duration in seconds
388
+ * @returns Formatted duration string
389
+ */
390
+ declare function formatDuration(seconds: number): string;
391
+ /**
392
+ * Convert milliseconds to formatted duration string with ms
393
+ * @param ms - Duration in milliseconds
394
+ * @returns Formatted duration string (HH:MM:SS.mmm)
395
+ */
396
+ declare function formatDurationMs(ms: number): string;
397
+ /**
398
+ * Sleep/delay for specified milliseconds
399
+ * @param ms - Milliseconds to sleep
400
+ * @returns Promise that resolves after delay
401
+ */
402
+ declare function sleep(ms: number): Promise<void>;
403
+ /**
404
+ * Check if a date is today
405
+ * @param date - Date to check
406
+ * @returns True if date is today
407
+ */
408
+ declare function isToday(date: Date): boolean;
409
+ /**
410
+ * Check if a date is yesterday
411
+ * @param date - Date to check
412
+ * @returns True if date is yesterday
413
+ */
414
+ declare function isYesterday(date: Date): boolean;
415
+ /**
416
+ * Get relative time string (e.g., "2 hours ago", "in 3 days")
417
+ * @param date - Date to compare
418
+ * @param now - Reference date (default: current date)
419
+ * @returns Relative time string
420
+ */
421
+ declare function timeAgo(date: Date, now?: Date): string;
422
+
423
+ declare const time_formatDate: typeof formatDate;
424
+ declare const time_formatDateTime: typeof formatDateTime;
425
+ declare const time_formatDateTimeSeconds: typeof formatDateTimeSeconds;
426
+ declare const time_formatDuration: typeof formatDuration;
427
+ declare const time_formatDurationMs: typeof formatDurationMs;
428
+ declare const time_formatTimestamp: typeof formatTimestamp;
429
+ declare const time_isToday: typeof isToday;
430
+ declare const time_isYesterday: typeof isYesterday;
431
+ declare const time_padZero: typeof padZero;
432
+ declare const time_sleep: typeof sleep;
433
+ declare const time_timeAgo: typeof timeAgo;
434
+ declare const time_timestamp: typeof timestamp;
435
+ declare const time_timestampMs: typeof timestampMs;
436
+ declare namespace time {
437
+ export {
438
+ time_formatDate as formatDate,
439
+ time_formatDateTime as formatDateTime,
440
+ time_formatDateTimeSeconds as formatDateTimeSeconds,
441
+ time_formatDuration as formatDuration,
442
+ time_formatDurationMs as formatDurationMs,
443
+ time_formatTimestamp as formatTimestamp,
444
+ time_isToday as isToday,
445
+ time_isYesterday as isYesterday,
446
+ time_padZero as padZero,
447
+ time_sleep as sleep,
448
+ time_timeAgo as timeAgo,
449
+ time_timestamp as timestamp,
450
+ time_timestampMs as timestampMs,
451
+ };
452
+ }
453
+
454
+ /**
455
+ * Encode string to Base64
456
+ * @param str - String to encode
457
+ * @returns Base64 encoded string
458
+ */
459
+ declare function toBase64(str: string): string;
460
+ /**
461
+ * Decode Base64 string
462
+ * @param encoded - Base64 encoded string
463
+ * @returns Decoded string
464
+ */
465
+ declare function fromBase64(encoded: string): string;
466
+ /**
467
+ * Generate MD5 hash of a string
468
+ * @param text - Text to hash
469
+ * @returns MD5 hash
470
+ */
471
+ declare function hash(text: string): string;
472
+ /**
473
+ * Encode URI component safely
474
+ * @param str - String to encode
475
+ * @returns Encoded URI component
476
+ */
477
+ declare function encodeUri(str: string): string;
478
+ /**
479
+ * Decode URI component safely
480
+ * @param str - String to decode
481
+ * @returns Decoded URI component
482
+ */
483
+ declare function decodeUri(str: string): string;
484
+ /**
485
+ * Convert ArrayBuffer to Buffer (Node.js)
486
+ * @param ab - ArrayBuffer to convert
487
+ * @returns Buffer
488
+ */
489
+ declare function arrayBufferToBuffer(ab: ArrayBuffer): Buffer;
490
+ /**
491
+ * Convert hex string to bytes
492
+ * @param hex - Hex string
493
+ * @returns Uint8Array
494
+ */
495
+ declare function hexToBytes(hex: string): Uint8Array;
496
+ /**
497
+ * Convert bytes to hex string
498
+ * @param bytes - Byte array
499
+ * @returns Hex string
500
+ */
501
+ declare function bytesToHex(bytes: Uint8Array): string;
502
+
503
+ declare const encoding_arrayBufferToBuffer: typeof arrayBufferToBuffer;
504
+ declare const encoding_bytesToHex: typeof bytesToHex;
505
+ declare const encoding_decodeUri: typeof decodeUri;
506
+ declare const encoding_encodeUri: typeof encodeUri;
507
+ declare const encoding_fromBase64: typeof fromBase64;
508
+ declare const encoding_hash: typeof hash;
509
+ declare const encoding_hexToBytes: typeof hexToBytes;
510
+ declare const encoding_toBase64: typeof toBase64;
511
+ declare namespace encoding {
512
+ export {
513
+ encoding_arrayBufferToBuffer as arrayBufferToBuffer,
514
+ encoding_bytesToHex as bytesToHex,
515
+ encoding_decodeUri as decodeUri,
516
+ encoding_encodeUri as encodeUri,
517
+ encoding_fromBase64 as fromBase64,
518
+ encoding_hash as hash,
519
+ encoding_hexToBytes as hexToBytes,
520
+ encoding_toBase64 as toBase64,
521
+ };
522
+ }
523
+
524
+ /**
525
+ * Check if a string is a valid emoji
526
+ * @param str - String to check
527
+ * @returns True if string is an emoji
528
+ */
529
+ declare function isEmoji(str: string): boolean;
530
+ /**
531
+ * Check if a URL is an image link
532
+ * @param url - URL to check
533
+ * @returns True if URL points to an image
534
+ */
535
+ declare function isImageUrl(url: string): boolean;
536
+ /**
537
+ * Check if a string is a valid email
538
+ * @param email - Email string to validate
539
+ * @returns True if email is valid
540
+ */
541
+ declare function isEmail(email: string): boolean;
542
+ /**
543
+ * Check if a string is a valid URL
544
+ * @param url - URL string to validate
545
+ * @returns True if URL is valid
546
+ */
547
+ declare function isUrl(url: string): boolean;
548
+ /**
549
+ * Check if a string contains only numbers
550
+ * @param str - String to check
551
+ * @returns True if string contains only numbers
552
+ */
553
+ declare function isNumeric(str: string): boolean;
554
+ /**
555
+ * Check if a string contains only letters
556
+ * @param str - String to check
557
+ * @returns True if string contains only letters
558
+ */
559
+ declare function isAlpha(str: string): boolean;
560
+ /**
561
+ * Check if a string contains only letters and numbers
562
+ * @param str - String to check
563
+ * @returns True if string is alphanumeric
564
+ */
565
+ declare function isAlphanumeric(str: string): boolean;
566
+ /**
567
+ * Check if a value is empty (null, undefined, empty string, empty array, empty object)
568
+ * @param value - Value to check
569
+ * @returns True if value is empty
570
+ */
571
+ declare function isEmpty(value: unknown): value is null | undefined | '' | [] | Record<string, never>;
572
+ /**
573
+ * Check if a value is a plain object
574
+ * @param value - Value to check
575
+ * @returns True if value is a plain object
576
+ */
577
+ declare function isPlainObject(value: unknown): value is Record<string, unknown>;
578
+ /**
579
+ * Extract URL information from a string
580
+ * @param str - String containing URL
581
+ * @returns URL info or null if no URL found
582
+ */
583
+ declare function extractUrl(str: string): {
584
+ url: string;
585
+ domain: string;
586
+ } | null;
587
+ /**
588
+ * Check if a string is a valid IPv4 address
589
+ * @param ip - IP address string
590
+ * @returns True if valid IPv4
591
+ */
592
+ declare function isIPv4(ip: string): boolean;
593
+ /**
594
+ * Check if a string is a valid hex color
595
+ * @param color - Color string
596
+ * @returns True if valid hex color
597
+ */
598
+ declare function isHexColor(color: string): boolean;
599
+
600
+ declare const validation_extractUrl: typeof extractUrl;
601
+ declare const validation_isAlpha: typeof isAlpha;
602
+ declare const validation_isAlphanumeric: typeof isAlphanumeric;
603
+ declare const validation_isEmail: typeof isEmail;
604
+ declare const validation_isEmoji: typeof isEmoji;
605
+ declare const validation_isEmpty: typeof isEmpty;
606
+ declare const validation_isHexColor: typeof isHexColor;
607
+ declare const validation_isIPv4: typeof isIPv4;
608
+ declare const validation_isImageUrl: typeof isImageUrl;
609
+ declare const validation_isNumeric: typeof isNumeric;
610
+ declare const validation_isPlainObject: typeof isPlainObject;
611
+ declare const validation_isUrl: typeof isUrl;
612
+ declare namespace validation {
613
+ export {
614
+ validation_extractUrl as extractUrl,
615
+ validation_isAlpha as isAlpha,
616
+ validation_isAlphanumeric as isAlphanumeric,
617
+ validation_isEmail as isEmail,
618
+ validation_isEmoji as isEmoji,
619
+ validation_isEmpty as isEmpty,
620
+ validation_isHexColor as isHexColor,
621
+ validation_isIPv4 as isIPv4,
622
+ validation_isImageUrl as isImageUrl,
623
+ validation_isNumeric as isNumeric,
624
+ validation_isPlainObject as isPlainObject,
625
+ validation_isUrl as isUrl,
626
+ };
627
+ }
628
+
629
+ /**
630
+ * Format a number with thousands separators
631
+ * @param num - Number to format
632
+ * @param removeTrailingZeros - Remove .00 from integers (default: true)
633
+ * @returns Formatted number string
634
+ */
635
+ declare function formatNumber(num: number, removeTrailingZeros?: boolean): string;
636
+ /**
637
+ * Format bytes to human-readable size
638
+ * @param bytes - Number of bytes
639
+ * @param decimals - Decimal places (default: 2)
640
+ * @returns Formatted size string
641
+ */
642
+ declare function formatBytes(bytes: number, decimals?: number): string;
643
+ /**
644
+ * Format a number as currency
645
+ * @param amount - Amount to format
646
+ * @param currency - Currency code (default: 'USD')
647
+ * @param locale - Locale for formatting (default: 'en-US')
648
+ * @returns Formatted currency string
649
+ */
650
+ declare function formatCurrency(amount: number, currency?: string, locale?: string): string;
651
+ /**
652
+ * Format a phone number (basic US format)
653
+ * @param phone - Phone number string
654
+ * @returns Formatted phone number
655
+ */
656
+ declare function formatPhone(phone: string): string;
657
+ /**
658
+ * Format a credit card number with spaces
659
+ * @param cardNumber - Card number string
660
+ * @returns Formatted card number
661
+ */
662
+ declare function formatCardNumber(cardNumber: string): string;
663
+ /**
664
+ * Mask sensitive data (show only last N characters)
665
+ * @param str - String to mask
666
+ * @param visibleChars - Number of visible characters at the end (default: 4)
667
+ * @param maskChar - Character to use for masking (default: '*')
668
+ * @returns Masked string
669
+ */
670
+ declare function maskString(str: string, visibleChars?: number, maskChar?: string): string;
671
+ /**
672
+ * Format percentage
673
+ * @param value - Value to format
674
+ * @param decimals - Decimal places (default: 2)
675
+ * @returns Formatted percentage string
676
+ */
677
+ declare function formatPercentage(value: number, decimals?: number): string;
678
+ /**
679
+ * Pluralize a word based on count
680
+ * @param count - Count number
681
+ * @param singular - Singular form
682
+ * @param plural - Plural form (optional, will add 's' if not provided)
683
+ * @returns Pluralized string with count
684
+ */
685
+ declare function pluralize(count: number, singular: string, plural?: string): string;
686
+ /**
687
+ * Abbreviate large numbers (1000 -> 1K, 1000000 -> 1M)
688
+ * @param num - Number to abbreviate
689
+ * @param decimals - Decimal places (default: 1)
690
+ * @returns Abbreviated number string
691
+ */
692
+ declare function abbreviateNumber(num: number, decimals?: number): string;
693
+ /**
694
+ * Format file name with extension
695
+ * @param name - File name without extension
696
+ * @param extension - File extension
697
+ * @returns Formatted file name
698
+ */
699
+ declare function formatFileName(name: string, extension: string): string;
700
+ /**
701
+ * Title case a string (capitalize first letter of each word)
702
+ * @param str - String to title case
703
+ * @returns Title cased string
704
+ */
705
+ declare function titleCase(str: string): string;
706
+
707
+ declare const format_abbreviateNumber: typeof abbreviateNumber;
708
+ declare const format_formatBytes: typeof formatBytes;
709
+ declare const format_formatCardNumber: typeof formatCardNumber;
710
+ declare const format_formatCurrency: typeof formatCurrency;
711
+ declare const format_formatFileName: typeof formatFileName;
712
+ declare const format_formatNumber: typeof formatNumber;
713
+ declare const format_formatPercentage: typeof formatPercentage;
714
+ declare const format_formatPhone: typeof formatPhone;
715
+ declare const format_maskString: typeof maskString;
716
+ declare const format_pluralize: typeof pluralize;
717
+ declare const format_titleCase: typeof titleCase;
718
+ declare namespace format {
719
+ export {
720
+ format_abbreviateNumber as abbreviateNumber,
721
+ format_formatBytes as formatBytes,
722
+ format_formatCardNumber as formatCardNumber,
723
+ format_formatCurrency as formatCurrency,
724
+ format_formatFileName as formatFileName,
725
+ format_formatNumber as formatNumber,
726
+ format_formatPercentage as formatPercentage,
727
+ format_formatPhone as formatPhone,
728
+ format_maskString as maskString,
729
+ format_pluralize as pluralize,
730
+ format_titleCase as titleCase,
731
+ };
732
+ }
733
+
734
+ /**
735
+ * Generate a random integer between min and max (inclusive)
736
+ * @param min - Minimum value
737
+ * @param max - Maximum value
738
+ * @returns Random integer
739
+ */
740
+ declare function randomInt(min: number, max: number): number;
741
+ /**
742
+ * Generate a random float between min and max
743
+ * @param min - Minimum value
744
+ * @param max - Maximum value
745
+ * @returns Random float
746
+ */
747
+ declare function randomFloat(min: number, max: number): number;
748
+ /**
749
+ * Generate a random boolean
750
+ * @param probability - Probability of true (0-1, default: 0.5)
751
+ * @returns Random boolean
752
+ */
753
+ declare function randomBoolean(probability?: number): boolean;
754
+ /**
755
+ * Pick N random unique elements from an array
756
+ * @param arr - Array to pick from
757
+ * @param count - Number of elements to pick
758
+ * @returns Array of random elements
759
+ */
760
+ declare function randomSample<T>(arr: T[], count: number): T[];
761
+ /**
762
+ * Generate a random hex color
763
+ * @returns Random hex color string
764
+ */
765
+ declare function randomColor(): string;
766
+ /**
767
+ * Generate a random UUID v4
768
+ * @returns UUID string
769
+ */
770
+ declare function randomUUID(): string;
771
+ /**
772
+ * Generate random weighted choice based on weights
773
+ * @param items - Array of items
774
+ * @param weights - Array of weights (must match items length)
775
+ * @returns Random item based on weights
776
+ */
777
+ declare function randomWeighted<T>(items: T[], weights: number[]): T;
778
+ /**
779
+ * Generate a random date between two dates
780
+ * @param start - Start date
781
+ * @param end - End date
782
+ * @returns Random date
783
+ */
784
+ declare function randomDate(start: Date, end: Date): Date;
785
+
786
+ declare const random_randomBoolean: typeof randomBoolean;
787
+ declare const random_randomColor: typeof randomColor;
788
+ declare const random_randomDate: typeof randomDate;
789
+ declare const random_randomFloat: typeof randomFloat;
790
+ declare const random_randomInt: typeof randomInt;
791
+ declare const random_randomSample: typeof randomSample;
792
+ declare const random_randomUUID: typeof randomUUID;
793
+ declare const random_randomWeighted: typeof randomWeighted;
794
+ declare namespace random {
795
+ export {
796
+ random_randomBoolean as randomBoolean,
797
+ random_randomColor as randomColor,
798
+ random_randomDate as randomDate,
799
+ random_randomFloat as randomFloat,
800
+ random_randomInt as randomInt,
801
+ random_randomSample as randomSample,
802
+ random_randomUUID as randomUUID,
803
+ random_randomWeighted as randomWeighted,
804
+ };
805
+ }
806
+
807
+ /**
808
+ * Deep clone an object
809
+ * @param obj - Object to clone
810
+ * @returns Cloned object
811
+ */
812
+ declare function deepClone<T>(obj: T): T;
813
+ type PlainObject = Record<string, unknown>;
814
+ /**
815
+ * Deep merge two or more objects (mutates target)
816
+ */
817
+ declare function deepMerge<T extends PlainObject>(target: T, ...sources: PlainObject[]): T;
818
+ /**
819
+ * Get nested property value from object using path
820
+ * @param obj - Object to get value from
821
+ * @param path - Property path (e.g., 'user.address.city')
822
+ * @param defaultValue - Default value if path not found
823
+ * @returns Property value or default
824
+ */
825
+ declare function get<T = any>(obj: any, path: string, defaultValue?: T): T | undefined;
826
+ /**
827
+ * Set nested property value in object using path
828
+ * @param obj - Object to set value in
829
+ * @param path - Property path (e.g., 'user.address.city')
830
+ * @param value - Value to set
831
+ * @returns Modified object
832
+ */
833
+ declare function set<T extends Record<string, any>>(obj: T, path: string, value: any): T;
834
+ /**
835
+ * Pick specific properties from object
836
+ * @param obj - Source object
837
+ * @param keys - Keys to pick
838
+ * @returns New object with picked properties
839
+ */
840
+ declare function pick<T extends Record<string, any>, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
841
+ /**
842
+ * Omit specific properties from object
843
+ * @param obj - Source object
844
+ * @param keys - Keys to omit
845
+ * @returns New object without omitted properties
846
+ */
847
+ declare function omit<T extends Record<string, any>, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>;
848
+ /**
849
+ * Flatten nested object to single level with dot notation keys
850
+ * @param obj - Object to flatten
851
+ * @param prefix - Key prefix (used internally)
852
+ * @returns Flattened object
853
+ */
854
+ declare function flatten(obj: Record<string, any>, prefix?: string): Record<string, any>;
855
+ /**
856
+ * Unflatten object with dot notation keys to nested object
857
+ * @param obj - Flattened object
858
+ * @returns Nested object
859
+ */
860
+ declare function unflatten(obj: Record<string, any>): Record<string, any>;
861
+ /**
862
+ * Get all keys from object including nested keys (dot notation)
863
+ * @param obj - Object to get keys from
864
+ * @param prefix - Key prefix (used internally)
865
+ * @returns Array of all keys
866
+ */
867
+ declare function keys(obj: Record<string, any>, prefix?: string): string[];
868
+ /**
869
+ * Get all values from object including nested values
870
+ * @param obj - Object to get values from
871
+ * @returns Array of all values
872
+ */
873
+ declare function values(obj: Record<string, any>): any[];
874
+ /**
875
+ * Check if two objects are deeply equal
876
+ * @param obj1 - First object
877
+ * @param obj2 - Second object
878
+ * @returns True if objects are equal
879
+ */
880
+ declare function isEqual(obj1: any, obj2: any): boolean;
881
+
882
+ declare const object_deepClone: typeof deepClone;
883
+ declare const object_deepMerge: typeof deepMerge;
884
+ declare const object_flatten: typeof flatten;
885
+ declare const object_get: typeof get;
886
+ declare const object_isEqual: typeof isEqual;
887
+ declare const object_keys: typeof keys;
888
+ declare const object_omit: typeof omit;
889
+ declare const object_pick: typeof pick;
890
+ declare const object_set: typeof set;
891
+ declare const object_unflatten: typeof unflatten;
892
+ declare const object_values: typeof values;
893
+ declare namespace object {
894
+ export {
895
+ object_deepClone as deepClone,
896
+ object_deepMerge as deepMerge,
897
+ object_flatten as flatten,
898
+ object_get as get,
899
+ object_isEqual as isEqual,
900
+ object_keys as keys,
901
+ object_omit as omit,
902
+ object_pick as pick,
903
+ object_set as set,
904
+ object_unflatten as unflatten,
905
+ object_values as values,
906
+ };
907
+ }
908
+
909
+ declare const toolkit: {
910
+ string: typeof string;
911
+ array: typeof array;
912
+ math: typeof math;
913
+ time: typeof time;
914
+ encoding: typeof encoding;
915
+ validation: typeof validation;
916
+ format: typeof format;
917
+ random: typeof random;
918
+ object: typeof object;
919
+ randomString: typeof randomString;
920
+ capitalize: typeof capitalize;
921
+ truncate: typeof truncate;
922
+ randomElement: typeof randomElement;
923
+ chunk: typeof chunk;
924
+ unique: typeof unique;
925
+ shuffle: typeof shuffle;
926
+ randomInt: typeof randomInt$1;
927
+ randomFloat: typeof randomFloat$1;
928
+ lerp: typeof lerp;
929
+ clamp: typeof clamp;
930
+ round: typeof round;
931
+ timestamp: typeof timestamp;
932
+ timestampMs: typeof timestampMs;
933
+ formatDateTime: typeof formatDateTime;
934
+ formatDuration: typeof formatDuration;
935
+ sleep: typeof sleep;
936
+ toBase64: typeof toBase64;
937
+ fromBase64: typeof fromBase64;
938
+ hash: typeof hash;
939
+ isEmail: typeof isEmail;
940
+ isUrl: typeof isUrl;
941
+ isEmpty: typeof isEmpty;
942
+ isEmoji: typeof isEmoji;
943
+ formatNumber: typeof formatNumber;
944
+ formatBytes: typeof formatBytes;
945
+ pluralize: typeof pluralize;
946
+ randomBoolean: typeof randomBoolean;
947
+ randomColor: typeof randomColor;
948
+ randomUUID: typeof randomUUID;
949
+ deepClone: typeof deepClone;
950
+ pick: typeof pick;
951
+ omit: typeof omit;
952
+ get: typeof get;
953
+ set: typeof set;
954
+ };
955
+
956
+ export { array, capitalize, chunk, clamp, deepClone, toolkit as default, encoding, format, formatBytes, formatDateTime, formatDuration, formatNumber, fromBase64, get, hash, isEmail, isEmoji, isEmpty, isUrl, lerp, math, object, omit, pick, pluralize, random, randomBoolean, randomColor, randomElement, randomFloat$1 as randomFloat, randomInt$1 as randomInt, randomString, randomUUID, round, set, shuffle, sleep, string, time, timestamp, timestampMs, toBase64, unique, validation };