@react-hive/honey-utils 3.15.0 → 3.16.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.
@@ -2451,6 +2451,89 @@ __webpack_require__.r(__webpack_exports__);
2451
2451
  const camelToWords = (input) => input.replace(/([a-z0-9])([A-Z])/g, '$1 $2');
2452
2452
 
2453
2453
 
2454
+ /***/ }),
2455
+
2456
+ /***/ "./src/string/find-char-indices.ts":
2457
+ /*!*****************************************!*\
2458
+ !*** ./src/string/find-char-indices.ts ***!
2459
+ \*****************************************/
2460
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2461
+
2462
+ __webpack_require__.r(__webpack_exports__);
2463
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2464
+ /* harmony export */ findCharIndices: () => (/* binding */ findCharIndices)
2465
+ /* harmony export */ });
2466
+ /**
2467
+ * Finds all zero-based indices where a given single character occurs in a string.
2468
+ *
2469
+ * The string is scanned once from start to end and each matching character position is collected.
2470
+ *
2471
+ * ⚠️ Character comparison is performed at the UTF-16 code unit level
2472
+ * (`String.charCodeAt`), not by Unicode grapheme clusters.
2473
+ *
2474
+ * @param inputString - The string to scan.
2475
+ * @param targetChar - A single character to search for.
2476
+ *
2477
+ * @returns An array of zero-based indices for each occurrence of `targetChar`.
2478
+ * Returns an empty array if no matches are found.
2479
+ */
2480
+ const findCharIndices = (inputString, targetChar) => {
2481
+ if (inputString.length === 0) {
2482
+ return [];
2483
+ }
2484
+ const targetCode = targetChar.charCodeAt(0);
2485
+ const indices = [];
2486
+ for (let i = 0; i < inputString.length; i++) {
2487
+ if (inputString.charCodeAt(i) === targetCode) {
2488
+ indices.push(i);
2489
+ }
2490
+ }
2491
+ return indices;
2492
+ };
2493
+
2494
+
2495
+ /***/ }),
2496
+
2497
+ /***/ "./src/string/for-each-char.ts":
2498
+ /*!*************************************!*\
2499
+ !*** ./src/string/for-each-char.ts ***!
2500
+ \*************************************/
2501
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2502
+
2503
+ __webpack_require__.r(__webpack_exports__);
2504
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2505
+ /* harmony export */ forEachChar: () => (/* binding */ forEachChar)
2506
+ /* harmony export */ });
2507
+ /**
2508
+ * Iterates over each character of a string and invokes a callback for each one.
2509
+ *
2510
+ * Iteration is performed over UTF-16 code units (not Unicode grapheme clusters).
2511
+ * Characters may be conditionally skipped using an optional predicate.
2512
+ *
2513
+ * @param input - The string to iterate over.
2514
+ * @param onChar - Invoked for each character that is not skipped.
2515
+ * @param shouldSkipChar - Optional predicate; returning `true` skips the character.
2516
+ */
2517
+ const forEachChar = (input, onChar, shouldSkipChar) => {
2518
+ if (input.length === 0) {
2519
+ return;
2520
+ }
2521
+ const length = input.length;
2522
+ for (let charIndex = 0; charIndex < length; charIndex++) {
2523
+ const char = input[charIndex];
2524
+ const context = {
2525
+ charIndex,
2526
+ prevChar: charIndex > 0 ? input[charIndex - 1] : null,
2527
+ nextChar: charIndex < length - 1 ? input[charIndex + 1] : null,
2528
+ };
2529
+ if (shouldSkipChar?.(char, context)) {
2530
+ continue;
2531
+ }
2532
+ onChar(char, context);
2533
+ }
2534
+ };
2535
+
2536
+
2454
2537
  /***/ }),
2455
2538
 
2456
2539
  /***/ "./src/string/index.ts":
@@ -2463,6 +2546,8 @@ __webpack_require__.r(__webpack_exports__);
2463
2546
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2464
2547
  /* harmony export */ camelToDashCase: () => (/* reexport safe */ _camel_to_dash_case__WEBPACK_IMPORTED_MODULE_2__.camelToDashCase),
2465
2548
  /* harmony export */ camelToWords: () => (/* reexport safe */ _camel_to_words__WEBPACK_IMPORTED_MODULE_3__.camelToWords),
2549
+ /* harmony export */ findCharIndices: () => (/* reexport safe */ _find_char_indices__WEBPACK_IMPORTED_MODULE_7__.findCharIndices),
2550
+ /* harmony export */ forEachChar: () => (/* reexport safe */ _for_each_char__WEBPACK_IMPORTED_MODULE_8__.forEachChar),
2466
2551
  /* harmony export */ isNilOrEmptyString: () => (/* reexport safe */ _is_nil_or_empty_string__WEBPACK_IMPORTED_MODULE_5__.isNilOrEmptyString),
2467
2552
  /* harmony export */ isString: () => (/* reexport safe */ _is_string__WEBPACK_IMPORTED_MODULE_0__.isString),
2468
2553
  /* harmony export */ parseFileName: () => (/* reexport safe */ _parse_file_name__WEBPACK_IMPORTED_MODULE_6__.parseFileName),
@@ -2476,6 +2561,10 @@ __webpack_require__.r(__webpack_exports__);
2476
2561
  /* harmony import */ var _split_string_into_words__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./split-string-into-words */ "./src/string/split-string-into-words.ts");
2477
2562
  /* harmony import */ var _is_nil_or_empty_string__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./is-nil-or-empty-string */ "./src/string/is-nil-or-empty-string.ts");
2478
2563
  /* harmony import */ var _parse_file_name__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./parse-file-name */ "./src/string/parse-file-name.ts");
2564
+ /* harmony import */ var _find_char_indices__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./find-char-indices */ "./src/string/find-char-indices.ts");
2565
+ /* harmony import */ var _for_each_char__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./for-each-char */ "./src/string/for-each-char.ts");
2566
+
2567
+
2479
2568
 
2480
2569
 
2481
2570
 
@@ -2717,6 +2806,8 @@ __webpack_require__.r(__webpack_exports__);
2717
2806
  /* harmony export */ filterParallel: () => (/* reexport safe */ _async__WEBPACK_IMPORTED_MODULE_0__.filterParallel),
2718
2807
  /* harmony export */ filterSequential: () => (/* reexport safe */ _async__WEBPACK_IMPORTED_MODULE_0__.filterSequential),
2719
2808
  /* harmony export */ findAsync: () => (/* reexport safe */ _async__WEBPACK_IMPORTED_MODULE_0__.findAsync),
2809
+ /* harmony export */ findCharIndices: () => (/* reexport safe */ _string__WEBPACK_IMPORTED_MODULE_1__.findCharIndices),
2810
+ /* harmony export */ forEachChar: () => (/* reexport safe */ _string__WEBPACK_IMPORTED_MODULE_1__.forEachChar),
2720
2811
  /* harmony export */ getDOMRectIntersectionRatio: () => (/* reexport safe */ _intersection__WEBPACK_IMPORTED_MODULE_10__.getDOMRectIntersectionRatio),
2721
2812
  /* harmony export */ getElementOffsetRect: () => (/* reexport safe */ _dom__WEBPACK_IMPORTED_MODULE_6__.getElementOffsetRect),
2722
2813
  /* harmony export */ getFocusableHtmlElements: () => (/* reexport safe */ _a11y__WEBPACK_IMPORTED_MODULE_11__.getFocusableHtmlElements),