@cspell/cspell-pipe 6.26.2 → 6.27.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/dist/cjs/helpers/distribute.js +37 -0
- package/dist/cjs/helpers/index.js +17 -0
- package/dist/cjs/helpers/interleave.js +22 -0
- package/dist/cjs/helpers/iteratorToIterable.js +18 -0
- package/dist/cjs/helpers/toArray.js +21 -0
- package/dist/cjs/helpers/toAsyncIterable.js +19 -0
- package/dist/cjs/helpers/util.js +15 -0
- package/dist/cjs/index.js +60 -0
- package/dist/cjs/internalTypes.js +3 -0
- package/dist/cjs/operators/{append.cjs → append.js} +8 -10
- package/dist/cjs/operators/await.js +13 -0
- package/dist/cjs/operators/{combine.cjs → combine.js} +5 -4
- package/dist/cjs/operators/{concatMap.cjs → concatMap.js} +8 -16
- package/dist/cjs/operators/{filter.cjs → filter.js} +8 -10
- package/dist/cjs/operators/{first.cjs → first.js} +8 -10
- package/dist/cjs/operators/{flatten.cjs → flatten.js} +8 -16
- package/dist/cjs/operators/index.js +60 -0
- package/dist/cjs/operators/joinStrings.js +28 -0
- package/dist/cjs/operators/{last.cjs → last.js} +8 -10
- package/dist/cjs/operators/{map.cjs → map.js} +8 -16
- package/dist/cjs/operators/{reduce.cjs → reduce.js} +9 -20
- package/dist/cjs/operators/{skip.cjs → skip.js} +8 -16
- package/dist/cjs/operators/{take.cjs → take.js} +8 -16
- package/dist/cjs/operators/{tap.cjs → tap.js} +8 -16
- package/dist/cjs/operators/types.js +3 -0
- package/dist/cjs/operators/{unique.cjs → unique.js} +8 -16
- package/dist/cjs/pipe.js +15 -0
- package/dist/cjs/reduce.js +27 -0
- package/dist/cjs/sync/index.js +26 -0
- package/dist/{cjs/operators/helpers/distribute.d.ts → esm/helpers/distribute.d.mts} +1 -1
- package/dist/esm/helpers/distribute.mjs +33 -0
- package/dist/esm/helpers/index.d.mts +7 -0
- package/dist/esm/helpers/index.mjs +7 -0
- package/dist/{cjs/operators/helpers/interleave.d.ts → esm/helpers/interleave.d.mts} +1 -1
- package/dist/esm/helpers/interleave.mjs +18 -0
- package/dist/{cjs/operators/helpers/iteratorToIterable.d.ts → esm/helpers/iteratorToIterable.d.mts} +1 -1
- package/dist/esm/helpers/iteratorToIterable.mjs +13 -0
- package/dist/{cjs/operators/helpers/toArray.d.ts → esm/helpers/toArray.d.mts} +1 -1
- package/dist/esm/helpers/toArray.mjs +15 -0
- package/dist/{cjs/sync/helpers/toAsyncIterable.d.ts → esm/helpers/toAsyncIterable.d.mts} +2 -2
- package/dist/esm/helpers/toAsyncIterable.mjs +15 -0
- package/dist/{cjs/operators/helpers/util.d.ts → esm/helpers/util.d.mts} +2 -2
- package/dist/esm/helpers/util.mjs +10 -0
- package/dist/esm/index.d.mts +9 -0
- package/dist/esm/index.mjs +11 -0
- package/dist/{cjs/operators/internalTypes.d.ts → esm/internalTypes.d.mts} +1 -1
- package/dist/esm/internalTypes.mjs +2 -0
- package/dist/{cjs/sync/operators/append.d.ts → esm/operators/append.d.mts} +2 -2
- package/dist/esm/operators/append.mjs +36 -0
- package/dist/{cjs/operators/operators/await.d.ts → esm/operators/await.d.mts} +1 -1
- package/dist/{cjs/operators/await.cjs → esm/operators/await.mjs} +2 -5
- package/dist/{cjs/operators/operators/combine.d.ts → esm/operators/combine.d.mts} +3 -3
- package/dist/esm/operators/combine.mjs +19 -0
- package/dist/{cjs/operators/operators/concatMap.d.ts → esm/operators/concatMap.d.mts} +1 -1
- package/dist/esm/operators/concatMap.mjs +19 -0
- package/dist/{cjs/operators/operators/filter.d.ts → esm/operators/filter.d.mts} +2 -2
- package/dist/esm/operators/filter.mjs +30 -0
- package/dist/{cjs/operators/operators/first.d.ts → esm/operators/first.d.mts} +2 -2
- package/dist/esm/operators/first.mjs +34 -0
- package/dist/{cjs/operators/operators/flatten.d.ts → esm/operators/flatten.d.mts} +1 -1
- package/dist/esm/operators/flatten.mjs +19 -0
- package/dist/esm/operators/index.d.mts +17 -0
- package/dist/esm/operators/index.mjs +16 -0
- package/dist/{cjs/operators/operators/joinStrings.d.ts → esm/operators/joinStrings.d.mts} +1 -1
- package/dist/esm/operators/joinStrings.mjs +22 -0
- package/dist/{cjs/operators/operators/last.d.ts → esm/operators/last.d.mts} +2 -2
- package/dist/esm/operators/last.mjs +39 -0
- package/dist/{cjs/operators/operators/map.d.ts → esm/operators/map.d.mts} +1 -1
- package/dist/esm/operators/map.mjs +19 -0
- package/dist/{cjs/operators/operators/reduce.d.ts → esm/operators/reduce.d.mts} +1 -1
- package/dist/esm/operators/reduce.mjs +49 -0
- package/dist/{cjs/operators/operators/skip.d.ts → esm/operators/skip.d.mts} +1 -1
- package/dist/esm/operators/skip.mjs +27 -0
- package/dist/{operators/take.d.ts → esm/operators/take.d.mts} +1 -1
- package/dist/esm/operators/take.mjs +31 -0
- package/dist/{cjs/sync/operators/tap.d.ts → esm/operators/tap.d.mts} +1 -1
- package/dist/esm/operators/tap.mjs +36 -0
- package/dist/{cjs/operators/operators/types.d.ts → esm/operators/types.d.mts} +1 -1
- package/dist/esm/operators/types.mjs +2 -0
- package/dist/{operators/unique.d.ts → esm/operators/unique.d.mts} +1 -1
- package/dist/esm/operators/unique.mjs +53 -0
- package/dist/{cjs/operators/pipe.d.ts → esm/pipe.d.mts} +2 -2
- package/dist/esm/pipe.mjs +10 -0
- package/dist/{cjs/sync/reduce.d.ts → esm/reduce.d.mts} +2 -2
- package/dist/esm/reduce.mjs +21 -0
- package/dist/{cjs/operators/sync/index.d.ts → esm/sync/index.d.mts} +6 -6
- package/dist/{cjs/sync/sync/index.d.ts → esm/sync/index.mjs} +5 -6
- package/package.json +41 -57
- package/dist/cjs/index.cjs +0 -644
- package/dist/cjs/operators/helpers/index.d.ts +0 -7
- package/dist/cjs/operators/helpers/toAsyncIterable.d.ts +0 -11
- package/dist/cjs/operators/index.cjs +0 -508
- package/dist/cjs/operators/joinStrings.cjs +0 -49
- package/dist/cjs/operators/operators/append.d.ts +0 -15
- package/dist/cjs/operators/operators/index.d.ts +0 -17
- package/dist/cjs/operators/operators/take.d.ts +0 -8
- package/dist/cjs/operators/operators/tap.d.ts +0 -19
- package/dist/cjs/operators/operators/unique.d.ts +0 -4
- package/dist/cjs/operators/types.cjs +0 -2
- package/dist/cjs/sync/helpers/distribute.d.ts +0 -13
- package/dist/cjs/sync/helpers/index.d.ts +0 -7
- package/dist/cjs/sync/helpers/interleave.d.ts +0 -2
- package/dist/cjs/sync/helpers/iteratorToIterable.d.ts +0 -3
- package/dist/cjs/sync/helpers/toArray.d.ts +0 -6
- package/dist/cjs/sync/helpers/util.d.ts +0 -4
- package/dist/cjs/sync/index.cjs +0 -245
- package/dist/cjs/sync/internalTypes.d.ts +0 -17
- package/dist/cjs/sync/operators/await.d.ts +0 -2
- package/dist/cjs/sync/operators/combine.d.ts +0 -23
- package/dist/cjs/sync/operators/concatMap.d.ts +0 -4
- package/dist/cjs/sync/operators/filter.d.ts +0 -10
- package/dist/cjs/sync/operators/first.d.ts +0 -10
- package/dist/cjs/sync/operators/flatten.d.ts +0 -4
- package/dist/cjs/sync/operators/index.d.ts +0 -17
- package/dist/cjs/sync/operators/joinStrings.d.ts +0 -4
- package/dist/cjs/sync/operators/last.d.ts +0 -10
- package/dist/cjs/sync/operators/map.d.ts +0 -4
- package/dist/cjs/sync/operators/reduce.d.ts +0 -7
- package/dist/cjs/sync/operators/skip.d.ts +0 -4
- package/dist/cjs/sync/operators/take.d.ts +0 -8
- package/dist/cjs/sync/operators/types.d.ts +0 -4
- package/dist/cjs/sync/operators/unique.d.ts +0 -4
- package/dist/cjs/sync/pipe.d.ts +0 -20
- package/dist/helpers/distribute.d.ts +0 -13
- package/dist/helpers/index.d.ts +0 -7
- package/dist/helpers/interleave.d.ts +0 -2
- package/dist/helpers/iteratorToIterable.d.ts +0 -3
- package/dist/helpers/toArray.d.ts +0 -6
- package/dist/helpers/toAsyncIterable.d.ts +0 -11
- package/dist/helpers/util.d.ts +0 -4
- package/dist/index.d.ts +0 -9
- package/dist/internalTypes.d.ts +0 -17
- package/dist/operators/append.d.ts +0 -15
- package/dist/operators/await.d.ts +0 -2
- package/dist/operators/combine.d.ts +0 -23
- package/dist/operators/concatMap.d.ts +0 -4
- package/dist/operators/filter.d.ts +0 -10
- package/dist/operators/first.d.ts +0 -10
- package/dist/operators/flatten.d.ts +0 -4
- package/dist/operators/index.d.ts +0 -17
- package/dist/operators/joinStrings.d.ts +0 -4
- package/dist/operators/last.d.ts +0 -10
- package/dist/operators/map.d.ts +0 -4
- package/dist/operators/reduce.d.ts +0 -7
- package/dist/operators/skip.d.ts +0 -4
- package/dist/operators/tap.d.ts +0 -19
- package/dist/operators/types.d.ts +0 -4
- package/dist/pipe.d.ts +0 -20
- package/dist/reduce.d.ts +0 -16
- package/dist/sync/index.d.ts +0 -6
|
@@ -1,508 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
function* iteratorToIterable(iterator) {
|
|
4
|
-
let n;
|
|
5
|
-
while (!(n = iterator.next()).done) {
|
|
6
|
-
yield n.value;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
async function* asyncIteratorToAsyncIterable(iterator) {
|
|
10
|
-
let n;
|
|
11
|
-
while (!(n = await iterator.next()).done) {
|
|
12
|
-
yield n.value;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function toPipeFn(syncFn, asyncFn) {
|
|
17
|
-
function _(i) {
|
|
18
|
-
return isAsyncIterable(i) ? asyncFn(i) : syncFn(i);
|
|
19
|
-
}
|
|
20
|
-
return _;
|
|
21
|
-
}
|
|
22
|
-
function isAsyncIterable(i) {
|
|
23
|
-
return typeof i[Symbol.asyncIterator] === 'function';
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function toArray(i) {
|
|
27
|
-
return isAsyncIterable(i) ? toArrayAsync(i) : toArraySync(i);
|
|
28
|
-
}
|
|
29
|
-
function toArraySync(iter) {
|
|
30
|
-
return [...iter];
|
|
31
|
-
}
|
|
32
|
-
async function toArrayAsync(iter) {
|
|
33
|
-
const collection = [];
|
|
34
|
-
for await (const i of iter) {
|
|
35
|
-
collection.push(i);
|
|
36
|
-
}
|
|
37
|
-
return collection;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Append values onto the end of an iterable.
|
|
42
|
-
* @param iterablesToAppend - the iterables in the order to be appended.
|
|
43
|
-
* @returns
|
|
44
|
-
*/
|
|
45
|
-
function opAppendAsync(...iterablesToAppend) {
|
|
46
|
-
async function* fn(iter) {
|
|
47
|
-
yield* iter;
|
|
48
|
-
for (const i of iterablesToAppend) {
|
|
49
|
-
yield* i;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return fn;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Append values onto the end of an iterable.
|
|
56
|
-
* @param iterablesToAppend - the iterables in the order to be appended.
|
|
57
|
-
* @returns
|
|
58
|
-
*/
|
|
59
|
-
function opAppendSync(...iterablesToAppend) {
|
|
60
|
-
function* fn(iter) {
|
|
61
|
-
yield* iter;
|
|
62
|
-
for (const i of iterablesToAppend) {
|
|
63
|
-
yield* i;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return fn;
|
|
67
|
-
}
|
|
68
|
-
function opAppend(...iterablesToAppend) {
|
|
69
|
-
function _(i) {
|
|
70
|
-
return isAsyncIterable(i) ? opAppendAsync(...iterablesToAppend)(i) : opAppendSync(...iterablesToAppend)(i);
|
|
71
|
-
}
|
|
72
|
-
return _;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
async function* _asyncAwait(iter) {
|
|
76
|
-
for await (const v of iter) {
|
|
77
|
-
yield v;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
function opAwaitAsync() {
|
|
81
|
-
return _asyncAwait;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function opCombineAsync(...fns) {
|
|
85
|
-
function combine(iter) {
|
|
86
|
-
for (const fn of fns) {
|
|
87
|
-
iter = fn(iter);
|
|
88
|
-
}
|
|
89
|
-
return iter;
|
|
90
|
-
}
|
|
91
|
-
return combine;
|
|
92
|
-
}
|
|
93
|
-
function opCombineSync(...fns) {
|
|
94
|
-
function combine(iter) {
|
|
95
|
-
for (const fn of fns) {
|
|
96
|
-
iter = fn(iter);
|
|
97
|
-
}
|
|
98
|
-
return iter;
|
|
99
|
-
}
|
|
100
|
-
return combine;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function opConcatMapAsync(mapFn) {
|
|
104
|
-
async function* fn(iter) {
|
|
105
|
-
for await (const v of iter) {
|
|
106
|
-
yield* mapFn(v);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
return fn;
|
|
110
|
-
}
|
|
111
|
-
function opConcatMapSync(mapFn) {
|
|
112
|
-
function* fn(iter) {
|
|
113
|
-
for (const v of iter) {
|
|
114
|
-
yield* mapFn(v);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
return fn;
|
|
118
|
-
}
|
|
119
|
-
const opConcatMap = (fn) => toPipeFn(opConcatMapSync(fn), opConcatMapAsync(fn));
|
|
120
|
-
|
|
121
|
-
// prettier-ignore
|
|
122
|
-
function opFilterAsync(filterFn) {
|
|
123
|
-
async function* fn(iter) {
|
|
124
|
-
for await (const v of iter) {
|
|
125
|
-
const pass = await filterFn(v);
|
|
126
|
-
if (pass)
|
|
127
|
-
yield v;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
return fn;
|
|
131
|
-
}
|
|
132
|
-
function opFilterSync(filterFn) {
|
|
133
|
-
function* fn(iter) {
|
|
134
|
-
for (const v of iter) {
|
|
135
|
-
if (filterFn(v))
|
|
136
|
-
yield v;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
return fn;
|
|
140
|
-
}
|
|
141
|
-
function opFilter(fn) {
|
|
142
|
-
const asyncFn = opFilterAsync(fn);
|
|
143
|
-
const syncFn = opFilterSync(fn);
|
|
144
|
-
function _(i) {
|
|
145
|
-
return isAsyncIterable(i) ? asyncFn(i) : syncFn(i);
|
|
146
|
-
}
|
|
147
|
-
return _;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// prettier-ignore
|
|
151
|
-
function opFirstAsync(firstFn) {
|
|
152
|
-
async function* fn(iter) {
|
|
153
|
-
for await (const v of iter) {
|
|
154
|
-
const pass = await firstFn(v);
|
|
155
|
-
if (pass) {
|
|
156
|
-
yield v;
|
|
157
|
-
break;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
return fn;
|
|
162
|
-
}
|
|
163
|
-
function opFirstSync(firstFn) {
|
|
164
|
-
function* fn(iter) {
|
|
165
|
-
for (const v of iter) {
|
|
166
|
-
if (firstFn(v)) {
|
|
167
|
-
yield v;
|
|
168
|
-
break;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
return fn;
|
|
173
|
-
}
|
|
174
|
-
function opFirst(fn) {
|
|
175
|
-
const asyncFn = opFirstAsync(fn);
|
|
176
|
-
const syncFn = opFirstSync(fn);
|
|
177
|
-
function _(i) {
|
|
178
|
-
return isAsyncIterable(i) ? asyncFn(i) : syncFn(i);
|
|
179
|
-
}
|
|
180
|
-
return _;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
function opFlattenAsync() {
|
|
184
|
-
async function* fn(iter) {
|
|
185
|
-
for await (const v of iter) {
|
|
186
|
-
yield* v;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
return fn;
|
|
190
|
-
}
|
|
191
|
-
function opFlattenSync() {
|
|
192
|
-
function* fn(iter) {
|
|
193
|
-
for (const v of iter) {
|
|
194
|
-
yield* v;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
return fn;
|
|
198
|
-
}
|
|
199
|
-
const opFlatten = () => toPipeFn(opFlattenSync(), opFlattenAsync());
|
|
200
|
-
|
|
201
|
-
function opJoinStringsAsync(joinCharacter = ',') {
|
|
202
|
-
async function* fn(iter) {
|
|
203
|
-
for await (const v of iter) {
|
|
204
|
-
const a = await toArray(v);
|
|
205
|
-
yield a.join(joinCharacter);
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
return fn;
|
|
209
|
-
}
|
|
210
|
-
function opJoinStringsSync(joinCharacter = ',') {
|
|
211
|
-
function* fn(iter) {
|
|
212
|
-
for (const v of iter) {
|
|
213
|
-
const a = toArray(v);
|
|
214
|
-
yield a.join(joinCharacter);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
return fn;
|
|
218
|
-
}
|
|
219
|
-
const opJoinStrings = (joinCharacter) => toPipeFn(opJoinStringsSync(joinCharacter), opJoinStringsAsync(joinCharacter));
|
|
220
|
-
|
|
221
|
-
const symNotFound = Symbol('LastNotFound');
|
|
222
|
-
// prettier-ignore
|
|
223
|
-
function opLastAsync(lastFn) {
|
|
224
|
-
async function* fn(iter) {
|
|
225
|
-
let last = symNotFound;
|
|
226
|
-
for await (const v of iter) {
|
|
227
|
-
const pass = await lastFn(v);
|
|
228
|
-
if (pass) {
|
|
229
|
-
last = v;
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
if (last !== symNotFound)
|
|
233
|
-
yield last;
|
|
234
|
-
}
|
|
235
|
-
return fn;
|
|
236
|
-
}
|
|
237
|
-
function opLastSync(lastFn) {
|
|
238
|
-
function* fn(iter) {
|
|
239
|
-
let last = symNotFound;
|
|
240
|
-
for (const v of iter) {
|
|
241
|
-
if (lastFn(v)) {
|
|
242
|
-
last = v;
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
if (last !== symNotFound)
|
|
246
|
-
yield last;
|
|
247
|
-
}
|
|
248
|
-
return fn;
|
|
249
|
-
}
|
|
250
|
-
function opLast(fn) {
|
|
251
|
-
const asyncFn = opLastAsync(fn);
|
|
252
|
-
const syncFn = opLastSync(fn);
|
|
253
|
-
function _(i) {
|
|
254
|
-
return isAsyncIterable(i) ? asyncFn(i) : syncFn(i);
|
|
255
|
-
}
|
|
256
|
-
return _;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
function opMapAsync(mapFn) {
|
|
260
|
-
async function* fn(iter) {
|
|
261
|
-
for await (const v of iter) {
|
|
262
|
-
yield mapFn(v);
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
return fn;
|
|
266
|
-
}
|
|
267
|
-
function opMapSync(mapFn) {
|
|
268
|
-
function* fn(iter) {
|
|
269
|
-
for (const v of iter) {
|
|
270
|
-
yield mapFn(v);
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
return fn;
|
|
274
|
-
}
|
|
275
|
-
const opMap = (fn) => toPipeFn(opMapSync(fn), opMapAsync(fn));
|
|
276
|
-
|
|
277
|
-
function opReduceAsync(reduceFn, initialValue) {
|
|
278
|
-
async function* reduce(head, tail) {
|
|
279
|
-
for await (const v of tail) {
|
|
280
|
-
head = reduceFn(head, v);
|
|
281
|
-
}
|
|
282
|
-
yield head;
|
|
283
|
-
}
|
|
284
|
-
async function* fn(iter) {
|
|
285
|
-
const ht = initialValue === undefined ? await headTailAsync(iter) : { head: await initialValue, tail: iter };
|
|
286
|
-
if (!ht)
|
|
287
|
-
return;
|
|
288
|
-
yield* reduce(ht.head, ht.tail);
|
|
289
|
-
}
|
|
290
|
-
return fn;
|
|
291
|
-
}
|
|
292
|
-
function opReduceSync(reduceFn, initialValue) {
|
|
293
|
-
function* reduce(head, tail) {
|
|
294
|
-
for (const v of tail) {
|
|
295
|
-
head = reduceFn(head, v);
|
|
296
|
-
}
|
|
297
|
-
yield head;
|
|
298
|
-
}
|
|
299
|
-
function* fn(iter) {
|
|
300
|
-
const ht = initialValue === undefined ? headTail(iter) : { head: initialValue, tail: iter };
|
|
301
|
-
if (!ht)
|
|
302
|
-
return;
|
|
303
|
-
yield* reduce(ht.head, ht.tail);
|
|
304
|
-
}
|
|
305
|
-
return fn;
|
|
306
|
-
}
|
|
307
|
-
function headTail(iter) {
|
|
308
|
-
const iterator = iter[Symbol.iterator]();
|
|
309
|
-
const first = iterator.next();
|
|
310
|
-
if (first.done)
|
|
311
|
-
return undefined;
|
|
312
|
-
return { head: first.value, tail: iteratorToIterable(iterator) };
|
|
313
|
-
}
|
|
314
|
-
async function headTailAsync(iter) {
|
|
315
|
-
const iterator = isIterable(iter) ? iter[Symbol.iterator]() : iter[Symbol.asyncIterator]();
|
|
316
|
-
const first = await iterator.next();
|
|
317
|
-
if (first.done)
|
|
318
|
-
return undefined;
|
|
319
|
-
return { head: first.value, tail: asyncIteratorToAsyncIterable(iterator) };
|
|
320
|
-
}
|
|
321
|
-
function isIterable(i) {
|
|
322
|
-
return typeof i[Symbol.iterator] === 'function';
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
function opSkipAsync(count) {
|
|
326
|
-
async function* fn(iter) {
|
|
327
|
-
for await (const v of iter) {
|
|
328
|
-
if (count > 0) {
|
|
329
|
-
--count;
|
|
330
|
-
continue;
|
|
331
|
-
}
|
|
332
|
-
yield v;
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
return fn;
|
|
336
|
-
}
|
|
337
|
-
function opSkipSync(count) {
|
|
338
|
-
function* fn(iter) {
|
|
339
|
-
for (const v of iter) {
|
|
340
|
-
if (count > 0) {
|
|
341
|
-
--count;
|
|
342
|
-
continue;
|
|
343
|
-
}
|
|
344
|
-
yield v;
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
return fn;
|
|
348
|
-
}
|
|
349
|
-
const opSkip = (count) => toPipeFn(opSkipSync(count), opSkipAsync(count));
|
|
350
|
-
|
|
351
|
-
function opTakeAsync(count) {
|
|
352
|
-
async function* fn(iter) {
|
|
353
|
-
if (count <= 0)
|
|
354
|
-
return;
|
|
355
|
-
for await (const v of iter) {
|
|
356
|
-
yield v;
|
|
357
|
-
if (--count <= 0)
|
|
358
|
-
return;
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
return fn;
|
|
362
|
-
}
|
|
363
|
-
function opTakeSync(count) {
|
|
364
|
-
function* fn(iter) {
|
|
365
|
-
if (count <= 0)
|
|
366
|
-
return;
|
|
367
|
-
for (const v of iter) {
|
|
368
|
-
yield v;
|
|
369
|
-
if (--count <= 0)
|
|
370
|
-
return;
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
return fn;
|
|
374
|
-
}
|
|
375
|
-
/**
|
|
376
|
-
* Consume only the first `count` number from the iterable.
|
|
377
|
-
* @param count - number to take
|
|
378
|
-
*/
|
|
379
|
-
const opTake = (count) => toPipeFn(opTakeSync(count), opTakeAsync(count));
|
|
380
|
-
|
|
381
|
-
/**
|
|
382
|
-
* Tap allows you to listen on values, without modifying them.
|
|
383
|
-
*
|
|
384
|
-
* @param fn - function to call for each value.
|
|
385
|
-
*/
|
|
386
|
-
function opTapAsync(tapFn) {
|
|
387
|
-
async function* fn(iter) {
|
|
388
|
-
for await (const v of iter) {
|
|
389
|
-
tapFn(v);
|
|
390
|
-
yield v;
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
return fn;
|
|
394
|
-
}
|
|
395
|
-
/**
|
|
396
|
-
* Tap allows you to listen on values, without modifying them.
|
|
397
|
-
*
|
|
398
|
-
* @param fn - function to call for each value.
|
|
399
|
-
*/
|
|
400
|
-
function opTapSync(tapFn) {
|
|
401
|
-
function* fn(iter) {
|
|
402
|
-
for (const v of iter) {
|
|
403
|
-
tapFn(v);
|
|
404
|
-
yield v;
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
return fn;
|
|
408
|
-
}
|
|
409
|
-
/**
|
|
410
|
-
* Tap allows you to listen on values, without modifying them.
|
|
411
|
-
*
|
|
412
|
-
* @param fn - function to call for each value.
|
|
413
|
-
*/
|
|
414
|
-
const opTap = (fn) => toPipeFn(opTapSync(fn), opTapAsync(fn));
|
|
415
|
-
|
|
416
|
-
function opUniqueAsync(k) {
|
|
417
|
-
function fnK(k) {
|
|
418
|
-
async function* fn(iter) {
|
|
419
|
-
const s = new Set();
|
|
420
|
-
for await (const v of iter) {
|
|
421
|
-
const kk = k(v);
|
|
422
|
-
if (s.has(kk))
|
|
423
|
-
continue;
|
|
424
|
-
s.add(kk);
|
|
425
|
-
yield v;
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
return fn;
|
|
429
|
-
}
|
|
430
|
-
async function* fn(iter) {
|
|
431
|
-
const s = new Set();
|
|
432
|
-
for await (const v of iter) {
|
|
433
|
-
if (s.has(v))
|
|
434
|
-
continue;
|
|
435
|
-
s.add(v);
|
|
436
|
-
yield v;
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
return k ? fnK(k) : fn;
|
|
440
|
-
}
|
|
441
|
-
function opUniqueSync(k) {
|
|
442
|
-
function fnK(key) {
|
|
443
|
-
function* fn(iter) {
|
|
444
|
-
const s = new Set();
|
|
445
|
-
for (const v of iter) {
|
|
446
|
-
const kk = key(v);
|
|
447
|
-
if (s.has(kk))
|
|
448
|
-
continue;
|
|
449
|
-
s.add(kk);
|
|
450
|
-
yield v;
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
return fn;
|
|
454
|
-
}
|
|
455
|
-
function* fn(iter) {
|
|
456
|
-
const s = new Set();
|
|
457
|
-
for (const v of iter) {
|
|
458
|
-
if (s.has(v))
|
|
459
|
-
continue;
|
|
460
|
-
s.add(v);
|
|
461
|
-
yield v;
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
return k ? fnK(k) : fn;
|
|
465
|
-
}
|
|
466
|
-
const opUnique = (getKey) => toPipeFn(opUniqueSync(getKey), opUniqueAsync(getKey));
|
|
467
|
-
|
|
468
|
-
exports.opAppend = opAppend;
|
|
469
|
-
exports.opAppendAsync = opAppendAsync;
|
|
470
|
-
exports.opAppendSync = opAppendSync;
|
|
471
|
-
exports.opAwaitAsync = opAwaitAsync;
|
|
472
|
-
exports.opCombineAsync = opCombineAsync;
|
|
473
|
-
exports.opCombineSync = opCombineSync;
|
|
474
|
-
exports.opConcatMap = opConcatMap;
|
|
475
|
-
exports.opConcatMapAsync = opConcatMapAsync;
|
|
476
|
-
exports.opConcatMapSync = opConcatMapSync;
|
|
477
|
-
exports.opFilter = opFilter;
|
|
478
|
-
exports.opFilterAsync = opFilterAsync;
|
|
479
|
-
exports.opFilterSync = opFilterSync;
|
|
480
|
-
exports.opFirst = opFirst;
|
|
481
|
-
exports.opFirstAsync = opFirstAsync;
|
|
482
|
-
exports.opFirstSync = opFirstSync;
|
|
483
|
-
exports.opFlatten = opFlatten;
|
|
484
|
-
exports.opFlattenAsync = opFlattenAsync;
|
|
485
|
-
exports.opFlattenSync = opFlattenSync;
|
|
486
|
-
exports.opJoinStrings = opJoinStrings;
|
|
487
|
-
exports.opJoinStringsAsync = opJoinStringsAsync;
|
|
488
|
-
exports.opJoinStringsSync = opJoinStringsSync;
|
|
489
|
-
exports.opLast = opLast;
|
|
490
|
-
exports.opLastAsync = opLastAsync;
|
|
491
|
-
exports.opLastSync = opLastSync;
|
|
492
|
-
exports.opMap = opMap;
|
|
493
|
-
exports.opMapAsync = opMapAsync;
|
|
494
|
-
exports.opMapSync = opMapSync;
|
|
495
|
-
exports.opReduceAsync = opReduceAsync;
|
|
496
|
-
exports.opReduceSync = opReduceSync;
|
|
497
|
-
exports.opSkip = opSkip;
|
|
498
|
-
exports.opSkipAsync = opSkipAsync;
|
|
499
|
-
exports.opSkipSync = opSkipSync;
|
|
500
|
-
exports.opTake = opTake;
|
|
501
|
-
exports.opTakeAsync = opTakeAsync;
|
|
502
|
-
exports.opTakeSync = opTakeSync;
|
|
503
|
-
exports.opTap = opTap;
|
|
504
|
-
exports.opTapAsync = opTapAsync;
|
|
505
|
-
exports.opTapSync = opTapSync;
|
|
506
|
-
exports.opUnique = opUnique;
|
|
507
|
-
exports.opUniqueAsync = opUniqueAsync;
|
|
508
|
-
exports.opUniqueSync = opUniqueSync;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
function toPipeFn(syncFn, asyncFn) {
|
|
4
|
-
function _(i) {
|
|
5
|
-
return isAsyncIterable(i) ? asyncFn(i) : syncFn(i);
|
|
6
|
-
}
|
|
7
|
-
return _;
|
|
8
|
-
}
|
|
9
|
-
function isAsyncIterable(i) {
|
|
10
|
-
return typeof i[Symbol.asyncIterator] === 'function';
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function toArray(i) {
|
|
14
|
-
return isAsyncIterable(i) ? toArrayAsync(i) : toArraySync(i);
|
|
15
|
-
}
|
|
16
|
-
function toArraySync(iter) {
|
|
17
|
-
return [...iter];
|
|
18
|
-
}
|
|
19
|
-
async function toArrayAsync(iter) {
|
|
20
|
-
const collection = [];
|
|
21
|
-
for await (const i of iter) {
|
|
22
|
-
collection.push(i);
|
|
23
|
-
}
|
|
24
|
-
return collection;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function opJoinStringsAsync(joinCharacter = ',') {
|
|
28
|
-
async function* fn(iter) {
|
|
29
|
-
for await (const v of iter) {
|
|
30
|
-
const a = await toArray(v);
|
|
31
|
-
yield a.join(joinCharacter);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return fn;
|
|
35
|
-
}
|
|
36
|
-
function opJoinStringsSync(joinCharacter = ',') {
|
|
37
|
-
function* fn(iter) {
|
|
38
|
-
for (const v of iter) {
|
|
39
|
-
const a = toArray(v);
|
|
40
|
-
yield a.join(joinCharacter);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return fn;
|
|
44
|
-
}
|
|
45
|
-
const opJoinStrings = (joinCharacter) => toPipeFn(opJoinStringsSync(joinCharacter), opJoinStringsAsync(joinCharacter));
|
|
46
|
-
|
|
47
|
-
exports.opJoinStrings = opJoinStrings;
|
|
48
|
-
exports.opJoinStringsAsync = opJoinStringsAsync;
|
|
49
|
-
exports.opJoinStringsSync = opJoinStringsSync;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { PipeFn } from '../internalTypes.js';
|
|
2
|
-
/**
|
|
3
|
-
* Append values onto the end of an iterable.
|
|
4
|
-
* @param iterablesToAppend - the iterables in the order to be appended.
|
|
5
|
-
* @returns
|
|
6
|
-
*/
|
|
7
|
-
export declare function opAppendAsync<T>(...iterablesToAppend: (AsyncIterable<T> | Iterable<T>)[]): (iter: AsyncIterable<T> | Iterable<T>) => AsyncIterable<T>;
|
|
8
|
-
/**
|
|
9
|
-
* Append values onto the end of an iterable.
|
|
10
|
-
* @param iterablesToAppend - the iterables in the order to be appended.
|
|
11
|
-
* @returns
|
|
12
|
-
*/
|
|
13
|
-
export declare function opAppendSync<T>(...iterablesToAppend: Iterable<T>[]): (iter: Iterable<T>) => Iterable<T>;
|
|
14
|
-
export declare function opAppend<T>(...iterablesToAppend: Iterable<T>[]): PipeFn<T, T>;
|
|
15
|
-
//# sourceMappingURL=append.d.ts.map
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export { opAppend, opAppendAsync, opAppendSync } from './append.js';
|
|
2
|
-
export { opAwaitAsync } from './await.js';
|
|
3
|
-
export { opCombineAsync, opCombineSync } from './combine.js';
|
|
4
|
-
export { opConcatMap, opConcatMapAsync, opConcatMapSync } from './concatMap.js';
|
|
5
|
-
export { opFilter, opFilterAsync, opFilterSync } from './filter.js';
|
|
6
|
-
export { opFirst, opFirstAsync, opFirstSync } from './first.js';
|
|
7
|
-
export { opFlatten, opFlattenAsync, opFlattenSync } from './flatten.js';
|
|
8
|
-
export { opJoinStrings, opJoinStringsAsync, opJoinStringsSync } from './joinStrings.js';
|
|
9
|
-
export { opLast, opLastAsync, opLastSync } from './last.js';
|
|
10
|
-
export { opMap, opMapAsync, opMapSync } from './map.js';
|
|
11
|
-
export { opReduceAsync, opReduceSync } from './reduce.js';
|
|
12
|
-
export { opSkip, opSkipAsync, opSkipSync } from './skip.js';
|
|
13
|
-
export { opTake, opTakeAsync, opTakeSync } from './take.js';
|
|
14
|
-
export { opTap, opTapAsync, opTapSync } from './tap.js';
|
|
15
|
-
export type { OperatorAsync, OperatorSync, OperatorSyncToAsync } from './types.js';
|
|
16
|
-
export { opUnique, opUniqueAsync, opUniqueSync } from './unique.js';
|
|
17
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare function opTakeAsync<T>(count: number): (iter: AsyncIterable<T> | Iterable<T>) => AsyncIterable<T>;
|
|
2
|
-
export declare function opTakeSync<T>(count: number): (iter: Iterable<T>) => Iterable<T>;
|
|
3
|
-
/**
|
|
4
|
-
* Consume only the first `count` number from the iterable.
|
|
5
|
-
* @param count - number to take
|
|
6
|
-
*/
|
|
7
|
-
export declare const opTake: <T>(count: number) => import("../internalTypes.js").PipeFn<T, T>;
|
|
8
|
-
//# sourceMappingURL=take.d.ts.map
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tap allows you to listen on values, without modifying them.
|
|
3
|
-
*
|
|
4
|
-
* @param fn - function to call for each value.
|
|
5
|
-
*/
|
|
6
|
-
export declare function opTapAsync<T>(tapFn: (v: T) => void): (iter: AsyncIterable<T>) => AsyncIterable<T>;
|
|
7
|
-
/**
|
|
8
|
-
* Tap allows you to listen on values, without modifying them.
|
|
9
|
-
*
|
|
10
|
-
* @param fn - function to call for each value.
|
|
11
|
-
*/
|
|
12
|
-
export declare function opTapSync<T>(tapFn: (v: T) => void): (iter: Iterable<T>) => Iterable<T>;
|
|
13
|
-
/**
|
|
14
|
-
* Tap allows you to listen on values, without modifying them.
|
|
15
|
-
*
|
|
16
|
-
* @param fn - function to call for each value.
|
|
17
|
-
*/
|
|
18
|
-
export declare const opTap: <T>(fn: (v: T) => void) => import("../internalTypes.js").PipeFn<T, T>;
|
|
19
|
-
//# sourceMappingURL=tap.d.ts.map
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare function opUniqueAsync<T, U>(k?: (v: T) => U): (iter: AsyncIterable<T>) => AsyncIterable<T>;
|
|
2
|
-
export declare function opUniqueSync<T, U>(k?: (v: T) => U): (iter: Iterable<T>) => Iterable<T>;
|
|
3
|
-
export declare const opUnique: <T, U = T>(getKey?: ((v: T) => U) | undefined) => import("../internalTypes.js").PipeFn<T, T>;
|
|
4
|
-
//# sourceMappingURL=unique.d.ts.map
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Allows an iterable to be shared by multiple consumers.
|
|
3
|
-
* Each consumer takes from the iterable.
|
|
4
|
-
* @param iterable - the iterable to share
|
|
5
|
-
*/
|
|
6
|
-
export declare function toDistributableIterableSync<T>(iterable: Iterable<T>): Iterable<T>;
|
|
7
|
-
/**
|
|
8
|
-
* Allows an iterable to be shared by multiple consumers.
|
|
9
|
-
* Each consumer takes from the iterable.
|
|
10
|
-
* @param iterable - the iterable to share
|
|
11
|
-
*/
|
|
12
|
-
export declare const toDistributableIterable: typeof toDistributableIterableSync;
|
|
13
|
-
//# sourceMappingURL=distribute.d.ts.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { toDistributableIterable } from './distribute.js';
|
|
2
|
-
export { interleave } from './interleave.js';
|
|
3
|
-
export { asyncIteratorToAsyncIterable, iteratorToIterable } from './iteratorToIterable.js';
|
|
4
|
-
export { toArray } from './toArray.js';
|
|
5
|
-
export { toAsyncIterable } from './toAsyncIterable.js';
|
|
6
|
-
export { isAsyncIterable } from './util.js';
|
|
7
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare function toArray<T>(i: AsyncIterable<T>): Promise<Awaited<T>[]>;
|
|
2
|
-
export declare function toArray<T>(i: Iterable<T>): T[];
|
|
3
|
-
export declare function toArray<T>(i: Iterable<T> | AsyncIterable<T>): T[] | Promise<Awaited<T>[]>;
|
|
4
|
-
export declare function toArraySync<T>(iter: Iterable<T>): T[];
|
|
5
|
-
export declare function toArrayAsync<T>(iter: AsyncIterable<T>): Promise<Awaited<T>[]>;
|
|
6
|
-
//# sourceMappingURL=toArray.d.ts.map
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { AnyIterable, PipeFn, PipeFnAsync, PipeFnSync } from '../internalTypes.js';
|
|
2
|
-
export declare function toPipeFn<T, U = T>(syncFn: PipeFnSync<T, U>, asyncFn: PipeFnAsync<T, U>): PipeFn<T, U>;
|
|
3
|
-
export declare function isAsyncIterable<T>(i: AnyIterable<T>): i is AsyncIterable<T>;
|
|
4
|
-
//# sourceMappingURL=util.d.ts.map
|