@react-hive/honey-utils 3.0.0 → 3.2.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.
package/README.md CHANGED
@@ -48,7 +48,32 @@ import * as HoneyUtils from '@react-hive/honey-utils';
48
48
  ### String Utilities
49
49
 
50
50
  ```ts
51
- import { toKebabCase, camelToDashCase, splitStringIntoWords, hashString } from '@react-hive/honey-utils';
51
+ import {
52
+ isString,
53
+ isNilOrEmptyString,
54
+ toKebabCase,
55
+ camelToDashCase,
56
+ splitStringIntoWords,
57
+ hashString
58
+ } from '@react-hive/honey-utils';
59
+
60
+ /**
61
+ * Check if value is a string
62
+ */
63
+ isString('hello');
64
+ // ➜ true
65
+ isString(123);
66
+ // ➜ false
67
+
68
+ /**
69
+ * Check if value is null, undefined, or empty string
70
+ */
71
+ isNilOrEmptyString('');
72
+ // ➜ true
73
+ isNilOrEmptyString(null);
74
+ // ➜ true
75
+ isNilOrEmptyString('hello');
76
+ // ➜ false
52
77
 
53
78
  /**
54
79
  * Convert string to kebab-case
@@ -79,6 +104,8 @@ const hash = hashString('background-color: red;');
79
104
 
80
105
  ```ts
81
106
  import {
107
+ isArray,
108
+ isEmptyArray,
82
109
  compact,
83
110
  unique,
84
111
  chunk,
@@ -88,6 +115,22 @@ import {
88
115
  compose,
89
116
  } from '@react-hive/honey-utils';
90
117
 
118
+ /**
119
+ * Check if value is an array
120
+ */
121
+ isArray([1, 2, 3]);
122
+ // ➜ true
123
+ isArray({});
124
+ // ➜ false
125
+
126
+ /**
127
+ * Check if value is an empty array
128
+ */
129
+ isEmptyArray([]);
130
+ // ➜ true
131
+ isEmptyArray([1, 2, 3]);
132
+ // ➜ false
133
+
91
134
  /**
92
135
  * Filter out falsy values from an array
93
136
  */
@@ -138,6 +181,7 @@ compose(increment, double)(3);
138
181
 
139
182
  ```ts
140
183
  import {
184
+ isPromise,
141
185
  runParallel,
142
186
  runSequential,
143
187
  reduceAsync,
@@ -147,6 +191,14 @@ import {
147
191
  findAsync,
148
192
  } from '@react-hive/honey-utils';
149
193
 
194
+ /**
195
+ * Check if value is a Promise
196
+ */
197
+ isPromise(Promise.resolve());
198
+ // ➜ true
199
+ isPromise({});
200
+ // ➜ false
201
+
150
202
  /**
151
203
  * Run async operations in parallel and collect results
152
204
  */
@@ -214,13 +266,27 @@ await findAsync([1, 3, 4, 5], async (n) => {
214
266
  ### Function Utilities
215
267
 
216
268
  ```ts
217
- import { noop, invokeIfFunction, delay, retry } from '@react-hive/honey-utils';
269
+ import {
270
+ noop,
271
+ isFunction,
272
+ invokeIfFunction,
273
+ delay,
274
+ retry
275
+ } from '@react-hive/honey-utils';
218
276
 
219
277
  /**
220
278
  * No-operation function. Does nothing
221
279
  */
222
280
  noop();
223
281
 
282
+ /**
283
+ * Check if value is a function
284
+ */
285
+ isFunction(() => {});
286
+ // ➜ true
287
+ isFunction({});
288
+ // ➜ false
289
+
224
290
  /**
225
291
  * Invoke if function, otherwise return value
226
292
  */
@@ -265,35 +331,21 @@ fetchWithRetry()
265
331
  ### Type Guards
266
332
 
267
333
  ```ts
268
- import {
269
- isString,
270
- isNumber,
271
- isBool,
272
- isObject,
273
- isFunction,
274
- isPromise,
275
- isNil,
276
- isNilOrEmptyString,
277
- isArray,
278
- isEmptyArray,
279
- isEmptyObject,
280
- isNull,
281
- isUndefined,
282
- isDate,
283
- isValidDate,
284
- isRegExp,
285
- isMap,
286
- isSet
334
+ import {
335
+ isNumber,
336
+ isBool,
337
+ isObject,
338
+ isNil,
339
+ isEmptyObject,
340
+ isNull,
341
+ isUndefined,
342
+ isDate,
343
+ isValidDate,
344
+ isRegExp,
345
+ isMap,
346
+ isSet
287
347
  } from '@react-hive/honey-utils';
288
348
 
289
- /**
290
- * Check if value is a string
291
- */
292
- isString('hello');
293
- // ➜ true
294
- isString(123);
295
- // ➜ false
296
-
297
349
  /**
298
350
  * Check if value is a number
299
351
  */
@@ -318,22 +370,6 @@ isObject({});
318
370
  isObject('object');
319
371
  // ➜ false
320
372
 
321
- /**
322
- * Check if value is a function
323
- */
324
- isFunction(() => {});
325
- // ➜ true
326
- isFunction({});
327
- // ➜ false
328
-
329
- /**
330
- * Check if value is a Promise
331
- */
332
- isPromise(Promise.resolve());
333
- // ➜ true
334
- isPromise({});
335
- // ➜ false
336
-
337
373
  /**
338
374
  * Check if value is null or undefined
339
375
  */
@@ -344,32 +380,6 @@ isNil(undefined);
344
380
  isNil('');
345
381
  // ➜ false
346
382
 
347
- /**
348
- * Check if value is null, undefined, or empty string
349
- */
350
- isNilOrEmptyString('');
351
- // ➜ true
352
- isNilOrEmptyString(null);
353
- // ➜ true
354
- isNilOrEmptyString('hello');
355
- // ➜ false
356
-
357
- /**
358
- * Check if value is an array
359
- */
360
- isArray([1, 2, 3]);
361
- // ➜ true
362
- isArray({});
363
- // ➜ false
364
-
365
- /**
366
- * Check if value is an empty array
367
- */
368
- isEmptyArray([]);
369
- // ➜ true
370
- isEmptyArray([1, 2, 3]);
371
- // ➜ false
372
-
373
383
  /**
374
384
  * Check if value is an empty object
375
385
  */
@@ -414,10 +424,10 @@ isSet(new Set());
414
424
  ### Math Utilities
415
425
 
416
426
  ```ts
417
- import {
418
- calculateEuclideanDistance,
419
- calculateMovingSpeed,
420
- calculatePercentage
427
+ import {
428
+ calculateEuclideanDistance,
429
+ calculateMovingSpeed,
430
+ calculatePercentage
421
431
  } from '@react-hive/honey-utils';
422
432
 
423
433
  /**
@@ -536,6 +546,8 @@ function divide(a: number, b: number): number {
536
546
 
537
547
  ### String Utilities
538
548
 
549
+ - `isString(value: unknown): value is string` - Checks if a value is a `string`.
550
+ - `isNilOrEmptyString(value: unknown): value is null | undefined` - Checks if a value is `null`, `undefined`, or an empty string.
539
551
  - `toKebabCase(input: string): string` - Converts a string to kebab-case.
540
552
  - `camelToDashCase(input: string): string` - Converts camelCase to dash-case.
541
553
  - `splitStringIntoWords(input: string): string[]` - Splits a string into an array of words.
@@ -543,6 +555,8 @@ function divide(a: number, b: number): number {
543
555
 
544
556
  ### Array Utilities
545
557
 
558
+ - `isArray(value: unknown): value is unknown[]` - Checks if a value is an array.
559
+ - `isEmptyArray(value: unknown): value is []` - Checks if a value is an empty array.
546
560
  - `compact<T>(array: (T | Falsy)[]): T[]` – Returns a new array with all falsy values (false, null, undefined, 0, '', NaN) removed, preserving only truthy items of type `T`.
547
561
  - `unique<T>(array: T[]): T[]` - Returns a new array with all duplicate elements removed. Keeps only the first occurrence of each value.
548
562
  - `chunk<T>(array: T[], size: number): T[][]` - Splits an array into smaller arrays ("chunks") of the specified size.
@@ -553,6 +567,7 @@ function divide(a: number, b: number): number {
553
567
 
554
568
  ### Function Utilities
555
569
 
570
+ - `isFunction(value: unknown): value is Function` - Checks if a value is a `function`.
556
571
  - `noop(): void` - A no-operation function.
557
572
  - `not<Args extends any[]>(fn: (...args: Args) => any): (...args: Args) => boolean` - Creates a new function that negates the result of the given predicate function. Useful for logical inversions, e.g., turning `isEven` into `isOdd`.
558
573
  - `invokeIfFunction<Args extends any[], Result>(input: ((...args: Args) => Result) | Result, ...args: Args): Result` - Invokes the input if it's a function, otherwise returns it as-is.
@@ -563,16 +578,10 @@ function divide(a: number, b: number): number {
563
578
  ### Type Guards
564
579
 
565
580
  - `assert(condition: any, message: string): asserts condition` - Asserts that a condition is truthy, throwing an error with the provided message if it's not.
566
- - `isString(value: unknown): value is string` - Checks if a value is a `string`.
567
581
  - `isNumber(value: unknown): value is number` - Checks if a value is a `number`.
568
582
  - `isBool(value: unknown): value is boolean` - Checks if a value is a `boolean`.
569
583
  - `isObject(value: unknown): value is object` - Checks if a value is an `object`.
570
- - `isFunction(value: unknown): value is Function` - Checks if a value is a `function`.
571
- - `isPromise<T = unknown>(value: unknown): value is Promise<T>` - Checks if a value is a `Promise`.
572
584
  - `isNil(value: unknown): value is null | undefined` - Checks if a value is `null` or `undefined`.
573
- - `isNilOrEmptyString(value: unknown): value is null | undefined` - Checks if a value is `null`, `undefined`, or an empty string.
574
- - `isArray(value: unknown): value is unknown[]` - Checks if a value is an array.
575
- - `isEmptyArray(value: unknown): value is []` - Checks if a value is an empty array.
576
585
  - `isEmptyObject(value: unknown): value is Record<string, never>` - Checks if a value is an empty object.
577
586
  - `isNull(value: unknown): value is null` - Checks if a value is `null`.
578
587
  - `isUndefined(value: unknown): value is undefined` - Checks if a value is `undefined`.
@@ -605,12 +614,16 @@ function divide(a: number, b: number): number {
605
614
 
606
615
  ### File Utilities
607
616
 
617
+ - `isFile(value: unknown): value is File` - Checks if a value is a `File`.
608
618
  - `parseFileName(fileName: string): [baseName: string, extension: string]` - Splits a file name into its base name and extension using the last `.` as the separator. Handles edge cases such as hidden files (`.gitignore`), multi-dot names (`archive.tar.gz`), and names ending with a dot (`"file."`). The extension is returned in lowercase.
609
619
  - `fileListToFiles(fileList: FileList | null): File[]` - Converts a `FileList` object (such as the one returned from an `<input type="file">`) into a standard array of `File` objects. Returns an empty array when the input is `null`.
610
620
  - `blobToFile(blob: Blob, fileName: string): File` - Converts a Blob object into a File object with the specified name.
621
+ - `traverseFileSystemDirectory(directoryEntry: FileSystemDirectoryEntry, options?: TraverseDirectoryOptions): Promise<File[]>` — Recursively scans a directory using the File System API and returns all nested files as `File` objects. Supports skipping system files and reporting progress through an optional `onProgress` callback.
622
+ - `readFilesFromDataTransfer(dataTransfer: DataTransfer | null): Promise<File[]>` — Reads files from a `DataTransfer` object (such as drag-and-drop or paste events). Supports both regular dropped files and entire directories via the non-standard `webkitGetAsEntry` API. Directories are traversed recursively, returning a flat array of all extracted `File` objects.
611
623
 
612
624
  ### Asynchronous Utilities
613
625
 
626
+ - `isPromise<T = unknown>(value: unknown): value is Promise<T>` - Checks if a value is a `Promise`.
614
627
  - `runSequential<Item, Result>(array: Item[], fn: (item, index, array) => Promise<Result>): Promise<Result[]>` - Runs asynchronous operations on each array item *sequentially* and returns the results in the original order.
615
628
  - `runParallel<Item, Result>(array: Item[], fn: (item, index, array) => Promise<Result>): Promise<Result[]>` - Executes an asynchronous function for each array item *in parallel* and returns a promise of all results.
616
629
  - `reduceAsync<Item, Accumulator>(array: Item[], fn, initialValue): Promise<Accumulator>` - Asynchronously reduces an array to a single accumulated value. Each step waits for the previous promise to resolve.
package/dist/README.md CHANGED
@@ -48,7 +48,32 @@ import * as HoneyUtils from '@react-hive/honey-utils';
48
48
  ### String Utilities
49
49
 
50
50
  ```ts
51
- import { toKebabCase, camelToDashCase, splitStringIntoWords, hashString } from '@react-hive/honey-utils';
51
+ import {
52
+ isString,
53
+ isNilOrEmptyString,
54
+ toKebabCase,
55
+ camelToDashCase,
56
+ splitStringIntoWords,
57
+ hashString
58
+ } from '@react-hive/honey-utils';
59
+
60
+ /**
61
+ * Check if value is a string
62
+ */
63
+ isString('hello');
64
+ // ➜ true
65
+ isString(123);
66
+ // ➜ false
67
+
68
+ /**
69
+ * Check if value is null, undefined, or empty string
70
+ */
71
+ isNilOrEmptyString('');
72
+ // ➜ true
73
+ isNilOrEmptyString(null);
74
+ // ➜ true
75
+ isNilOrEmptyString('hello');
76
+ // ➜ false
52
77
 
53
78
  /**
54
79
  * Convert string to kebab-case
@@ -79,6 +104,8 @@ const hash = hashString('background-color: red;');
79
104
 
80
105
  ```ts
81
106
  import {
107
+ isArray,
108
+ isEmptyArray,
82
109
  compact,
83
110
  unique,
84
111
  chunk,
@@ -88,6 +115,22 @@ import {
88
115
  compose,
89
116
  } from '@react-hive/honey-utils';
90
117
 
118
+ /**
119
+ * Check if value is an array
120
+ */
121
+ isArray([1, 2, 3]);
122
+ // ➜ true
123
+ isArray({});
124
+ // ➜ false
125
+
126
+ /**
127
+ * Check if value is an empty array
128
+ */
129
+ isEmptyArray([]);
130
+ // ➜ true
131
+ isEmptyArray([1, 2, 3]);
132
+ // ➜ false
133
+
91
134
  /**
92
135
  * Filter out falsy values from an array
93
136
  */
@@ -138,6 +181,7 @@ compose(increment, double)(3);
138
181
 
139
182
  ```ts
140
183
  import {
184
+ isPromise,
141
185
  runParallel,
142
186
  runSequential,
143
187
  reduceAsync,
@@ -147,6 +191,14 @@ import {
147
191
  findAsync,
148
192
  } from '@react-hive/honey-utils';
149
193
 
194
+ /**
195
+ * Check if value is a Promise
196
+ */
197
+ isPromise(Promise.resolve());
198
+ // ➜ true
199
+ isPromise({});
200
+ // ➜ false
201
+
150
202
  /**
151
203
  * Run async operations in parallel and collect results
152
204
  */
@@ -214,13 +266,27 @@ await findAsync([1, 3, 4, 5], async (n) => {
214
266
  ### Function Utilities
215
267
 
216
268
  ```ts
217
- import { noop, invokeIfFunction, delay, retry } from '@react-hive/honey-utils';
269
+ import {
270
+ noop,
271
+ isFunction,
272
+ invokeIfFunction,
273
+ delay,
274
+ retry
275
+ } from '@react-hive/honey-utils';
218
276
 
219
277
  /**
220
278
  * No-operation function. Does nothing
221
279
  */
222
280
  noop();
223
281
 
282
+ /**
283
+ * Check if value is a function
284
+ */
285
+ isFunction(() => {});
286
+ // ➜ true
287
+ isFunction({});
288
+ // ➜ false
289
+
224
290
  /**
225
291
  * Invoke if function, otherwise return value
226
292
  */
@@ -265,35 +331,21 @@ fetchWithRetry()
265
331
  ### Type Guards
266
332
 
267
333
  ```ts
268
- import {
269
- isString,
270
- isNumber,
271
- isBool,
272
- isObject,
273
- isFunction,
274
- isPromise,
275
- isNil,
276
- isNilOrEmptyString,
277
- isArray,
278
- isEmptyArray,
279
- isEmptyObject,
280
- isNull,
281
- isUndefined,
282
- isDate,
283
- isValidDate,
284
- isRegExp,
285
- isMap,
286
- isSet
334
+ import {
335
+ isNumber,
336
+ isBool,
337
+ isObject,
338
+ isNil,
339
+ isEmptyObject,
340
+ isNull,
341
+ isUndefined,
342
+ isDate,
343
+ isValidDate,
344
+ isRegExp,
345
+ isMap,
346
+ isSet
287
347
  } from '@react-hive/honey-utils';
288
348
 
289
- /**
290
- * Check if value is a string
291
- */
292
- isString('hello');
293
- // ➜ true
294
- isString(123);
295
- // ➜ false
296
-
297
349
  /**
298
350
  * Check if value is a number
299
351
  */
@@ -318,22 +370,6 @@ isObject({});
318
370
  isObject('object');
319
371
  // ➜ false
320
372
 
321
- /**
322
- * Check if value is a function
323
- */
324
- isFunction(() => {});
325
- // ➜ true
326
- isFunction({});
327
- // ➜ false
328
-
329
- /**
330
- * Check if value is a Promise
331
- */
332
- isPromise(Promise.resolve());
333
- // ➜ true
334
- isPromise({});
335
- // ➜ false
336
-
337
373
  /**
338
374
  * Check if value is null or undefined
339
375
  */
@@ -344,32 +380,6 @@ isNil(undefined);
344
380
  isNil('');
345
381
  // ➜ false
346
382
 
347
- /**
348
- * Check if value is null, undefined, or empty string
349
- */
350
- isNilOrEmptyString('');
351
- // ➜ true
352
- isNilOrEmptyString(null);
353
- // ➜ true
354
- isNilOrEmptyString('hello');
355
- // ➜ false
356
-
357
- /**
358
- * Check if value is an array
359
- */
360
- isArray([1, 2, 3]);
361
- // ➜ true
362
- isArray({});
363
- // ➜ false
364
-
365
- /**
366
- * Check if value is an empty array
367
- */
368
- isEmptyArray([]);
369
- // ➜ true
370
- isEmptyArray([1, 2, 3]);
371
- // ➜ false
372
-
373
383
  /**
374
384
  * Check if value is an empty object
375
385
  */
@@ -414,10 +424,10 @@ isSet(new Set());
414
424
  ### Math Utilities
415
425
 
416
426
  ```ts
417
- import {
418
- calculateEuclideanDistance,
419
- calculateMovingSpeed,
420
- calculatePercentage
427
+ import {
428
+ calculateEuclideanDistance,
429
+ calculateMovingSpeed,
430
+ calculatePercentage
421
431
  } from '@react-hive/honey-utils';
422
432
 
423
433
  /**
@@ -536,6 +546,8 @@ function divide(a: number, b: number): number {
536
546
 
537
547
  ### String Utilities
538
548
 
549
+ - `isString(value: unknown): value is string` - Checks if a value is a `string`.
550
+ - `isNilOrEmptyString(value: unknown): value is null | undefined` - Checks if a value is `null`, `undefined`, or an empty string.
539
551
  - `toKebabCase(input: string): string` - Converts a string to kebab-case.
540
552
  - `camelToDashCase(input: string): string` - Converts camelCase to dash-case.
541
553
  - `splitStringIntoWords(input: string): string[]` - Splits a string into an array of words.
@@ -543,6 +555,8 @@ function divide(a: number, b: number): number {
543
555
 
544
556
  ### Array Utilities
545
557
 
558
+ - `isArray(value: unknown): value is unknown[]` - Checks if a value is an array.
559
+ - `isEmptyArray(value: unknown): value is []` - Checks if a value is an empty array.
546
560
  - `compact<T>(array: (T | Falsy)[]): T[]` – Returns a new array with all falsy values (false, null, undefined, 0, '', NaN) removed, preserving only truthy items of type `T`.
547
561
  - `unique<T>(array: T[]): T[]` - Returns a new array with all duplicate elements removed. Keeps only the first occurrence of each value.
548
562
  - `chunk<T>(array: T[], size: number): T[][]` - Splits an array into smaller arrays ("chunks") of the specified size.
@@ -553,6 +567,7 @@ function divide(a: number, b: number): number {
553
567
 
554
568
  ### Function Utilities
555
569
 
570
+ - `isFunction(value: unknown): value is Function` - Checks if a value is a `function`.
556
571
  - `noop(): void` - A no-operation function.
557
572
  - `not<Args extends any[]>(fn: (...args: Args) => any): (...args: Args) => boolean` - Creates a new function that negates the result of the given predicate function. Useful for logical inversions, e.g., turning `isEven` into `isOdd`.
558
573
  - `invokeIfFunction<Args extends any[], Result>(input: ((...args: Args) => Result) | Result, ...args: Args): Result` - Invokes the input if it's a function, otherwise returns it as-is.
@@ -563,16 +578,10 @@ function divide(a: number, b: number): number {
563
578
  ### Type Guards
564
579
 
565
580
  - `assert(condition: any, message: string): asserts condition` - Asserts that a condition is truthy, throwing an error with the provided message if it's not.
566
- - `isString(value: unknown): value is string` - Checks if a value is a `string`.
567
581
  - `isNumber(value: unknown): value is number` - Checks if a value is a `number`.
568
582
  - `isBool(value: unknown): value is boolean` - Checks if a value is a `boolean`.
569
583
  - `isObject(value: unknown): value is object` - Checks if a value is an `object`.
570
- - `isFunction(value: unknown): value is Function` - Checks if a value is a `function`.
571
- - `isPromise<T = unknown>(value: unknown): value is Promise<T>` - Checks if a value is a `Promise`.
572
584
  - `isNil(value: unknown): value is null | undefined` - Checks if a value is `null` or `undefined`.
573
- - `isNilOrEmptyString(value: unknown): value is null | undefined` - Checks if a value is `null`, `undefined`, or an empty string.
574
- - `isArray(value: unknown): value is unknown[]` - Checks if a value is an array.
575
- - `isEmptyArray(value: unknown): value is []` - Checks if a value is an empty array.
576
585
  - `isEmptyObject(value: unknown): value is Record<string, never>` - Checks if a value is an empty object.
577
586
  - `isNull(value: unknown): value is null` - Checks if a value is `null`.
578
587
  - `isUndefined(value: unknown): value is undefined` - Checks if a value is `undefined`.
@@ -605,12 +614,16 @@ function divide(a: number, b: number): number {
605
614
 
606
615
  ### File Utilities
607
616
 
617
+ - `isFile(value: unknown): value is File` - Checks if a value is a `File`.
608
618
  - `parseFileName(fileName: string): [baseName: string, extension: string]` - Splits a file name into its base name and extension using the last `.` as the separator. Handles edge cases such as hidden files (`.gitignore`), multi-dot names (`archive.tar.gz`), and names ending with a dot (`"file."`). The extension is returned in lowercase.
609
619
  - `fileListToFiles(fileList: FileList | null): File[]` - Converts a `FileList` object (such as the one returned from an `<input type="file">`) into a standard array of `File` objects. Returns an empty array when the input is `null`.
610
620
  - `blobToFile(blob: Blob, fileName: string): File` - Converts a Blob object into a File object with the specified name.
621
+ - `traverseFileSystemDirectory(directoryEntry: FileSystemDirectoryEntry, options?: TraverseDirectoryOptions): Promise<File[]>` — Recursively scans a directory using the File System API and returns all nested files as `File` objects. Supports skipping system files and reporting progress through an optional `onProgress` callback.
622
+ - `readFilesFromDataTransfer(dataTransfer: DataTransfer | null): Promise<File[]>` — Reads files from a `DataTransfer` object (such as drag-and-drop or paste events). Supports both regular dropped files and entire directories via the non-standard `webkitGetAsEntry` API. Directories are traversed recursively, returning a flat array of all extracted `File` objects.
611
623
 
612
624
  ### Asynchronous Utilities
613
625
 
626
+ - `isPromise<T = unknown>(value: unknown): value is Promise<T>` - Checks if a value is a `Promise`.
614
627
  - `runSequential<Item, Result>(array: Item[], fn: (item, index, array) => Promise<Result>): Promise<Result[]>` - Runs asynchronous operations on each array item *sequentially* and returns the results in the original order.
615
628
  - `runParallel<Item, Result>(array: Item[], fn: (item, index, array) => Promise<Result>): Promise<Result[]>` - Executes an asynchronous function for each array item *in parallel* and returns a promise of all results.
616
629
  - `reduceAsync<Item, Accumulator>(array: Item[], fn, initialValue): Promise<Accumulator>` - Asynchronously reduces an array to a single accumulated value. Each step waits for the previous promise to resolve.
package/dist/array.d.ts CHANGED
@@ -1,3 +1,19 @@
1
+ /**
2
+ * Checks if a value is an array.
3
+ *
4
+ * @param value - The value to check.
5
+ *
6
+ * @returns `true` if the value is an array; otherwise, `false`.
7
+ */
8
+ export declare const isArray: (value: unknown) => value is unknown[];
9
+ /**
10
+ * Checks if a value is an empty array.
11
+ *
12
+ * @param value - The value to check.
13
+ *
14
+ * @returns `true` if the value is an empty array; otherwise, `false`.
15
+ */
16
+ export declare const isEmptyArray: (value: unknown) => value is [];
1
17
  /**
2
18
  * Represents all falsy values.
3
19
  */
package/dist/async.d.ts CHANGED
@@ -1,3 +1,13 @@
1
+ /**
2
+ * Checks if a value is a Promise.
3
+ *
4
+ * @template T - The type of the value that the Promise resolves to.
5
+ *
6
+ * @param value - The value to check.
7
+ *
8
+ * @returns `true` if the value is a Promise; otherwise, `false`.
9
+ */
10
+ export declare const isPromise: <T = unknown>(value: unknown) => value is Promise<T>;
1
11
  /**
2
12
  * Asynchronously iterates over an array and executes an async function on each item sequentially,
3
13
  * collecting the results.
package/dist/file.d.ts CHANGED
@@ -1,3 +1,11 @@
1
+ /**
2
+ * Checks if a value is a `File` object.
3
+ *
4
+ * @param value - The value to check.
5
+ *
6
+ * @returns `true` if the value is a `File` object; otherwise, `false`.
7
+ */
8
+ export declare const isFile: (value: unknown) => value is File;
1
9
  /**
2
10
  * Splits a file name into its base name and extension.
3
11
  *
@@ -42,3 +50,59 @@ export declare const fileListToFiles: (fileList: FileList | null) => File[];
42
50
  * ```
43
51
  */
44
52
  export declare const blobToFile: (blob: Blob, fileName: string) => File;
53
+ /**
54
+ * A callback function invoked whenever a file is discovered during directory traversal.
55
+ *
56
+ * @param progress - An object containing details about the current traversal state.
57
+ * @param progress.processed - The total number of files processed so far.
58
+ * @param progress.currentFile - The `File` object for the file just discovered (if available).
59
+ * @param progress.path - The full path of the file relative to the traversed directory (if available).
60
+ */
61
+ type TraverseDirectoryOnProgressHandler = (progress: {
62
+ processed: number;
63
+ currentFile?: File;
64
+ path?: string;
65
+ }) => void;
66
+ interface TraverseDirectoryOptions {
67
+ /**
68
+ * A list of file names that should be ignored during traversal.
69
+ * Any file whose name matches an entry will be skipped entirely.
70
+ *
71
+ * Common values include OS-generated metadata files such as:
72
+ * `.DS_Store`, `Thumbs.db`, `desktop.ini`, `.Spotlight-V100`, etc.
73
+ */
74
+ skipFiles?: string[];
75
+ /**
76
+ * Optional callback invoked each time a file is discovered.
77
+ * Useful for progress tracking when traversing large or deeply nested directories.
78
+ */
79
+ onProgress?: TraverseDirectoryOnProgressHandler;
80
+ }
81
+ /**
82
+ * Recursively scans a directory using the File System API and collects all nested files.
83
+ *
84
+ * This function walks through all subdirectories, resolving each file into a `File` object.
85
+ * Directories themselves are not returned. To avoid unnecessary noise, certain system or
86
+ * OS-generated files can be excluded via the `skipFiles` option.
87
+ *
88
+ * A progress callback (`onProgress`) may be provided to receive updates each time a file
89
+ * is discovered. This is useful when working with large folders or deeply nested structures.
90
+ *
91
+ * @param directoryEntry - The starting directory entry to traverse.
92
+ * @param options - Optional settings that control traversal behavior.
93
+ * @param processed - Internal counter used to track the number of processed files
94
+ * during recursive traversal. Not intended to be provided manually.
95
+ *
96
+ * @returns A promise resolving to a flat array of all collected `File` objects.
97
+ */
98
+ export declare const traverseFileSystemDirectory: (directoryEntry: FileSystemDirectoryEntry, { skipFiles, onProgress, }?: TraverseDirectoryOptions, processed?: number) => Promise<File[]>;
99
+ /**
100
+ * Reads files from a `DataTransfer` object, handling both dropped files
101
+ * and directories (via the non-standard `webkitGetAsEntry` API).
102
+ *
103
+ * @param dataTransfer - The DataTransfer object from a drop or paste event.
104
+ *
105
+ * @returns A promise resolving to a flat array of all extracted File objects.
106
+ */
107
+ export declare const readFilesFromDataTransfer: (dataTransfer: DataTransfer | null) => Promise<File[]>;
108
+ export {};