@react-hive/honey-utils 3.27.0 → 3.30.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 +1 -0
- package/dist/README.md +1 -0
- package/dist/array/chunk.d.ts +20 -0
- package/dist/array/compact.d.ts +24 -0
- package/dist/array/compose.d.ts +31 -0
- package/dist/array/difference.d.ts +17 -0
- package/dist/array/get-adjacent-items.d.ts +16 -0
- package/dist/array/index.d.ts +10 -0
- package/dist/array/intersection.d.ts +16 -0
- package/dist/array/is-array.d.ts +8 -0
- package/dist/array/is-empty-array.d.ts +8 -0
- package/dist/array/pipe.d.ts +32 -0
- package/dist/array/unique.d.ts +18 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.dev.cjs +268 -71
- package/dist/index.dev.cjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -28
- package/dist/array.d.ts +0 -172
package/dist/index.dev.cjs
CHANGED
|
@@ -212,42 +212,55 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
212
212
|
|
|
213
213
|
/***/ },
|
|
214
214
|
|
|
215
|
-
/***/ "./src/array.ts"
|
|
216
|
-
|
|
217
|
-
!*** ./src/array.ts ***!
|
|
218
|
-
|
|
215
|
+
/***/ "./src/array/chunk.ts"
|
|
216
|
+
/*!****************************!*\
|
|
217
|
+
!*** ./src/array/chunk.ts ***!
|
|
218
|
+
\****************************/
|
|
219
219
|
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
220
220
|
|
|
221
221
|
__webpack_require__.r(__webpack_exports__);
|
|
222
222
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
223
|
-
/* harmony export */ chunk: () => (/* binding */ chunk)
|
|
224
|
-
/* harmony export */ compact: () => (/* binding */ compact),
|
|
225
|
-
/* harmony export */ compose: () => (/* binding */ compose),
|
|
226
|
-
/* harmony export */ difference: () => (/* binding */ difference),
|
|
227
|
-
/* harmony export */ intersection: () => (/* binding */ intersection),
|
|
228
|
-
/* harmony export */ isArray: () => (/* binding */ isArray),
|
|
229
|
-
/* harmony export */ isEmptyArray: () => (/* binding */ isEmptyArray),
|
|
230
|
-
/* harmony export */ pipe: () => (/* binding */ pipe),
|
|
231
|
-
/* harmony export */ unique: () => (/* binding */ unique)
|
|
223
|
+
/* harmony export */ chunk: () => (/* binding */ chunk)
|
|
232
224
|
/* harmony export */ });
|
|
233
225
|
/* harmony import */ var _guards__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ~/guards */ "./src/guards.ts");
|
|
234
226
|
|
|
235
227
|
/**
|
|
236
|
-
*
|
|
228
|
+
* Splits an array into chunks of the specified size.
|
|
237
229
|
*
|
|
238
|
-
*
|
|
230
|
+
* Useful for pagination, batch processing, or creating grid layouts.
|
|
239
231
|
*
|
|
240
|
-
* @
|
|
241
|
-
*/
|
|
242
|
-
const isArray = (value) => Array.isArray(value);
|
|
243
|
-
/**
|
|
244
|
-
* Checks if a value is an empty array.
|
|
232
|
+
* @template T - The type of the items in the array.
|
|
245
233
|
*
|
|
246
|
-
* @param
|
|
234
|
+
* @param array - The input array to be chunked.
|
|
235
|
+
* @param size - The size of each chunk. Must be greater than 0.
|
|
247
236
|
*
|
|
248
|
-
* @returns
|
|
237
|
+
* @returns An array of chunks, where each chunk is an array of the specified size
|
|
238
|
+
* (except possibly the last chunk, which may be smaller).
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
* ```ts
|
|
242
|
+
* chunk([1, 2, 3, 4, 5], 2); // [[1, 2], [3, 4], [5]]
|
|
243
|
+
* chunk(['a', 'b', 'c', 'd'], 3); // [['a', 'b', 'c'], ['d']]
|
|
244
|
+
* ```
|
|
249
245
|
*/
|
|
250
|
-
const
|
|
246
|
+
const chunk = (array, size) => {
|
|
247
|
+
(0,_guards__WEBPACK_IMPORTED_MODULE_0__.assert)(size > 0, 'Chunk size must be greater than 0');
|
|
248
|
+
return Array.from({ length: Math.ceil(array.length / size) }, (_, index) => array.slice(index * size, (index + 1) * size));
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
/***/ },
|
|
253
|
+
|
|
254
|
+
/***/ "./src/array/compact.ts"
|
|
255
|
+
/*!******************************!*\
|
|
256
|
+
!*** ./src/array/compact.ts ***!
|
|
257
|
+
\******************************/
|
|
258
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
259
|
+
|
|
260
|
+
__webpack_require__.r(__webpack_exports__);
|
|
261
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
262
|
+
/* harmony export */ compact: () => (/* binding */ compact)
|
|
263
|
+
/* harmony export */ });
|
|
251
264
|
/**
|
|
252
265
|
* Removes all falsy values from an array.
|
|
253
266
|
*
|
|
@@ -267,47 +280,176 @@ const isEmptyArray = (value) => isArray(value) && value.length === 0;
|
|
|
267
280
|
* ```
|
|
268
281
|
*/
|
|
269
282
|
const compact = (array) => array.filter(Boolean);
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
/***/ },
|
|
286
|
+
|
|
287
|
+
/***/ "./src/array/compose.ts"
|
|
288
|
+
/*!******************************!*\
|
|
289
|
+
!*** ./src/array/compose.ts ***!
|
|
290
|
+
\******************************/
|
|
291
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
292
|
+
|
|
293
|
+
__webpack_require__.r(__webpack_exports__);
|
|
294
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
295
|
+
/* harmony export */ compose: () => (/* binding */ compose)
|
|
296
|
+
/* harmony export */ });
|
|
270
297
|
/**
|
|
271
|
-
*
|
|
272
|
-
*
|
|
273
|
-
* Uses Set for efficient duplicate removal while preserving the original order.
|
|
298
|
+
* Composes multiple unary functions into a single function, applying them from **right to left**.
|
|
274
299
|
*
|
|
275
|
-
*
|
|
300
|
+
* Often used for building functional pipelines where the innermost function runs first.
|
|
301
|
+
* Types are inferred up to 5 chained functions for full type safety.
|
|
276
302
|
*
|
|
277
|
-
* @param
|
|
303
|
+
* @param fns - A list of unary functions to compose.
|
|
278
304
|
*
|
|
279
|
-
* @returns A new
|
|
305
|
+
* @returns A new function that applies all functions from right to left.
|
|
280
306
|
*
|
|
281
307
|
* @example
|
|
282
308
|
* ```ts
|
|
283
|
-
*
|
|
284
|
-
*
|
|
309
|
+
* const add = (x: number) => x + 1;
|
|
310
|
+
* const double = (x: number) => x * 2;
|
|
311
|
+
* const toStr = (x: number) => `Result: ${x}`;
|
|
312
|
+
*
|
|
313
|
+
* const result = compose(toStr, double, add)(2);
|
|
314
|
+
* // => 'Result: 6'
|
|
285
315
|
* ```
|
|
286
316
|
*/
|
|
287
|
-
const
|
|
317
|
+
const compose = (...fns) => (arg) => fns.reduceRight((prev, fn) => fn(prev), arg);
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
/***/ },
|
|
321
|
+
|
|
322
|
+
/***/ "./src/array/difference.ts"
|
|
323
|
+
/*!*********************************!*\
|
|
324
|
+
!*** ./src/array/difference.ts ***!
|
|
325
|
+
\*********************************/
|
|
326
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
327
|
+
|
|
328
|
+
__webpack_require__.r(__webpack_exports__);
|
|
329
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
330
|
+
/* harmony export */ difference: () => (/* binding */ difference)
|
|
331
|
+
/* harmony export */ });
|
|
288
332
|
/**
|
|
289
|
-
*
|
|
290
|
-
*
|
|
291
|
-
* Useful for pagination, batch processing, or creating grid layouts.
|
|
333
|
+
* Returns elements from the first array that don't exist in the second array.
|
|
292
334
|
*
|
|
293
|
-
* @template T - The type of the items in the
|
|
335
|
+
* @template T - The type of the items in the arrays.
|
|
294
336
|
*
|
|
295
|
-
* @param array - The
|
|
296
|
-
* @param
|
|
337
|
+
* @param array - The source array.
|
|
338
|
+
* @param exclude - The array containing elements to exclude.
|
|
297
339
|
*
|
|
298
|
-
* @returns
|
|
299
|
-
* (except possibly the last chunk, which may be smaller).
|
|
340
|
+
* @returns A new array with elements from the first array that don't exist in the second array.
|
|
300
341
|
*
|
|
301
342
|
* @example
|
|
302
343
|
* ```ts
|
|
303
|
-
*
|
|
304
|
-
*
|
|
344
|
+
* difference([1, 2, 3, 4], [2, 4]); // [1, 3]
|
|
345
|
+
* difference(['a', 'b', 'c'], ['b']); // ['a', 'c']
|
|
305
346
|
* ```
|
|
306
347
|
*/
|
|
307
|
-
const
|
|
308
|
-
|
|
309
|
-
|
|
348
|
+
const difference = (array, exclude) => array.filter(item => !exclude.includes(item));
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
/***/ },
|
|
352
|
+
|
|
353
|
+
/***/ "./src/array/get-adjacent-items.ts"
|
|
354
|
+
/*!*****************************************!*\
|
|
355
|
+
!*** ./src/array/get-adjacent-items.ts ***!
|
|
356
|
+
\*****************************************/
|
|
357
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
358
|
+
|
|
359
|
+
__webpack_require__.r(__webpack_exports__);
|
|
360
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
361
|
+
/* harmony export */ getAdjacentItems: () => (/* binding */ getAdjacentItems)
|
|
362
|
+
/* harmony export */ });
|
|
363
|
+
/**
|
|
364
|
+
* Returns previous, current, and next items for the matched item.
|
|
365
|
+
*
|
|
366
|
+
* @param items - Source items.
|
|
367
|
+
* @param targetItem - Item to find in the source array.
|
|
368
|
+
* @param isSameItem - Comparator used to match items.
|
|
369
|
+
*
|
|
370
|
+
* @returns Adjacent items around the matched item.
|
|
371
|
+
*/
|
|
372
|
+
const getAdjacentItems = (items, targetItem, isSameItem) => {
|
|
373
|
+
if (!items?.length || !targetItem) {
|
|
374
|
+
return {
|
|
375
|
+
previousItem: null,
|
|
376
|
+
currentItem: null,
|
|
377
|
+
nextItem: null,
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
const currentItemIndex = items.findIndex(item => isSameItem(item, targetItem));
|
|
381
|
+
if (currentItemIndex === -1) {
|
|
382
|
+
return {
|
|
383
|
+
previousItem: null,
|
|
384
|
+
currentItem: null,
|
|
385
|
+
nextItem: null,
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
return {
|
|
389
|
+
previousItem: currentItemIndex > 0 ? items[currentItemIndex - 1] : null,
|
|
390
|
+
currentItem: items[currentItemIndex],
|
|
391
|
+
nextItem: currentItemIndex < items.length - 1 ? items[currentItemIndex + 1] : null,
|
|
392
|
+
};
|
|
310
393
|
};
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
/***/ },
|
|
397
|
+
|
|
398
|
+
/***/ "./src/array/index.ts"
|
|
399
|
+
/*!****************************!*\
|
|
400
|
+
!*** ./src/array/index.ts ***!
|
|
401
|
+
\****************************/
|
|
402
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
403
|
+
|
|
404
|
+
__webpack_require__.r(__webpack_exports__);
|
|
405
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
406
|
+
/* harmony export */ chunk: () => (/* reexport safe */ _chunk__WEBPACK_IMPORTED_MODULE_4__.chunk),
|
|
407
|
+
/* harmony export */ compact: () => (/* reexport safe */ _compact__WEBPACK_IMPORTED_MODULE_6__.compact),
|
|
408
|
+
/* harmony export */ compose: () => (/* reexport safe */ _compose__WEBPACK_IMPORTED_MODULE_1__.compose),
|
|
409
|
+
/* harmony export */ difference: () => (/* reexport safe */ _difference__WEBPACK_IMPORTED_MODULE_2__.difference),
|
|
410
|
+
/* harmony export */ getAdjacentItems: () => (/* reexport safe */ _get_adjacent_items__WEBPACK_IMPORTED_MODULE_9__.getAdjacentItems),
|
|
411
|
+
/* harmony export */ intersection: () => (/* reexport safe */ _intersection__WEBPACK_IMPORTED_MODULE_3__.intersection),
|
|
412
|
+
/* harmony export */ isArray: () => (/* reexport safe */ _is_array__WEBPACK_IMPORTED_MODULE_7__.isArray),
|
|
413
|
+
/* harmony export */ isEmptyArray: () => (/* reexport safe */ _is_empty_array__WEBPACK_IMPORTED_MODULE_8__.isEmptyArray),
|
|
414
|
+
/* harmony export */ pipe: () => (/* reexport safe */ _pipe__WEBPACK_IMPORTED_MODULE_0__.pipe),
|
|
415
|
+
/* harmony export */ unique: () => (/* reexport safe */ _unique__WEBPACK_IMPORTED_MODULE_5__.unique)
|
|
416
|
+
/* harmony export */ });
|
|
417
|
+
/* harmony import */ var _pipe__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pipe */ "./src/array/pipe.ts");
|
|
418
|
+
/* harmony import */ var _compose__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./compose */ "./src/array/compose.ts");
|
|
419
|
+
/* harmony import */ var _difference__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./difference */ "./src/array/difference.ts");
|
|
420
|
+
/* harmony import */ var _intersection__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./intersection */ "./src/array/intersection.ts");
|
|
421
|
+
/* harmony import */ var _chunk__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./chunk */ "./src/array/chunk.ts");
|
|
422
|
+
/* harmony import */ var _unique__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./unique */ "./src/array/unique.ts");
|
|
423
|
+
/* harmony import */ var _compact__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./compact */ "./src/array/compact.ts");
|
|
424
|
+
/* harmony import */ var _is_array__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./is-array */ "./src/array/is-array.ts");
|
|
425
|
+
/* harmony import */ var _is_empty_array__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./is-empty-array */ "./src/array/is-empty-array.ts");
|
|
426
|
+
/* harmony import */ var _get_adjacent_items__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./get-adjacent-items */ "./src/array/get-adjacent-items.ts");
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
/***/ },
|
|
440
|
+
|
|
441
|
+
/***/ "./src/array/intersection.ts"
|
|
442
|
+
/*!***********************************!*\
|
|
443
|
+
!*** ./src/array/intersection.ts ***!
|
|
444
|
+
\***********************************/
|
|
445
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
446
|
+
|
|
447
|
+
__webpack_require__.r(__webpack_exports__);
|
|
448
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
449
|
+
/* harmony export */ intersection: () => (/* binding */ intersection)
|
|
450
|
+
/* harmony export */ });
|
|
451
|
+
/* harmony import */ var _array__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ~/array */ "./src/array/index.ts");
|
|
452
|
+
|
|
311
453
|
/**
|
|
312
454
|
* Returns an array containing elements that exist in all provided arrays.
|
|
313
455
|
*
|
|
@@ -331,26 +473,69 @@ const intersection = (...arrays) => {
|
|
|
331
473
|
return [...arrays[0]];
|
|
332
474
|
}
|
|
333
475
|
const [first, ...rest] = arrays;
|
|
334
|
-
const uniqueFirst = unique(first);
|
|
476
|
+
const uniqueFirst = (0,_array__WEBPACK_IMPORTED_MODULE_0__.unique)(first);
|
|
335
477
|
return uniqueFirst.filter(item => rest.every(array => array.includes(item)));
|
|
336
478
|
};
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
/***/ },
|
|
482
|
+
|
|
483
|
+
/***/ "./src/array/is-array.ts"
|
|
484
|
+
/*!*******************************!*\
|
|
485
|
+
!*** ./src/array/is-array.ts ***!
|
|
486
|
+
\*******************************/
|
|
487
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
488
|
+
|
|
489
|
+
__webpack_require__.r(__webpack_exports__);
|
|
490
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
491
|
+
/* harmony export */ isArray: () => (/* binding */ isArray)
|
|
492
|
+
/* harmony export */ });
|
|
337
493
|
/**
|
|
338
|
-
*
|
|
494
|
+
* Checks if a value is an array.
|
|
339
495
|
*
|
|
340
|
-
* @
|
|
496
|
+
* @param value - The value to check.
|
|
341
497
|
*
|
|
342
|
-
* @
|
|
343
|
-
|
|
498
|
+
* @returns `true` if the value is an array; otherwise, `false`.
|
|
499
|
+
*/
|
|
500
|
+
const isArray = (value) => Array.isArray(value);
|
|
501
|
+
|
|
502
|
+
|
|
503
|
+
/***/ },
|
|
504
|
+
|
|
505
|
+
/***/ "./src/array/is-empty-array.ts"
|
|
506
|
+
/*!*************************************!*\
|
|
507
|
+
!*** ./src/array/is-empty-array.ts ***!
|
|
508
|
+
\*************************************/
|
|
509
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
510
|
+
|
|
511
|
+
__webpack_require__.r(__webpack_exports__);
|
|
512
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
513
|
+
/* harmony export */ isEmptyArray: () => (/* binding */ isEmptyArray)
|
|
514
|
+
/* harmony export */ });
|
|
515
|
+
/* harmony import */ var _array__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ~/array */ "./src/array/index.ts");
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Checks if a value is an empty array.
|
|
344
519
|
*
|
|
345
|
-
* @
|
|
520
|
+
* @param value - The value to check.
|
|
346
521
|
*
|
|
347
|
-
* @
|
|
348
|
-
* ```ts
|
|
349
|
-
* difference([1, 2, 3, 4], [2, 4]); // [1, 3]
|
|
350
|
-
* difference(['a', 'b', 'c'], ['b']); // ['a', 'c']
|
|
351
|
-
* ```
|
|
522
|
+
* @returns `true` if the value is an empty array; otherwise, `false`.
|
|
352
523
|
*/
|
|
353
|
-
const
|
|
524
|
+
const isEmptyArray = (value) => (0,_array__WEBPACK_IMPORTED_MODULE_0__.isArray)(value) && value.length === 0;
|
|
525
|
+
|
|
526
|
+
|
|
527
|
+
/***/ },
|
|
528
|
+
|
|
529
|
+
/***/ "./src/array/pipe.ts"
|
|
530
|
+
/*!***************************!*\
|
|
531
|
+
!*** ./src/array/pipe.ts ***!
|
|
532
|
+
\***************************/
|
|
533
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
534
|
+
|
|
535
|
+
__webpack_require__.r(__webpack_exports__);
|
|
536
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
537
|
+
/* harmony export */ pipe: () => (/* binding */ pipe)
|
|
538
|
+
/* harmony export */ });
|
|
354
539
|
/**
|
|
355
540
|
* Composes multiple unary functions into a single function, applying them from left to right.
|
|
356
541
|
*
|
|
@@ -373,27 +558,38 @@ const difference = (array, exclude) => array.filter(item => !exclude.includes(it
|
|
|
373
558
|
* ```
|
|
374
559
|
*/
|
|
375
560
|
const pipe = (...fns) => (arg) => fns.reduce((prev, fn) => fn(prev), arg);
|
|
561
|
+
|
|
562
|
+
|
|
563
|
+
/***/ },
|
|
564
|
+
|
|
565
|
+
/***/ "./src/array/unique.ts"
|
|
566
|
+
/*!*****************************!*\
|
|
567
|
+
!*** ./src/array/unique.ts ***!
|
|
568
|
+
\*****************************/
|
|
569
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
570
|
+
|
|
571
|
+
__webpack_require__.r(__webpack_exports__);
|
|
572
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
573
|
+
/* harmony export */ unique: () => (/* binding */ unique)
|
|
574
|
+
/* harmony export */ });
|
|
376
575
|
/**
|
|
377
|
-
*
|
|
576
|
+
* Returns a new array with duplicate values removed.
|
|
378
577
|
*
|
|
379
|
-
*
|
|
380
|
-
* Types are inferred up to 5 chained functions for full type safety.
|
|
578
|
+
* Uses Set for efficient duplicate removal while preserving the original order.
|
|
381
579
|
*
|
|
382
|
-
* @
|
|
580
|
+
* @template T - The type of the items in the array.
|
|
383
581
|
*
|
|
384
|
-
* @
|
|
582
|
+
* @param array - The input array that may contain duplicate values.
|
|
583
|
+
*
|
|
584
|
+
* @returns A new array with only unique values, maintaining the original order.
|
|
385
585
|
*
|
|
386
586
|
* @example
|
|
387
587
|
* ```ts
|
|
388
|
-
*
|
|
389
|
-
*
|
|
390
|
-
* const toStr = (x: number) => `Result: ${x}`;
|
|
391
|
-
*
|
|
392
|
-
* const result = compose(toStr, double, add)(2);
|
|
393
|
-
* // => 'Result: 6'
|
|
588
|
+
* unique([1, 2, 2, 3, 1, 4]); // [1, 2, 3, 4]
|
|
589
|
+
* unique(['a', 'b', 'a', 'c']); // ['a', 'b', 'c']
|
|
394
590
|
* ```
|
|
395
591
|
*/
|
|
396
|
-
const
|
|
592
|
+
const unique = (array) => [...new Set(array)];
|
|
397
593
|
|
|
398
594
|
|
|
399
595
|
/***/ },
|
|
@@ -416,7 +612,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
416
612
|
/* harmony export */ runSequential: () => (/* binding */ runSequential),
|
|
417
613
|
/* harmony export */ someAsync: () => (/* binding */ someAsync)
|
|
418
614
|
/* harmony export */ });
|
|
419
|
-
/* harmony import */ var _array__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ~/array */ "./src/array.ts");
|
|
615
|
+
/* harmony import */ var _array__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ~/array */ "./src/array/index.ts");
|
|
420
616
|
/* harmony import */ var _function__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ~/function */ "./src/function/index.ts");
|
|
421
617
|
|
|
422
618
|
|
|
@@ -3382,6 +3578,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
3382
3578
|
/* harmony export */ flattenTree: () => (/* reexport safe */ _tree__WEBPACK_IMPORTED_MODULE_14__.flattenTree),
|
|
3383
3579
|
/* harmony export */ forEachChar: () => (/* reexport safe */ _string__WEBPACK_IMPORTED_MODULE_13__.forEachChar),
|
|
3384
3580
|
/* harmony export */ generateEphemeralId: () => (/* reexport safe */ _id__WEBPACK_IMPORTED_MODULE_9__.generateEphemeralId),
|
|
3581
|
+
/* harmony export */ getAdjacentItems: () => (/* reexport safe */ _array__WEBPACK_IMPORTED_MODULE_1__.getAdjacentItems),
|
|
3385
3582
|
/* harmony export */ getDOMRectIntersectionRatio: () => (/* reexport safe */ _intersection__WEBPACK_IMPORTED_MODULE_10__.getDOMRectIntersectionRatio),
|
|
3386
3583
|
/* harmony export */ getDataTransferJson: () => (/* reexport safe */ _dom__WEBPACK_IMPORTED_MODULE_3__.getDataTransferJson),
|
|
3387
3584
|
/* harmony export */ getElementOffsetRect: () => (/* reexport safe */ _dom__WEBPACK_IMPORTED_MODULE_3__.getElementOffsetRect),
|
|
@@ -3452,7 +3649,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
3452
3649
|
/* harmony export */ unique: () => (/* reexport safe */ _array__WEBPACK_IMPORTED_MODULE_1__.unique)
|
|
3453
3650
|
/* harmony export */ });
|
|
3454
3651
|
/* harmony import */ var _a11y__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./a11y */ "./src/a11y/index.ts");
|
|
3455
|
-
/* harmony import */ var _array__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./array */ "./src/array.ts");
|
|
3652
|
+
/* harmony import */ var _array__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./array */ "./src/array/index.ts");
|
|
3456
3653
|
/* harmony import */ var _async__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./async */ "./src/async/index.ts");
|
|
3457
3654
|
/* harmony import */ var _dom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./dom */ "./src/dom/index.ts");
|
|
3458
3655
|
/* harmony import */ var _env__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./env */ "./src/env/index.ts");
|