@eslint-react/shared 5.17.0 → 5.17.1

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.
Files changed (2) hide show
  1. package/dist/index.js +52 -0
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -429,6 +429,58 @@ function getOrInsertComputed(map, key, callback) {
429
429
  map.set(key, value);
430
430
  return value;
431
431
  }
432
+ /**
433
+ * Drops the longest prefix of elements from an array that satisfy the given predicate.
434
+ *
435
+ * Supports both data-first and data-last (`pipe`-friendly) call styles.
436
+ *
437
+ * @param pred - The predicate to test each element with.
438
+ * @returns A new array without the matching prefix.
439
+ * @example
440
+ * ```ts
441
+ * import * as assert from "node:assert"
442
+ * import { dropWhile, pipe } from "@local/eff"
443
+ *
444
+ * // data-first
445
+ * assert.deepStrictEqual(dropWhile([1, 2, 3, 2, 1], (n: number) => n < 3), [3, 2, 1])
446
+ *
447
+ * // data-last
448
+ * assert.deepStrictEqual(pipe([1, 2, 3, 2, 1], dropWhile((n: number) => n < 3)), [3, 2, 1])
449
+ * ```
450
+ * @category array
451
+ */
452
+ const dropWhile = dual(2, (xs, pred) => {
453
+ const len = xs.length;
454
+ let idx = 0;
455
+ while (idx < len && pred(xs[idx])) idx++;
456
+ return xs.slice(idx);
457
+ });
458
+ /**
459
+ * Takes the longest prefix of elements from an array that satisfy the given predicate.
460
+ *
461
+ * Supports both data-first and data-last (`pipe`-friendly) call styles.
462
+ *
463
+ * @param pred - The predicate to test each element with.
464
+ * @returns A new array containing only the matching prefix.
465
+ * @example
466
+ * ```ts
467
+ * import * as assert from "node:assert"
468
+ * import { pipe, takeWhile } from "@local/eff"
469
+ *
470
+ * // data-first
471
+ * assert.deepStrictEqual(takeWhile([1, 2, 3, 2, 1], (n: number) => n < 3), [1, 2])
472
+ *
473
+ * // data-last
474
+ * assert.deepStrictEqual(pipe([1, 2, 3, 2, 1], takeWhile((n: number) => n < 3)), [1, 2])
475
+ * ```
476
+ * @category array
477
+ */
478
+ const takeWhile = dual(2, (xs, pred) => {
479
+ const len = xs.length;
480
+ let idx = 0;
481
+ while (idx < len && pred(xs[idx])) idx++;
482
+ return xs.slice(0, idx);
483
+ });
432
484
 
433
485
  //#endregion
434
486
  //#region src/regexp.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/shared",
3
- "version": "5.17.0",
3
+ "version": "5.17.1",
4
4
  "description": "ESLint React's Shared constants and functions.",
5
5
  "homepage": "https://github.com/Rel1cx/eslint-react",
6
6
  "bugs": {
@@ -32,14 +32,14 @@
32
32
  "@typescript-eslint/utils": "^8.64.0",
33
33
  "ts-pattern": "^5.9.0",
34
34
  "zod": "^3.25.0 || ^4.0.0",
35
- "@eslint-react/eslint": "5.17.0"
35
+ "@eslint-react/eslint": "5.17.1"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@tsconfig/node24": "^24.0.4",
39
39
  "@types/node": "^26.1.1",
40
40
  "@types/picomatch": "^4.0.3",
41
41
  "eslint": "^10.7.0",
42
- "tsdown": "^0.22.7",
42
+ "tsdown": "^0.22.8",
43
43
  "typescript": "6.0.3",
44
44
  "@local/configs": "0.0.0",
45
45
  "@local/eff": "0.0.0"