@eslint-react/ast 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.
- package/dist/index.js +52 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -539,6 +539,58 @@ const absurd = (_) => {
|
|
|
539
539
|
* @since 2.0.0
|
|
540
540
|
*/
|
|
541
541
|
const hole = cast(absurd);
|
|
542
|
+
/**
|
|
543
|
+
* Drops the longest prefix of elements from an array that satisfy the given predicate.
|
|
544
|
+
*
|
|
545
|
+
* Supports both data-first and data-last (`pipe`-friendly) call styles.
|
|
546
|
+
*
|
|
547
|
+
* @param pred - The predicate to test each element with.
|
|
548
|
+
* @returns A new array without the matching prefix.
|
|
549
|
+
* @example
|
|
550
|
+
* ```ts
|
|
551
|
+
* import * as assert from "node:assert"
|
|
552
|
+
* import { dropWhile, pipe } from "@local/eff"
|
|
553
|
+
*
|
|
554
|
+
* // data-first
|
|
555
|
+
* assert.deepStrictEqual(dropWhile([1, 2, 3, 2, 1], (n: number) => n < 3), [3, 2, 1])
|
|
556
|
+
*
|
|
557
|
+
* // data-last
|
|
558
|
+
* assert.deepStrictEqual(pipe([1, 2, 3, 2, 1], dropWhile((n: number) => n < 3)), [3, 2, 1])
|
|
559
|
+
* ```
|
|
560
|
+
* @category array
|
|
561
|
+
*/
|
|
562
|
+
const dropWhile = dual(2, (xs, pred) => {
|
|
563
|
+
const len = xs.length;
|
|
564
|
+
let idx = 0;
|
|
565
|
+
while (idx < len && pred(xs[idx])) idx++;
|
|
566
|
+
return xs.slice(idx);
|
|
567
|
+
});
|
|
568
|
+
/**
|
|
569
|
+
* Takes the longest prefix of elements from an array that satisfy the given predicate.
|
|
570
|
+
*
|
|
571
|
+
* Supports both data-first and data-last (`pipe`-friendly) call styles.
|
|
572
|
+
*
|
|
573
|
+
* @param pred - The predicate to test each element with.
|
|
574
|
+
* @returns A new array containing only the matching prefix.
|
|
575
|
+
* @example
|
|
576
|
+
* ```ts
|
|
577
|
+
* import * as assert from "node:assert"
|
|
578
|
+
* import { pipe, takeWhile } from "@local/eff"
|
|
579
|
+
*
|
|
580
|
+
* // data-first
|
|
581
|
+
* assert.deepStrictEqual(takeWhile([1, 2, 3, 2, 1], (n: number) => n < 3), [1, 2])
|
|
582
|
+
*
|
|
583
|
+
* // data-last
|
|
584
|
+
* assert.deepStrictEqual(pipe([1, 2, 3, 2, 1], takeWhile((n: number) => n < 3)), [1, 2])
|
|
585
|
+
* ```
|
|
586
|
+
* @category array
|
|
587
|
+
*/
|
|
588
|
+
const takeWhile = dual(2, (xs, pred) => {
|
|
589
|
+
const len = xs.length;
|
|
590
|
+
let idx = 0;
|
|
591
|
+
while (idx < len && pred(xs[idx])) idx++;
|
|
592
|
+
return xs.slice(0, idx);
|
|
593
|
+
});
|
|
542
594
|
|
|
543
595
|
//#endregion
|
|
544
596
|
//#region src/extract.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/ast",
|
|
3
|
-
"version": "5.17.
|
|
3
|
+
"version": "5.17.1",
|
|
4
4
|
"description": "ESLint React's TSESTree AST utility module.",
|
|
5
5
|
"homepage": "https://github.com/Rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@typescript-eslint/parser": "^8.64.0",
|
|
39
39
|
"eslint": "^10.7.0",
|
|
40
|
-
"tsdown": "^0.22.
|
|
40
|
+
"tsdown": "^0.22.8",
|
|
41
41
|
"typescript": "6.0.3",
|
|
42
42
|
"vitest": "^4.1.10",
|
|
43
43
|
"@local/configs": "0.0.0",
|