@react-hive/honey-utils 4.0.0 → 4.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 +80 -6
- package/dist/README.md +80 -6
- package/dist/array/index.d.ts +1 -0
- package/dist/array/toggle-array-item.d.ts +26 -0
- package/dist/dom/history.d.ts +24 -0
- package/dist/dom/index.d.ts +1 -0
- package/dist/encoding/encode-base64-json.d.ts +1 -0
- package/dist/encoding/encode-base64.d.ts +1 -0
- package/dist/encoding/index.d.ts +2 -0
- package/dist/guards.d.ts +23 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.dev.cjs +256 -45
- package/dist/index.dev.cjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/math/clamp.d.ts +18 -0
- package/dist/math/index.d.ts +1 -0
- package/package.json +9 -9
package/dist/index.dev.cjs
CHANGED
|
@@ -412,6 +412,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
412
412
|
/* harmony export */ isArray: () => (/* reexport safe */ _is_array__WEBPACK_IMPORTED_MODULE_7__.isArray),
|
|
413
413
|
/* harmony export */ isEmptyArray: () => (/* reexport safe */ _is_empty_array__WEBPACK_IMPORTED_MODULE_8__.isEmptyArray),
|
|
414
414
|
/* harmony export */ pipe: () => (/* reexport safe */ _pipe__WEBPACK_IMPORTED_MODULE_0__.pipe),
|
|
415
|
+
/* harmony export */ toggleArrayItem: () => (/* reexport safe */ _toggle_array_item__WEBPACK_IMPORTED_MODULE_10__.toggleArrayItem),
|
|
415
416
|
/* harmony export */ unique: () => (/* reexport safe */ _unique__WEBPACK_IMPORTED_MODULE_5__.unique)
|
|
416
417
|
/* harmony export */ });
|
|
417
418
|
/* harmony import */ var _pipe__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pipe */ "./src/array/pipe.ts");
|
|
@@ -424,6 +425,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
424
425
|
/* harmony import */ var _is_array__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./is-array */ "./src/array/is-array.ts");
|
|
425
426
|
/* harmony import */ var _is_empty_array__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./is-empty-array */ "./src/array/is-empty-array.ts");
|
|
426
427
|
/* harmony import */ var _get_adjacent_items__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./get-adjacent-items */ "./src/array/get-adjacent-items.ts");
|
|
428
|
+
/* harmony import */ var _toggle_array_item__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./toggle-array-item */ "./src/array/toggle-array-item.ts");
|
|
429
|
+
|
|
427
430
|
|
|
428
431
|
|
|
429
432
|
|
|
@@ -560,6 +563,54 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
560
563
|
const pipe = (...fns) => (arg) => fns.reduce((prev, fn) => fn(prev), arg);
|
|
561
564
|
|
|
562
565
|
|
|
566
|
+
/***/ },
|
|
567
|
+
|
|
568
|
+
/***/ "./src/array/toggle-array-item.ts"
|
|
569
|
+
/*!****************************************!*\
|
|
570
|
+
!*** ./src/array/toggle-array-item.ts ***!
|
|
571
|
+
\****************************************/
|
|
572
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
573
|
+
|
|
574
|
+
__webpack_require__.r(__webpack_exports__);
|
|
575
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
576
|
+
/* harmony export */ toggleArrayItem: () => (/* binding */ toggleArrayItem)
|
|
577
|
+
/* harmony export */ });
|
|
578
|
+
/* harmony import */ var _difference__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./difference */ "./src/array/difference.ts");
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* Adds an item to an array or removes it from the array, without changing the source array.
|
|
582
|
+
*
|
|
583
|
+
* With `isIncluded` given, the item ends up in the array or out of it as asked - what a checkbox
|
|
584
|
+
* in a list of them reports. Without it, the item's presence is flipped.
|
|
585
|
+
*
|
|
586
|
+
* The source array itself is returned when it already is as asked, and an item already present is
|
|
587
|
+
* never added a second time. Items are matched as `includes()` matches them.
|
|
588
|
+
*
|
|
589
|
+
* @template T - The type of the items in the array.
|
|
590
|
+
*
|
|
591
|
+
* @param array - The source array.
|
|
592
|
+
* @param item - The item to add or remove.
|
|
593
|
+
* @param isIncluded - Whether the item should be in the array. Flips its presence when omitted.
|
|
594
|
+
*
|
|
595
|
+
* @returns The array with the item in it or out of it.
|
|
596
|
+
*
|
|
597
|
+
* @example
|
|
598
|
+
* ```ts
|
|
599
|
+
* toggleArrayItem(['a', 'b'], 'c', true); // ['a', 'b', 'c']
|
|
600
|
+
* toggleArrayItem(['a', 'b'], 'b', false); // ['a']
|
|
601
|
+
* toggleArrayItem(['a', 'b'], 'a'); // ['b']
|
|
602
|
+
* toggleArrayItem(['a', 'b'], 'c'); // ['a', 'b', 'c']
|
|
603
|
+
* ```
|
|
604
|
+
*/
|
|
605
|
+
const toggleArrayItem = (array, item, isIncluded) => {
|
|
606
|
+
const isPresent = array.includes(item);
|
|
607
|
+
if (isPresent === (isIncluded ?? !isPresent)) {
|
|
608
|
+
return array;
|
|
609
|
+
}
|
|
610
|
+
return isPresent ? (0,_difference__WEBPACK_IMPORTED_MODULE_0__.difference)(array, [item]) : [...array, item];
|
|
611
|
+
};
|
|
612
|
+
|
|
613
|
+
|
|
563
614
|
/***/ },
|
|
564
615
|
|
|
565
616
|
/***/ "./src/array/unique.ts"
|
|
@@ -1271,6 +1322,47 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1271
1322
|
|
|
1272
1323
|
|
|
1273
1324
|
|
|
1325
|
+
/***/ },
|
|
1326
|
+
|
|
1327
|
+
/***/ "./src/dom/history.ts"
|
|
1328
|
+
/*!****************************!*\
|
|
1329
|
+
!*** ./src/dom/history.ts ***!
|
|
1330
|
+
\****************************/
|
|
1331
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
1332
|
+
|
|
1333
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1334
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1335
|
+
/* harmony export */ replaceHistorySearchParams: () => (/* binding */ replaceHistorySearchParams)
|
|
1336
|
+
/* harmony export */ });
|
|
1337
|
+
/**
|
|
1338
|
+
* Replaces the query string of the current URL without navigating or adding a history entry.
|
|
1339
|
+
*
|
|
1340
|
+
* The path and the hash are kept, and so is the history entry's state, which routers such as
|
|
1341
|
+
* React Router keep their own bookkeeping in. Empty search params remove the query string
|
|
1342
|
+
* altogether rather than leaving a bare `?`.
|
|
1343
|
+
*
|
|
1344
|
+
* `history.replaceState()` fires no event, so a router listening for navigation is not told: its
|
|
1345
|
+
* own location keeps the previous query until it next navigates.
|
|
1346
|
+
*
|
|
1347
|
+
* @param searchParams - The search params the URL should carry.
|
|
1348
|
+
*
|
|
1349
|
+
* @example
|
|
1350
|
+
* ```ts
|
|
1351
|
+
* // https://example.com/products?page=1#reviews
|
|
1352
|
+
* const searchParams = new URLSearchParams(window.location.search);
|
|
1353
|
+
*
|
|
1354
|
+
* searchParams.set('page', '2');
|
|
1355
|
+
*
|
|
1356
|
+
* replaceHistorySearchParams(searchParams);
|
|
1357
|
+
* // ➜ https://example.com/products?page=2#reviews
|
|
1358
|
+
* ```
|
|
1359
|
+
*/
|
|
1360
|
+
const replaceHistorySearchParams = (searchParams) => {
|
|
1361
|
+
const search = searchParams.toString();
|
|
1362
|
+
window.history.replaceState(window.history.state, '', `${window.location.pathname}${search ? `?${search}` : ''}${window.location.hash}`);
|
|
1363
|
+
};
|
|
1364
|
+
|
|
1365
|
+
|
|
1274
1366
|
/***/ },
|
|
1275
1367
|
|
|
1276
1368
|
/***/ "./src/dom/index.ts"
|
|
@@ -1282,25 +1374,28 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1282
1374
|
__webpack_require__.r(__webpack_exports__);
|
|
1283
1375
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1284
1376
|
/* harmony export */ DATA_TRANSFER_JSON_MIME: () => (/* reexport safe */ _data_transfer__WEBPACK_IMPORTED_MODULE_0__.DATA_TRANSFER_JSON_MIME),
|
|
1285
|
-
/* harmony export */ centerElementInContainer: () => (/* reexport safe */
|
|
1377
|
+
/* harmony export */ centerElementInContainer: () => (/* reexport safe */ _layout__WEBPACK_IMPORTED_MODULE_4__.centerElementInContainer),
|
|
1286
1378
|
/* harmony export */ cloneBlob: () => (/* reexport safe */ _dom__WEBPACK_IMPORTED_MODULE_1__.cloneBlob),
|
|
1287
1379
|
/* harmony export */ downloadFile: () => (/* reexport safe */ _file__WEBPACK_IMPORTED_MODULE_2__.downloadFile),
|
|
1288
1380
|
/* harmony export */ getDataTransferJson: () => (/* reexport safe */ _data_transfer__WEBPACK_IMPORTED_MODULE_0__.getDataTransferJson),
|
|
1289
1381
|
/* harmony export */ getElementOffsetRect: () => (/* reexport safe */ _dom__WEBPACK_IMPORTED_MODULE_1__.getElementOffsetRect),
|
|
1290
|
-
/* harmony export */ getXOverflowWidth: () => (/* reexport safe */
|
|
1291
|
-
/* harmony export */ getYOverflowHeight: () => (/* reexport safe */
|
|
1292
|
-
/* harmony export */ hasXOverflow: () => (/* reexport safe */
|
|
1293
|
-
/* harmony export */ hasYOverflow: () => (/* reexport safe */
|
|
1382
|
+
/* harmony export */ getXOverflowWidth: () => (/* reexport safe */ _layout__WEBPACK_IMPORTED_MODULE_4__.getXOverflowWidth),
|
|
1383
|
+
/* harmony export */ getYOverflowHeight: () => (/* reexport safe */ _layout__WEBPACK_IMPORTED_MODULE_4__.getYOverflowHeight),
|
|
1384
|
+
/* harmony export */ hasXOverflow: () => (/* reexport safe */ _layout__WEBPACK_IMPORTED_MODULE_4__.hasXOverflow),
|
|
1385
|
+
/* harmony export */ hasYOverflow: () => (/* reexport safe */ _layout__WEBPACK_IMPORTED_MODULE_4__.hasYOverflow),
|
|
1294
1386
|
/* harmony export */ isAnchorHtmlElement: () => (/* reexport safe */ _dom__WEBPACK_IMPORTED_MODULE_1__.isAnchorHtmlElement),
|
|
1295
1387
|
/* harmony export */ isContentEditableHtmlElement: () => (/* reexport safe */ _dom__WEBPACK_IMPORTED_MODULE_1__.isContentEditableHtmlElement),
|
|
1296
|
-
/* harmony export */ parse2DMatrix: () => (/* reexport safe */
|
|
1388
|
+
/* harmony export */ parse2DMatrix: () => (/* reexport safe */ _transform__WEBPACK_IMPORTED_MODULE_5__.parse2DMatrix),
|
|
1389
|
+
/* harmony export */ replaceHistorySearchParams: () => (/* reexport safe */ _history__WEBPACK_IMPORTED_MODULE_3__.replaceHistorySearchParams),
|
|
1297
1390
|
/* harmony export */ setDataTransferJson: () => (/* reexport safe */ _data_transfer__WEBPACK_IMPORTED_MODULE_0__.setDataTransferJson)
|
|
1298
1391
|
/* harmony export */ });
|
|
1299
1392
|
/* harmony import */ var _data_transfer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./data-transfer */ "./src/dom/data-transfer.ts");
|
|
1300
1393
|
/* harmony import */ var _dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./dom */ "./src/dom/dom.ts");
|
|
1301
1394
|
/* harmony import */ var _file__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./file */ "./src/dom/file/index.ts");
|
|
1302
|
-
/* harmony import */ var
|
|
1303
|
-
/* harmony import */ var
|
|
1395
|
+
/* harmony import */ var _history__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./history */ "./src/dom/history.ts");
|
|
1396
|
+
/* harmony import */ var _layout__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./layout */ "./src/dom/layout/index.ts");
|
|
1397
|
+
/* harmony import */ var _transform__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./transform */ "./src/dom/transform/index.ts");
|
|
1398
|
+
|
|
1304
1399
|
|
|
1305
1400
|
|
|
1306
1401
|
|
|
@@ -1555,18 +1650,26 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1555
1650
|
/* harmony export */ decodeBase64: () => (/* binding */ decodeBase64)
|
|
1556
1651
|
/* harmony export */ });
|
|
1557
1652
|
const BASE64_PATTERN = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
|
|
1653
|
+
const decodeBase64Bytes = (value) => {
|
|
1654
|
+
if (typeof Uint8Array.fromBase64 === 'function') {
|
|
1655
|
+
return Uint8Array.fromBase64(value);
|
|
1656
|
+
}
|
|
1657
|
+
if (typeof Buffer !== 'undefined') {
|
|
1658
|
+
return Buffer.from(value, 'base64');
|
|
1659
|
+
}
|
|
1660
|
+
const binary = atob(value);
|
|
1661
|
+
const bytes = new Uint8Array(binary.length);
|
|
1662
|
+
for (let i = 0; i < binary.length; i++) {
|
|
1663
|
+
bytes[i] = binary.charCodeAt(i);
|
|
1664
|
+
}
|
|
1665
|
+
return bytes;
|
|
1666
|
+
};
|
|
1558
1667
|
const decodeBase64 = (value) => {
|
|
1668
|
+
if (!BASE64_PATTERN.test(value)) {
|
|
1669
|
+
return null;
|
|
1670
|
+
}
|
|
1559
1671
|
try {
|
|
1560
|
-
|
|
1561
|
-
return null;
|
|
1562
|
-
}
|
|
1563
|
-
if (typeof Buffer !== 'undefined') {
|
|
1564
|
-
return Buffer.from(value, 'base64').toString('utf-8');
|
|
1565
|
-
}
|
|
1566
|
-
return decodeURIComponent(atob(value)
|
|
1567
|
-
.split('')
|
|
1568
|
-
.map(char => `%${char.charCodeAt(0).toString(16).padStart(2, '0')}`)
|
|
1569
|
-
.join(''));
|
|
1672
|
+
return new TextDecoder('utf-8', { fatal: true, ignoreBOM: true }).decode(decodeBase64Bytes(value));
|
|
1570
1673
|
}
|
|
1571
1674
|
catch {
|
|
1572
1675
|
return null;
|
|
@@ -1574,6 +1677,51 @@ const decodeBase64 = (value) => {
|
|
|
1574
1677
|
};
|
|
1575
1678
|
|
|
1576
1679
|
|
|
1680
|
+
/***/ },
|
|
1681
|
+
|
|
1682
|
+
/***/ "./src/encoding/encode-base64-json.ts"
|
|
1683
|
+
/*!********************************************!*\
|
|
1684
|
+
!*** ./src/encoding/encode-base64-json.ts ***!
|
|
1685
|
+
\********************************************/
|
|
1686
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
1687
|
+
|
|
1688
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1689
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1690
|
+
/* harmony export */ encodeBase64Json: () => (/* binding */ encodeBase64Json)
|
|
1691
|
+
/* harmony export */ });
|
|
1692
|
+
/* harmony import */ var _encode_base64__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./encode-base64 */ "./src/encoding/encode-base64.ts");
|
|
1693
|
+
|
|
1694
|
+
const encodeBase64Json = (value) => (0,_encode_base64__WEBPACK_IMPORTED_MODULE_0__.encodeBase64)(JSON.stringify(value));
|
|
1695
|
+
|
|
1696
|
+
|
|
1697
|
+
/***/ },
|
|
1698
|
+
|
|
1699
|
+
/***/ "./src/encoding/encode-base64.ts"
|
|
1700
|
+
/*!***************************************!*\
|
|
1701
|
+
!*** ./src/encoding/encode-base64.ts ***!
|
|
1702
|
+
\***************************************/
|
|
1703
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
1704
|
+
|
|
1705
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1706
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1707
|
+
/* harmony export */ encodeBase64: () => (/* binding */ encodeBase64)
|
|
1708
|
+
/* harmony export */ });
|
|
1709
|
+
const encodeBase64Bytes = (bytes) => {
|
|
1710
|
+
if (typeof bytes.toBase64 === 'function') {
|
|
1711
|
+
return bytes.toBase64();
|
|
1712
|
+
}
|
|
1713
|
+
if (typeof Buffer !== 'undefined') {
|
|
1714
|
+
return Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString('base64');
|
|
1715
|
+
}
|
|
1716
|
+
let binary = '';
|
|
1717
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
1718
|
+
binary += String.fromCharCode(bytes[i]);
|
|
1719
|
+
}
|
|
1720
|
+
return btoa(binary);
|
|
1721
|
+
};
|
|
1722
|
+
const encodeBase64 = (value) => encodeBase64Bytes(new TextEncoder().encode(value));
|
|
1723
|
+
|
|
1724
|
+
|
|
1577
1725
|
/***/ },
|
|
1578
1726
|
|
|
1579
1727
|
/***/ "./src/encoding/index.ts"
|
|
@@ -1585,10 +1733,16 @@ const decodeBase64 = (value) => {
|
|
|
1585
1733
|
__webpack_require__.r(__webpack_exports__);
|
|
1586
1734
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1587
1735
|
/* harmony export */ decodeBase64: () => (/* reexport safe */ _decode_base64__WEBPACK_IMPORTED_MODULE_0__.decodeBase64),
|
|
1588
|
-
/* harmony export */ decodeBase64Json: () => (/* reexport safe */ _decode_base64_json__WEBPACK_IMPORTED_MODULE_1__.decodeBase64Json)
|
|
1736
|
+
/* harmony export */ decodeBase64Json: () => (/* reexport safe */ _decode_base64_json__WEBPACK_IMPORTED_MODULE_1__.decodeBase64Json),
|
|
1737
|
+
/* harmony export */ encodeBase64: () => (/* reexport safe */ _encode_base64__WEBPACK_IMPORTED_MODULE_2__.encodeBase64),
|
|
1738
|
+
/* harmony export */ encodeBase64Json: () => (/* reexport safe */ _encode_base64_json__WEBPACK_IMPORTED_MODULE_3__.encodeBase64Json)
|
|
1589
1739
|
/* harmony export */ });
|
|
1590
1740
|
/* harmony import */ var _decode_base64__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./decode-base64 */ "./src/encoding/decode-base64.ts");
|
|
1591
1741
|
/* harmony import */ var _decode_base64_json__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./decode-base64-json */ "./src/encoding/decode-base64-json.ts");
|
|
1742
|
+
/* harmony import */ var _encode_base64__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./encode-base64 */ "./src/encoding/encode-base64.ts");
|
|
1743
|
+
/* harmony import */ var _encode_base64_json__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./encode-base64-json */ "./src/encoding/encode-base64-json.ts");
|
|
1744
|
+
|
|
1745
|
+
|
|
1592
1746
|
|
|
1593
1747
|
|
|
1594
1748
|
|
|
@@ -2286,6 +2440,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2286
2440
|
/* harmony export */ isDecimal: () => (/* binding */ isDecimal),
|
|
2287
2441
|
/* harmony export */ isDefined: () => (/* binding */ isDefined),
|
|
2288
2442
|
/* harmony export */ isEmptyObject: () => (/* binding */ isEmptyObject),
|
|
2443
|
+
/* harmony export */ isEnumValue: () => (/* binding */ isEnumValue),
|
|
2289
2444
|
/* harmony export */ isError: () => (/* binding */ isError),
|
|
2290
2445
|
/* harmony export */ isFiniteNumber: () => (/* binding */ isFiniteNumber),
|
|
2291
2446
|
/* harmony export */ isInteger: () => (/* binding */ isInteger),
|
|
@@ -2509,6 +2664,29 @@ const isInteger = (value) => isNumber(value) && Number.isInteger(value);
|
|
|
2509
2664
|
* ```
|
|
2510
2665
|
*/
|
|
2511
2666
|
const isDecimal = (value) => isFiniteNumber(value) && !Number.isInteger(value);
|
|
2667
|
+
/**
|
|
2668
|
+
* Checks if a value is one of a string enum's values.
|
|
2669
|
+
*
|
|
2670
|
+
* @template Value - The type of the enum's values.
|
|
2671
|
+
*
|
|
2672
|
+
* @param enumObject - The enum, or any object whose values are the allowed strings.
|
|
2673
|
+
* @param value - The value to check.
|
|
2674
|
+
*
|
|
2675
|
+
* @returns `true` if the value is one of the enum's values; otherwise, `false`.
|
|
2676
|
+
*
|
|
2677
|
+
* @example
|
|
2678
|
+
* ```ts
|
|
2679
|
+
* enum Fruit {
|
|
2680
|
+
* APPLE = 'apple',
|
|
2681
|
+
* PEAR = 'pear',
|
|
2682
|
+
* }
|
|
2683
|
+
*
|
|
2684
|
+
* isEnumValue(Fruit, 'apple'); // true
|
|
2685
|
+
* isEnumValue(Fruit, 'APPLE'); // false
|
|
2686
|
+
* isEnumValue(Fruit, null); // false
|
|
2687
|
+
* ```
|
|
2688
|
+
*/
|
|
2689
|
+
const isEnumValue = (enumObject, value) => Object.values(enumObject).includes(value);
|
|
2512
2690
|
|
|
2513
2691
|
|
|
2514
2692
|
/***/ },
|
|
@@ -2715,6 +2893,38 @@ const parseJson = (value) => {
|
|
|
2715
2893
|
};
|
|
2716
2894
|
|
|
2717
2895
|
|
|
2896
|
+
/***/ },
|
|
2897
|
+
|
|
2898
|
+
/***/ "./src/math/clamp.ts"
|
|
2899
|
+
/*!***************************!*\
|
|
2900
|
+
!*** ./src/math/clamp.ts ***!
|
|
2901
|
+
\***************************/
|
|
2902
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
2903
|
+
|
|
2904
|
+
__webpack_require__.r(__webpack_exports__);
|
|
2905
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2906
|
+
/* harmony export */ clamp: () => (/* binding */ clamp)
|
|
2907
|
+
/* harmony export */ });
|
|
2908
|
+
/**
|
|
2909
|
+
* Restricts a number to the inclusive range between `min` and `max`.
|
|
2910
|
+
*
|
|
2911
|
+
* @param value - The number to restrict.
|
|
2912
|
+
* @param min - The lower bound.
|
|
2913
|
+
* @param max - The upper bound. Wins over `min` when the two cross.
|
|
2914
|
+
*
|
|
2915
|
+
* @returns `min` when the value is below it, `max` when the value is above it, and the value
|
|
2916
|
+
* itself otherwise.
|
|
2917
|
+
*
|
|
2918
|
+
* @example
|
|
2919
|
+
* ```ts
|
|
2920
|
+
* clamp(5, 0, 10); // 5
|
|
2921
|
+
* clamp(-3, 0, 10); // 0
|
|
2922
|
+
* clamp(42, 0, 10); // 10
|
|
2923
|
+
* ```
|
|
2924
|
+
*/
|
|
2925
|
+
const clamp = (value, min, max) => Math.min(Math.max(value, min), max);
|
|
2926
|
+
|
|
2927
|
+
|
|
2718
2928
|
/***/ },
|
|
2719
2929
|
|
|
2720
2930
|
/***/ "./src/math/hash-string.ts"
|
|
@@ -2773,10 +2983,13 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2773
2983
|
/* harmony export */ calculateEuclideanDistance: () => (/* reexport safe */ _math__WEBPACK_IMPORTED_MODULE_0__.calculateEuclideanDistance),
|
|
2774
2984
|
/* harmony export */ calculateMovingSpeed: () => (/* reexport safe */ _math__WEBPACK_IMPORTED_MODULE_0__.calculateMovingSpeed),
|
|
2775
2985
|
/* harmony export */ calculatePercentage: () => (/* reexport safe */ _math__WEBPACK_IMPORTED_MODULE_0__.calculatePercentage),
|
|
2986
|
+
/* harmony export */ clamp: () => (/* reexport safe */ _clamp__WEBPACK_IMPORTED_MODULE_2__.clamp),
|
|
2776
2987
|
/* harmony export */ hashString: () => (/* reexport safe */ _hash_string__WEBPACK_IMPORTED_MODULE_1__.hashString)
|
|
2777
2988
|
/* harmony export */ });
|
|
2778
2989
|
/* harmony import */ var _math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./math */ "./src/math/math.ts");
|
|
2779
2990
|
/* harmony import */ var _hash_string__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hash-string */ "./src/math/hash-string.ts");
|
|
2991
|
+
/* harmony import */ var _clamp__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./clamp */ "./src/math/clamp.ts");
|
|
2992
|
+
|
|
2780
2993
|
|
|
2781
2994
|
|
|
2782
2995
|
|
|
@@ -3619,17 +3832,17 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
3619
3832
|
/******/ });
|
|
3620
3833
|
/************************************************************************/
|
|
3621
3834
|
/******/ // The module cache
|
|
3622
|
-
/******/
|
|
3835
|
+
/******/ const __webpack_module_cache__ = {};
|
|
3623
3836
|
/******/
|
|
3624
3837
|
/******/ // The require function
|
|
3625
3838
|
/******/ function __webpack_require__(moduleId) {
|
|
3626
3839
|
/******/ // Check if module is in cache
|
|
3627
|
-
/******/
|
|
3840
|
+
/******/ const cachedModule = __webpack_module_cache__[moduleId];
|
|
3628
3841
|
/******/ if (cachedModule !== undefined) {
|
|
3629
3842
|
/******/ return cachedModule.exports;
|
|
3630
3843
|
/******/ }
|
|
3631
3844
|
/******/ // Create a new module (and put it into the cache)
|
|
3632
|
-
/******/
|
|
3845
|
+
/******/ const module = __webpack_module_cache__[moduleId] = {
|
|
3633
3846
|
/******/ // no module.id needed
|
|
3634
3847
|
/******/ // no module.loaded needed
|
|
3635
3848
|
/******/ exports: {}
|
|
@@ -3638,7 +3851,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
3638
3851
|
/******/ // Execute the module function
|
|
3639
3852
|
/******/ if (!(moduleId in __webpack_modules__)) {
|
|
3640
3853
|
/******/ delete __webpack_module_cache__[moduleId];
|
|
3641
|
-
/******/
|
|
3854
|
+
/******/ const e = new Error("Cannot find module '" + moduleId + "'");
|
|
3642
3855
|
/******/ e.code = 'MODULE_NOT_FOUND';
|
|
3643
3856
|
/******/ throw e;
|
|
3644
3857
|
/******/ }
|
|
@@ -3650,35 +3863,27 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
3650
3863
|
/******/
|
|
3651
3864
|
/************************************************************************/
|
|
3652
3865
|
/******/ /* webpack/runtime/define property getters */
|
|
3653
|
-
/******/
|
|
3654
|
-
/******/
|
|
3655
|
-
/******/
|
|
3656
|
-
/******/
|
|
3657
|
-
/******/
|
|
3658
|
-
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
3659
|
-
/******/ }
|
|
3866
|
+
/******/ // define getter/value functions for harmony exports
|
|
3867
|
+
/******/ __webpack_require__.d = (exports, definition) => {
|
|
3868
|
+
/******/ for(var key in definition) {
|
|
3869
|
+
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
3870
|
+
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
3660
3871
|
/******/ }
|
|
3661
|
-
/******/ }
|
|
3662
|
-
/******/ }
|
|
3872
|
+
/******/ }
|
|
3873
|
+
/******/ };
|
|
3663
3874
|
/******/
|
|
3664
3875
|
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
3665
|
-
/******/ (
|
|
3666
|
-
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
3667
|
-
/******/ })();
|
|
3876
|
+
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop));
|
|
3668
3877
|
/******/
|
|
3669
3878
|
/******/ /* webpack/runtime/make namespace object */
|
|
3670
|
-
/******/
|
|
3671
|
-
/******/
|
|
3672
|
-
/******/
|
|
3673
|
-
/******/
|
|
3674
|
-
/******/
|
|
3675
|
-
/******/ }
|
|
3676
|
-
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
3677
|
-
/******/ };
|
|
3678
|
-
/******/ })();
|
|
3879
|
+
/******/ // define __esModule on exports
|
|
3880
|
+
/******/ __webpack_require__.r = (exports) => {
|
|
3881
|
+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
3882
|
+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
3883
|
+
/******/ };
|
|
3679
3884
|
/******/
|
|
3680
3885
|
/************************************************************************/
|
|
3681
|
-
|
|
3886
|
+
let __webpack_exports__ = {};
|
|
3682
3887
|
// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
|
|
3683
3888
|
(() => {
|
|
3684
3889
|
/*!**********************!*\
|
|
@@ -3699,6 +3904,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
3699
3904
|
/* harmony export */ camelToWords: () => (/* reexport safe */ _string__WEBPACK_IMPORTED_MODULE_13__.camelToWords),
|
|
3700
3905
|
/* harmony export */ centerElementInContainer: () => (/* reexport safe */ _dom__WEBPACK_IMPORTED_MODULE_3__.centerElementInContainer),
|
|
3701
3906
|
/* harmony export */ chunk: () => (/* reexport safe */ _array__WEBPACK_IMPORTED_MODULE_1__.chunk),
|
|
3907
|
+
/* harmony export */ clamp: () => (/* reexport safe */ _math__WEBPACK_IMPORTED_MODULE_11__.clamp),
|
|
3702
3908
|
/* harmony export */ clampOffsetToOverflow: () => (/* reexport safe */ _geometry__WEBPACK_IMPORTED_MODULE_7__.clampOffsetToOverflow),
|
|
3703
3909
|
/* harmony export */ cloneBlob: () => (/* reexport safe */ _dom__WEBPACK_IMPORTED_MODULE_3__.cloneBlob),
|
|
3704
3910
|
/* harmony export */ compact: () => (/* reexport safe */ _array__WEBPACK_IMPORTED_MODULE_1__.compact),
|
|
@@ -3709,6 +3915,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
3709
3915
|
/* harmony export */ delay: () => (/* reexport safe */ _async__WEBPACK_IMPORTED_MODULE_2__.delay),
|
|
3710
3916
|
/* harmony export */ difference: () => (/* reexport safe */ _array__WEBPACK_IMPORTED_MODULE_1__.difference),
|
|
3711
3917
|
/* harmony export */ downloadFile: () => (/* reexport safe */ _dom__WEBPACK_IMPORTED_MODULE_3__.downloadFile),
|
|
3918
|
+
/* harmony export */ encodeBase64: () => (/* reexport safe */ _encoding__WEBPACK_IMPORTED_MODULE_18__.encodeBase64),
|
|
3919
|
+
/* harmony export */ encodeBase64Json: () => (/* reexport safe */ _encoding__WEBPACK_IMPORTED_MODULE_18__.encodeBase64Json),
|
|
3712
3920
|
/* harmony export */ everyAsync: () => (/* reexport safe */ _async__WEBPACK_IMPORTED_MODULE_2__.everyAsync),
|
|
3713
3921
|
/* harmony export */ fileListToFiles: () => (/* reexport safe */ _file__WEBPACK_IMPORTED_MODULE_5__.fileListToFiles),
|
|
3714
3922
|
/* harmony export */ filterParallel: () => (/* reexport safe */ _async__WEBPACK_IMPORTED_MODULE_2__.filterParallel),
|
|
@@ -3744,6 +3952,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
3744
3952
|
/* harmony export */ isDefined: () => (/* reexport safe */ _guards__WEBPACK_IMPORTED_MODULE_8__.isDefined),
|
|
3745
3953
|
/* harmony export */ isEmptyArray: () => (/* reexport safe */ _array__WEBPACK_IMPORTED_MODULE_1__.isEmptyArray),
|
|
3746
3954
|
/* harmony export */ isEmptyObject: () => (/* reexport safe */ _guards__WEBPACK_IMPORTED_MODULE_8__.isEmptyObject),
|
|
3955
|
+
/* harmony export */ isEnumValue: () => (/* reexport safe */ _guards__WEBPACK_IMPORTED_MODULE_8__.isEnumValue),
|
|
3747
3956
|
/* harmony export */ isError: () => (/* reexport safe */ _guards__WEBPACK_IMPORTED_MODULE_8__.isError),
|
|
3748
3957
|
/* harmony export */ isFile: () => (/* reexport safe */ _file__WEBPACK_IMPORTED_MODULE_5__.isFile),
|
|
3749
3958
|
/* harmony export */ isFiniteNumber: () => (/* reexport safe */ _guards__WEBPACK_IMPORTED_MODULE_8__.isFiniteNumber),
|
|
@@ -3774,6 +3983,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
3774
3983
|
/* harmony export */ pipe: () => (/* reexport safe */ _array__WEBPACK_IMPORTED_MODULE_1__.pipe),
|
|
3775
3984
|
/* harmony export */ readFilesFromDataTransfer: () => (/* reexport safe */ _file__WEBPACK_IMPORTED_MODULE_5__.readFilesFromDataTransfer),
|
|
3776
3985
|
/* harmony export */ reduceAsync: () => (/* reexport safe */ _async__WEBPACK_IMPORTED_MODULE_2__.reduceAsync),
|
|
3986
|
+
/* harmony export */ replaceHistorySearchParams: () => (/* reexport safe */ _dom__WEBPACK_IMPORTED_MODULE_3__.replaceHistorySearchParams),
|
|
3777
3987
|
/* harmony export */ resolveAxisDelta: () => (/* reexport safe */ _intersection__WEBPACK_IMPORTED_MODULE_10__.resolveAxisDelta),
|
|
3778
3988
|
/* harmony export */ resolveBoundedDelta: () => (/* reexport safe */ _geometry__WEBPACK_IMPORTED_MODULE_7__.resolveBoundedDelta),
|
|
3779
3989
|
/* harmony export */ retry: () => (/* reexport safe */ _async__WEBPACK_IMPORTED_MODULE_2__.retry),
|
|
@@ -3786,6 +3996,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
3786
3996
|
/* harmony export */ splitStringIntoWords: () => (/* reexport safe */ _string__WEBPACK_IMPORTED_MODULE_13__.splitStringIntoWords),
|
|
3787
3997
|
/* harmony export */ timeout: () => (/* reexport safe */ _async__WEBPACK_IMPORTED_MODULE_2__.timeout),
|
|
3788
3998
|
/* harmony export */ toKebabCase: () => (/* reexport safe */ _string__WEBPACK_IMPORTED_MODULE_13__.toKebabCase),
|
|
3999
|
+
/* harmony export */ toggleArrayItem: () => (/* reexport safe */ _array__WEBPACK_IMPORTED_MODULE_1__.toggleArrayItem),
|
|
3789
4000
|
/* harmony export */ traverseFileSystemDirectory: () => (/* reexport safe */ _file__WEBPACK_IMPORTED_MODULE_5__.traverseFileSystemDirectory),
|
|
3790
4001
|
/* harmony export */ unique: () => (/* reexport safe */ _array__WEBPACK_IMPORTED_MODULE_1__.unique)
|
|
3791
4002
|
/* harmony export */ });
|