@cspell/cspell-pipe 8.12.1 → 8.13.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/operators/append.js +4 -4
- package/dist/operators/buffer.js +4 -4
- package/dist/operators/concatMap.d.ts +1 -0
- package/dist/operators/concatMap.js +33 -2
- package/dist/operators/filter.d.ts +2 -0
- package/dist/operators/filter.js +27 -4
- package/dist/operators/map.d.ts +2 -1
- package/dist/operators/map.js +25 -5
- package/package.json +10 -6
package/dist/operators/append.js
CHANGED
|
@@ -5,13 +5,13 @@ import { isAsyncIterable } from '../helpers/index.js';
|
|
|
5
5
|
* @returns
|
|
6
6
|
*/
|
|
7
7
|
export function opAppendAsync(...iterablesToAppend) {
|
|
8
|
-
async function*
|
|
8
|
+
async function* fnAppend(iter) {
|
|
9
9
|
yield* iter;
|
|
10
10
|
for (const i of iterablesToAppend) {
|
|
11
11
|
yield* i;
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
return
|
|
14
|
+
return fnAppend;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* Append values onto the end of an iterable.
|
|
@@ -19,13 +19,13 @@ export function opAppendAsync(...iterablesToAppend) {
|
|
|
19
19
|
* @returns
|
|
20
20
|
*/
|
|
21
21
|
export function opAppendSync(...iterablesToAppend) {
|
|
22
|
-
function*
|
|
22
|
+
function* fnAppend(iter) {
|
|
23
23
|
yield* iter;
|
|
24
24
|
for (const i of iterablesToAppend) {
|
|
25
25
|
yield* i;
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
return
|
|
28
|
+
return fnAppend;
|
|
29
29
|
}
|
|
30
30
|
export function opAppend(...iterablesToAppend) {
|
|
31
31
|
function _(i) {
|
package/dist/operators/buffer.js
CHANGED
|
@@ -5,7 +5,7 @@ import { isAsyncIterable } from '../helpers/util.js';
|
|
|
5
5
|
* @returns A function that takes an async iterable and returns an async iterable of arrays of the given size.
|
|
6
6
|
*/
|
|
7
7
|
export function opBufferAsync(size) {
|
|
8
|
-
async function*
|
|
8
|
+
async function* fnBuffer(iter) {
|
|
9
9
|
let buffer = [];
|
|
10
10
|
for await (const v of iter) {
|
|
11
11
|
buffer.push(v);
|
|
@@ -18,14 +18,14 @@ export function opBufferAsync(size) {
|
|
|
18
18
|
yield buffer;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
return
|
|
21
|
+
return fnBuffer;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
24
|
* @param size - The size of the buffer.
|
|
25
25
|
* @returns A function that takes an iterable and returns an iterable of arrays of the given size.
|
|
26
26
|
*/
|
|
27
27
|
export function opBufferSync(size) {
|
|
28
|
-
function*
|
|
28
|
+
function* fnBuffer(iter) {
|
|
29
29
|
let buffer = [];
|
|
30
30
|
for (const v of iter) {
|
|
31
31
|
buffer.push(v);
|
|
@@ -38,7 +38,7 @@ export function opBufferSync(size) {
|
|
|
38
38
|
yield buffer;
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
return
|
|
41
|
+
return fnBuffer;
|
|
42
42
|
}
|
|
43
43
|
export function opBuffer(size) {
|
|
44
44
|
const asyncFn = opBufferAsync(size);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare function opConcatMapAsync<T, U = T>(mapFn: (v: T) => AsyncIterable<U> | Iterable<U>): (iter: AsyncIterable<T>) => AsyncIterable<U>;
|
|
2
2
|
export declare function opConcatMapSync<T, U = T>(mapFn: (v: T) => Iterable<U>): (iter: Iterable<T>) => Iterable<U>;
|
|
3
|
+
export declare function _opConcatMapSync<T, U = T>(mapFn: (v: T) => Iterable<U>): (iter: Iterable<T>) => Iterable<U>;
|
|
3
4
|
export declare const opConcatMap: <T, U>(fn: (v: T) => Iterable<U>) => import("../internalTypes.js").PipeFn<T, U>;
|
|
4
5
|
//# sourceMappingURL=concatMap.d.ts.map
|
|
@@ -8,12 +8,43 @@ export function opConcatMapAsync(mapFn) {
|
|
|
8
8
|
return fn;
|
|
9
9
|
}
|
|
10
10
|
export function opConcatMapSync(mapFn) {
|
|
11
|
-
function
|
|
11
|
+
function fnConcatMapSync(iterable) {
|
|
12
|
+
function opConcatMapIterator() {
|
|
13
|
+
const iter = iterable[Symbol.iterator]();
|
|
14
|
+
let resultsIter = undefined;
|
|
15
|
+
function nextConcatMap() {
|
|
16
|
+
while (true) {
|
|
17
|
+
if (resultsIter) {
|
|
18
|
+
const { done, value } = resultsIter.next();
|
|
19
|
+
if (!done) {
|
|
20
|
+
return { value };
|
|
21
|
+
}
|
|
22
|
+
resultsIter = undefined;
|
|
23
|
+
}
|
|
24
|
+
const { done, value } = iter.next();
|
|
25
|
+
if (done) {
|
|
26
|
+
return { done, value: undefined };
|
|
27
|
+
}
|
|
28
|
+
resultsIter = mapFn(value)[Symbol.iterator]();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
next: nextConcatMap,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
[Symbol.iterator]: opConcatMapIterator,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
return fnConcatMapSync;
|
|
40
|
+
}
|
|
41
|
+
export function _opConcatMapSync(mapFn) {
|
|
42
|
+
function* fnConcatMapSync(iter) {
|
|
12
43
|
for (const v of iter) {
|
|
13
44
|
yield* mapFn(v);
|
|
14
45
|
}
|
|
15
46
|
}
|
|
16
|
-
return
|
|
47
|
+
return fnConcatMapSync;
|
|
17
48
|
}
|
|
18
49
|
export const opConcatMap = (fn) => toPipeFn(opConcatMapSync(fn), opConcatMapAsync(fn));
|
|
19
50
|
//# sourceMappingURL=concatMap.js.map
|
|
@@ -5,6 +5,8 @@ export declare function opFilterAsync<T>(filterFn: (v: Awaited<T>) => boolean):
|
|
|
5
5
|
export declare function opFilterAsync<T>(filterFn: (v: Awaited<T>) => Promise<boolean>): (iter: AsyncIterable<T>) => AsyncIterable<Awaited<T>>;
|
|
6
6
|
export declare function opFilterSync<T, S extends T>(filterFn: (v: T) => v is S): (iter: Iterable<T>) => Iterable<S>;
|
|
7
7
|
export declare function opFilterSync<T>(filterFn: (v: T) => boolean): (iter: Iterable<T>) => Iterable<T>;
|
|
8
|
+
export declare function _opFilterSync<T, S extends T>(filterFn: (v: T) => v is S): (iter: Iterable<T>) => Iterable<S>;
|
|
9
|
+
export declare function _opFilterSync<T>(filterFn: (v: T) => boolean): (iter: Iterable<T>) => Iterable<T>;
|
|
8
10
|
export declare function opFilter<T, S extends T>(fn: (v: T) => v is S): PipeFn<T, S>;
|
|
9
11
|
export declare function opFilter<T>(fn: (v: T) => boolean): PipeFn<T, T>;
|
|
10
12
|
//# sourceMappingURL=filter.d.ts.map
|
package/dist/operators/filter.js
CHANGED
|
@@ -1,23 +1,46 @@
|
|
|
1
1
|
import { isAsyncIterable } from '../helpers/util.js';
|
|
2
2
|
// prettier-ignore
|
|
3
3
|
export function opFilterAsync(filterFn) {
|
|
4
|
-
async function*
|
|
4
|
+
async function* genFilter(iter) {
|
|
5
5
|
for await (const v of iter) {
|
|
6
6
|
const pass = await filterFn(v);
|
|
7
7
|
if (pass)
|
|
8
8
|
yield v;
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
-
return
|
|
11
|
+
return genFilter;
|
|
12
12
|
}
|
|
13
13
|
export function opFilterSync(filterFn) {
|
|
14
|
-
function
|
|
14
|
+
function opFilterIterable(iterable) {
|
|
15
|
+
function opFilterIterator() {
|
|
16
|
+
const iter = iterable[Symbol.iterator]();
|
|
17
|
+
function nextOpFilter() {
|
|
18
|
+
while (true) {
|
|
19
|
+
const { done, value } = iter.next();
|
|
20
|
+
if (done)
|
|
21
|
+
return { done, value: undefined };
|
|
22
|
+
if (filterFn(value))
|
|
23
|
+
return { value };
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
next: nextOpFilter,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
[Symbol.iterator]: opFilterIterator,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return opFilterIterable;
|
|
35
|
+
}
|
|
36
|
+
export function _opFilterSync(filterFn) {
|
|
37
|
+
function* genFilter(iter) {
|
|
15
38
|
for (const v of iter) {
|
|
16
39
|
if (filterFn(v))
|
|
17
40
|
yield v;
|
|
18
41
|
}
|
|
19
42
|
}
|
|
20
|
-
return
|
|
43
|
+
return genFilter;
|
|
21
44
|
}
|
|
22
45
|
export function opFilter(fn) {
|
|
23
46
|
const asyncFn = opFilterAsync(fn);
|
package/dist/operators/map.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare function opMapAsync<T, U = T>(mapFn: (v: T) => U): (iter: AsyncIterable<T>) => AsyncIterable<U>;
|
|
2
|
-
export declare function
|
|
2
|
+
export declare function _opMapSync<T, U = T>(mapFn: (v: T) => U): (iter: Iterable<T>) => Iterable<U>;
|
|
3
|
+
export declare function opMapSync<T, U = T>(mapFn: (v: T) => U): (iterable: Iterable<T>) => Iterable<U>;
|
|
3
4
|
export declare const opMap: <T, U>(fn: (v: T) => U) => import("../internalTypes.js").PipeFn<T, U>;
|
|
4
5
|
//# sourceMappingURL=map.d.ts.map
|
package/dist/operators/map.js
CHANGED
|
@@ -1,19 +1,39 @@
|
|
|
1
1
|
import { toPipeFn } from '../helpers/util.js';
|
|
2
2
|
export function opMapAsync(mapFn) {
|
|
3
|
-
async function*
|
|
3
|
+
async function* genMap(iter) {
|
|
4
4
|
for await (const v of iter) {
|
|
5
5
|
yield mapFn(v);
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
|
-
return
|
|
8
|
+
return genMap;
|
|
9
9
|
}
|
|
10
|
-
export function
|
|
11
|
-
function*
|
|
10
|
+
export function _opMapSync(mapFn) {
|
|
11
|
+
function* genMap(iter) {
|
|
12
12
|
for (const v of iter) {
|
|
13
13
|
yield mapFn(v);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
return
|
|
16
|
+
return genMap;
|
|
17
|
+
}
|
|
18
|
+
export function opMapSync(mapFn) {
|
|
19
|
+
function opMapIterable(iterable) {
|
|
20
|
+
function opMapIterator() {
|
|
21
|
+
const iter = iterable[Symbol.iterator]();
|
|
22
|
+
function nextOpMap() {
|
|
23
|
+
const { done, value } = iter.next();
|
|
24
|
+
if (done)
|
|
25
|
+
return { done, value: undefined };
|
|
26
|
+
return { value: mapFn(value) };
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
next: nextOpMap,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
[Symbol.iterator]: opMapIterator,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return opMapIterable;
|
|
17
37
|
}
|
|
18
38
|
export const opMap = (fn) => toPipeFn(opMapSync(fn), opMapAsync(fn));
|
|
19
39
|
//# sourceMappingURL=map.js.map
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "8.
|
|
6
|
+
"version": "8.13.1",
|
|
7
7
|
"description": "Library to make working with Iterators/AsyncIterators easier.",
|
|
8
8
|
"keywords": [
|
|
9
9
|
"cspell",
|
|
@@ -99,18 +99,21 @@
|
|
|
99
99
|
"!**/*.tsbuildInfo",
|
|
100
100
|
"!**/__mocks__",
|
|
101
101
|
"!**/*.spec.*",
|
|
102
|
+
"!**/*.perf.*",
|
|
102
103
|
"!**/*.test.*",
|
|
104
|
+
"!**/perf/**",
|
|
103
105
|
"!**/test/**",
|
|
104
106
|
"!**/*.map"
|
|
105
107
|
],
|
|
106
108
|
"scripts": {
|
|
107
|
-
"build": "tsc -
|
|
108
|
-
"watch": "tsc -
|
|
109
|
+
"build": "tsc -p .",
|
|
110
|
+
"watch": "tsc -p . -w",
|
|
109
111
|
"clean": "shx rm -rf dist temp coverage \"*.tsbuildInfo\"",
|
|
110
112
|
"clean-build": "pnpm run clean && pnpm run build",
|
|
111
113
|
"coverage": "vitest run --coverage",
|
|
112
114
|
"test-watch": "vitest",
|
|
113
|
-
"test": "vitest run"
|
|
115
|
+
"test": "vitest run",
|
|
116
|
+
"test:perf": "NODE_ENV=production insight --register ts-node/esm --file \"**/*.perf.{mts,ts}\""
|
|
114
117
|
},
|
|
115
118
|
"repository": {
|
|
116
119
|
"type": "git",
|
|
@@ -124,7 +127,8 @@
|
|
|
124
127
|
"node": ">=18"
|
|
125
128
|
},
|
|
126
129
|
"devDependencies": {
|
|
127
|
-
"globby": "^14.0.2"
|
|
130
|
+
"globby": "^14.0.2",
|
|
131
|
+
"perf-insight": "^1.2.0"
|
|
128
132
|
},
|
|
129
|
-
"gitHead": "
|
|
133
|
+
"gitHead": "99cdb4e3e6579c57de1014b0cd3c168188b9c1f5"
|
|
130
134
|
}
|