iter-fest 0.1.1-main.d88474c → 0.1.1-main.dd552c2
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/README.md +43 -18
- package/dist/chunk-3S6LCGE6.mjs +10 -0
- package/dist/chunk-3S6LCGE6.mjs.map +1 -0
- package/dist/chunk-BWMXKULC.mjs +46 -0
- package/dist/chunk-BWMXKULC.mjs.map +1 -0
- package/dist/chunk-FBST4AUL.mjs +10 -0
- package/dist/chunk-FBST4AUL.mjs.map +1 -0
- package/dist/chunk-FMIHIL6A.mjs +10 -0
- package/dist/chunk-FMIHIL6A.mjs.map +1 -0
- package/dist/chunk-KYMTQJIJ.mjs +10 -0
- package/dist/chunk-KYMTQJIJ.mjs.map +1 -0
- package/dist/chunk-LIMQXDFK.mjs +10 -0
- package/dist/chunk-LIMQXDFK.mjs.map +1 -0
- package/dist/chunk-OWUGLCQB.mjs +10 -0
- package/dist/chunk-OWUGLCQB.mjs.map +1 -0
- package/dist/chunk-QX6EMOSQ.mjs +10 -0
- package/dist/chunk-QX6EMOSQ.mjs.map +1 -0
- package/dist/chunk-R6SXIXMH.mjs +10 -0
- package/dist/chunk-R6SXIXMH.mjs.map +1 -0
- package/dist/chunk-TDHR35S7.mjs +10 -0
- package/dist/chunk-TDHR35S7.mjs.map +1 -0
- package/dist/chunk-VCKLUCOT.mjs +10 -0
- package/dist/chunk-VCKLUCOT.mjs.map +1 -0
- package/dist/chunk-XQDGXAAF.mjs +10 -0
- package/dist/chunk-XQDGXAAF.mjs.map +1 -0
- package/dist/{chunk-MOBXUTO5.mjs → chunk-YJSIVBF7.mjs} +5 -5
- package/dist/chunk-YJSIVBF7.mjs.map +1 -0
- package/dist/chunk-YLERARWI.mjs +10 -0
- package/dist/chunk-YLERARWI.mjs.map +1 -0
- package/dist/iter-fest.d.mts +14 -9
- package/dist/iter-fest.d.ts +14 -9
- package/dist/iter-fest.iterableWritableStream.d.mts +7 -0
- package/dist/iter-fest.iterableWritableStream.d.ts +7 -0
- package/dist/{iter-fest.pushAsyncIterableIterator.js → iter-fest.iterableWritableStream.js} +39 -30
- package/dist/iter-fest.iterableWritableStream.js.map +1 -0
- package/dist/iter-fest.iterableWritableStream.mjs +7 -0
- package/dist/iter-fest.iteratorDrop.d.mts +12 -0
- package/dist/iter-fest.iteratorDrop.d.ts +12 -0
- package/dist/iter-fest.iteratorDrop.js +44 -0
- package/dist/iter-fest.iteratorDrop.js.map +1 -0
- package/dist/iter-fest.iteratorDrop.mjs +7 -0
- package/dist/iter-fest.iteratorEvery.d.mts +25 -0
- package/dist/iter-fest.iteratorEvery.d.ts +25 -0
- package/dist/iter-fest.iteratorEvery.js +44 -0
- package/dist/iter-fest.iteratorEvery.js.map +1 -0
- package/dist/iter-fest.iteratorEvery.mjs +7 -0
- package/dist/iter-fest.iteratorFilter.d.mts +18 -0
- package/dist/iter-fest.iteratorFilter.d.ts +18 -0
- package/dist/iter-fest.iteratorFilter.js +44 -0
- package/dist/iter-fest.iteratorFilter.js.map +1 -0
- package/dist/iter-fest.iteratorFilter.mjs +7 -0
- package/dist/iter-fest.iteratorFind.d.mts +14 -0
- package/dist/iter-fest.iteratorFind.d.ts +14 -0
- package/dist/iter-fest.iteratorFind.js +44 -0
- package/dist/iter-fest.iteratorFind.js.map +1 -0
- package/dist/iter-fest.iteratorFind.mjs +7 -0
- package/dist/iter-fest.iteratorFlatMap.d.mts +12 -0
- package/dist/iter-fest.iteratorFlatMap.d.ts +12 -0
- package/dist/iter-fest.iteratorFlatMap.js +44 -0
- package/dist/iter-fest.iteratorFlatMap.js.map +1 -0
- package/dist/iter-fest.iteratorFlatMap.mjs +7 -0
- package/dist/iter-fest.iteratorForEach.d.mts +10 -0
- package/dist/iter-fest.iteratorForEach.d.ts +10 -0
- package/dist/iter-fest.iteratorForEach.js +44 -0
- package/dist/iter-fest.iteratorForEach.js.map +1 -0
- package/dist/iter-fest.iteratorForEach.mjs +7 -0
- package/dist/iter-fest.iteratorFrom.d.mts +12 -0
- package/dist/iter-fest.iteratorFrom.d.ts +12 -0
- package/dist/iter-fest.iteratorFrom.js +44 -0
- package/dist/iter-fest.iteratorFrom.js.map +1 -0
- package/dist/iter-fest.iteratorFrom.mjs +7 -0
- package/dist/iter-fest.iteratorMap.d.mts +10 -0
- package/dist/iter-fest.iteratorMap.d.ts +10 -0
- package/dist/iter-fest.iteratorMap.js +44 -0
- package/dist/iter-fest.iteratorMap.js.map +1 -0
- package/dist/iter-fest.iteratorMap.mjs +7 -0
- package/dist/{iter-fest.iterableReduce.d.mts → iter-fest.iteratorReduce.d.mts} +13 -9
- package/dist/{iter-fest.iterableReduce.d.ts → iter-fest.iteratorReduce.d.ts} +13 -9
- package/dist/iter-fest.iteratorReduce.js +44 -0
- package/dist/iter-fest.iteratorReduce.js.map +1 -0
- package/dist/iter-fest.iteratorReduce.mjs +7 -0
- package/dist/iter-fest.iteratorReduce.mjs.map +1 -0
- package/dist/iter-fest.iteratorSome.d.mts +10 -0
- package/dist/iter-fest.iteratorSome.d.ts +10 -0
- package/dist/iter-fest.iteratorSome.js +44 -0
- package/dist/iter-fest.iteratorSome.js.map +1 -0
- package/dist/iter-fest.iteratorSome.mjs +7 -0
- package/dist/iter-fest.iteratorSome.mjs.map +1 -0
- package/dist/iter-fest.iteratorTake.d.mts +12 -0
- package/dist/iter-fest.iteratorTake.d.ts +12 -0
- package/dist/iter-fest.iteratorTake.js +44 -0
- package/dist/iter-fest.iteratorTake.js.map +1 -0
- package/dist/iter-fest.iteratorTake.mjs +7 -0
- package/dist/iter-fest.iteratorTake.mjs.map +1 -0
- package/dist/iter-fest.iteratorToArray.d.mts +13 -0
- package/dist/iter-fest.iteratorToArray.d.ts +13 -0
- package/dist/iter-fest.iteratorToArray.js +44 -0
- package/dist/iter-fest.iteratorToArray.js.map +1 -0
- package/dist/iter-fest.iteratorToArray.mjs +7 -0
- package/dist/iter-fest.iteratorToArray.mjs.map +1 -0
- package/dist/iter-fest.js +164 -168
- package/dist/iter-fest.js.map +1 -1
- package/dist/iter-fest.mjs +72 -52
- package/dist/iter-fest.readableStreamFrom.d.mts +3 -0
- package/dist/iter-fest.readableStreamFrom.d.ts +3 -0
- package/dist/{iter-fest.iterableGetReadable.js → iter-fest.readableStreamFrom.js} +9 -9
- package/dist/iter-fest.readableStreamFrom.js.map +1 -0
- package/dist/iter-fest.readableStreamFrom.mjs +7 -0
- package/dist/iter-fest.readableStreamFrom.mjs.map +1 -0
- package/package.json +137 -87
- package/dist/chunk-5CRMPYKD.mjs +0 -19
- package/dist/chunk-5CRMPYKD.mjs.map +0 -1
- package/dist/chunk-6C3P4TNK.mjs +0 -19
- package/dist/chunk-6C3P4TNK.mjs.map +0 -1
- package/dist/chunk-EZC33HE6.mjs +0 -15
- package/dist/chunk-EZC33HE6.mjs.map +0 -1
- package/dist/chunk-JU353VSE.mjs +0 -16
- package/dist/chunk-JU353VSE.mjs.map +0 -1
- package/dist/chunk-MNLOWKTC.mjs +0 -19
- package/dist/chunk-MNLOWKTC.mjs.map +0 -1
- package/dist/chunk-MOBXUTO5.mjs.map +0 -1
- package/dist/chunk-O5SQJUKB.mjs +0 -37
- package/dist/chunk-O5SQJUKB.mjs.map +0 -1
- package/dist/chunk-XW34KZRY.mjs +0 -17
- package/dist/chunk-XW34KZRY.mjs.map +0 -1
- package/dist/chunk-ZUBHGSCW.mjs +0 -18
- package/dist/chunk-ZUBHGSCW.mjs.map +0 -1
- package/dist/iter-fest.iterableEvery.d.mts +0 -24
- package/dist/iter-fest.iterableEvery.d.ts +0 -24
- package/dist/iter-fest.iterableEvery.js +0 -43
- package/dist/iter-fest.iterableEvery.js.map +0 -1
- package/dist/iter-fest.iterableEvery.mjs +0 -7
- package/dist/iter-fest.iterableFilter.d.mts +0 -16
- package/dist/iter-fest.iterableFilter.d.ts +0 -16
- package/dist/iter-fest.iterableFilter.js +0 -42
- package/dist/iter-fest.iterableFilter.js.map +0 -1
- package/dist/iter-fest.iterableFilter.mjs +0 -7
- package/dist/iter-fest.iterableFind.d.mts +0 -15
- package/dist/iter-fest.iterableFind.d.ts +0 -15
- package/dist/iter-fest.iterableFind.js +0 -43
- package/dist/iter-fest.iterableFind.js.map +0 -1
- package/dist/iter-fest.iterableFind.mjs +0 -7
- package/dist/iter-fest.iterableForEach.d.mts +0 -10
- package/dist/iter-fest.iterableForEach.d.ts +0 -10
- package/dist/iter-fest.iterableForEach.js +0 -40
- package/dist/iter-fest.iterableForEach.js.map +0 -1
- package/dist/iter-fest.iterableForEach.mjs +0 -7
- package/dist/iter-fest.iterableGetReadable.d.mts +0 -3
- package/dist/iter-fest.iterableGetReadable.d.ts +0 -3
- package/dist/iter-fest.iterableGetReadable.js.map +0 -1
- package/dist/iter-fest.iterableGetReadable.mjs +0 -7
- package/dist/iter-fest.iterableMap.d.mts +0 -8
- package/dist/iter-fest.iterableMap.d.ts +0 -8
- package/dist/iter-fest.iterableMap.js +0 -39
- package/dist/iter-fest.iterableMap.js.map +0 -1
- package/dist/iter-fest.iterableMap.mjs +0 -7
- package/dist/iter-fest.iterableReduce.js +0 -41
- package/dist/iter-fest.iterableReduce.js.map +0 -1
- package/dist/iter-fest.iterableReduce.mjs +0 -7
- package/dist/iter-fest.iterableSome.d.mts +0 -12
- package/dist/iter-fest.iterableSome.d.ts +0 -12
- package/dist/iter-fest.iterableSome.js +0 -43
- package/dist/iter-fest.iterableSome.js.map +0 -1
- package/dist/iter-fest.iterableSome.mjs +0 -7
- package/dist/iter-fest.pushAsyncIterableIterator.d.mts +0 -9
- package/dist/iter-fest.pushAsyncIterableIterator.d.ts +0 -9
- package/dist/iter-fest.pushAsyncIterableIterator.js.map +0 -1
- package/dist/iter-fest.pushAsyncIterableIterator.mjs +0 -7
- /package/dist/{iter-fest.iterableEvery.mjs.map → iter-fest.iterableWritableStream.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableFilter.mjs.map → iter-fest.iteratorDrop.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableFind.mjs.map → iter-fest.iteratorEvery.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableForEach.mjs.map → iter-fest.iteratorFilter.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableGetReadable.mjs.map → iter-fest.iteratorFind.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableMap.mjs.map → iter-fest.iteratorFlatMap.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableReduce.mjs.map → iter-fest.iteratorForEach.mjs.map} +0 -0
- /package/dist/{iter-fest.iterableSome.mjs.map → iter-fest.iteratorFrom.mjs.map} +0 -0
- /package/dist/{iter-fest.pushAsyncIterableIterator.mjs.map → iter-fest.iteratorMap.mjs.map} +0 -0
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@ npm install iter-fest
|
|
|
25
25
|
| `Observable` | `ReadableStream` | [`observableSubscribeAsReadable<T>(observable: Observable<T>): ReadableStream<T>`](#converting-an-observable-to-readablestream) |
|
|
26
26
|
| `ReadableStreamDefaultReader` | `AsyncIterableIterator` | [`readerValues`<T>(reader: ReadableStreamDefaultReader<T>): AsyncIterableIterator<T>`](#converting-a-readablestreamdefaultreader-to-asynciterableiterator) |
|
|
27
27
|
| `AsyncIterable` | `Observable` | [`observableFromAsync<T>(iterable: AsyncIterable<T>): Observable<T>`](#converting-an-asynciterable-to-observable) |
|
|
28
|
-
| `AsyncIterable`/`Iterable` | `ReadableStream` | [`
|
|
28
|
+
| `AsyncIterable`/`Iterable` | `ReadableStream` | [`readableStreamFrom<T>(anyIterable: AsyncIterable<T> \| Iterable<T>): ReadableStream<T>`](#converting-an-asynciterableiterable-to-readablestream) |
|
|
29
29
|
|
|
30
30
|
To convert `Observable` to `AsyncIterableIterator`, [use `ReadableStream` as intermediate format](#converting-an-observable-to-asynciterableiterator).
|
|
31
31
|
|
|
@@ -136,14 +136,16 @@ Note: `[Symbol.asyncIterator]()` will not restart the reader and read from start
|
|
|
136
136
|
|
|
137
137
|
### Converting an `AsyncIterable`/`Iterable` to `ReadableStream`
|
|
138
138
|
|
|
139
|
+
> Notes: this feature is part of [Streams Standard](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/from_static).
|
|
140
|
+
|
|
139
141
|
```ts
|
|
140
142
|
const iterable = [1, 2, 3].values();
|
|
141
|
-
const readable =
|
|
143
|
+
const readable = readableStreamFrom(iterable);
|
|
142
144
|
|
|
143
145
|
readable.pipeTo(stream.writable); // Will write 1, 2, 3.
|
|
144
146
|
```
|
|
145
147
|
|
|
146
|
-
Note: `
|
|
148
|
+
Note: `readableStreamFrom()` will call `[Symbol.iterator]()` initially to restart the iteration where possible.
|
|
147
149
|
|
|
148
150
|
## Others
|
|
149
151
|
|
|
@@ -153,14 +155,18 @@ Note: `iterableGetReadable()` will call `[Symbol.iterator]()` initially to resta
|
|
|
153
155
|
|
|
154
156
|
### Producer-consumer queue
|
|
155
157
|
|
|
156
|
-
`
|
|
158
|
+
`IterableWritableStream` is a push-based producer-consumer queue designed to decouple the flow between a producer and multiple consumers. The producer can push a new job at anytime. The consumer can pull a job at its own convenience via for-loop.
|
|
159
|
+
|
|
160
|
+
`IterableWritableStream` supports multiple consumers and continuation:
|
|
157
161
|
|
|
158
|
-
|
|
162
|
+
- Multiple consumers: when 2 or more consumers are active at the same time, jobs will be distributed across all consumers in a round robin fashion when possible
|
|
163
|
+
- Continuation: when the last consumer disconnected while producer keep pushing new jobs, the next consumer will pick up where the last consumer left
|
|
159
164
|
|
|
160
|
-
|
|
165
|
+
Compare to pull-based queue, a push-based queue is easy to use. However, pull-based queue offers better flow control as it will produce a job only if there is a consumer ready to consume.
|
|
161
166
|
|
|
162
167
|
```ts
|
|
163
|
-
const iterable = new
|
|
168
|
+
const iterable = new IterableWritableStream();
|
|
169
|
+
const writer = iterable.getWriter();
|
|
164
170
|
|
|
165
171
|
(async function consumer() {
|
|
166
172
|
for await (const value of iterable) {
|
|
@@ -171,10 +177,10 @@ const iterable = new PushAsyncIterableIterator();
|
|
|
171
177
|
})();
|
|
172
178
|
|
|
173
179
|
(async function producer() {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
180
|
+
writer.write(1);
|
|
181
|
+
writer.write(2);
|
|
182
|
+
writer.write(3);
|
|
183
|
+
writer.close();
|
|
178
184
|
})();
|
|
179
185
|
|
|
180
186
|
// Prints "1", "2", "3", "Done".
|
|
@@ -218,22 +224,41 @@ const generator = generatorWithLastValue(
|
|
|
218
224
|
);
|
|
219
225
|
```
|
|
220
226
|
|
|
227
|
+
## Adding types to `core-js-pure`
|
|
228
|
+
|
|
229
|
+
We added types to implementation from `core-js-pure`:
|
|
230
|
+
|
|
231
|
+
- [`Iterator.drop`](https://tc39.es/ecma262/#sec-array.prototype.drop)
|
|
232
|
+
- [`Iterator.every`](https://tc39.es/ecma262/#sec-array.prototype.every)
|
|
233
|
+
- [`Iterator.filter`](https://tc39.es/ecma262/#sec-array.prototype.filter)
|
|
234
|
+
- [`Iterator.find`](https://tc39.es/ecma262/#sec-array.prototype.find)
|
|
235
|
+
- [`Iterator.flatMap`](https://tc39.es/ecma262/#sec-array.prototype.flatmap)
|
|
236
|
+
- [`Iterator.forEach`](https://tc39.es/ecma262/#sec-array.prototype.foreach)
|
|
237
|
+
- [`Iterator.from`](https://tc39.es/ecma262/#sec-array.prototype.from)
|
|
238
|
+
- [`Iterator.map`](https://tc39.es/ecma262/#sec-array.prototype.map)
|
|
239
|
+
- [`Iterator.reduce`](https://tc39.es/ecma262/#sec-array.prototype.reduce)
|
|
240
|
+
- [`Iterator.some`](https://tc39.es/ecma262/#sec-array.prototype.some)
|
|
241
|
+
- [`Iterator.take`](https://tc39.es/ecma262/#sec-array.prototype.take)
|
|
242
|
+
- [`Iterator.toArray`](https://tc39.es/ecma262/#sec-array.prototype.toarray)
|
|
243
|
+
|
|
221
244
|
## `Array.prototype` ports
|
|
222
245
|
|
|
246
|
+
> Note: we are working to move them from `iterable*` to `iterator*` to make them similar to TC39 proposals.
|
|
247
|
+
|
|
223
248
|
We ported majority of functions from `Array.prototype.*` to `iterable*`.
|
|
224
249
|
|
|
225
250
|
```ts
|
|
226
|
-
import {
|
|
227
|
-
import {
|
|
251
|
+
import { iteratorIncludes, iteratorReduce } from 'iter-fest'; // Via default exports.
|
|
252
|
+
import { iteratorSome } from 'iter-fest/iteratorSome'; // Via named exports.
|
|
228
253
|
|
|
229
|
-
const
|
|
254
|
+
const iterator: iterator<number> = [1, 2, 3, 4, 5].values();
|
|
230
255
|
|
|
231
|
-
console.log(
|
|
232
|
-
console.log(
|
|
233
|
-
console.log(
|
|
256
|
+
console.log(iteratorIncludes(iterator, 3)); // Prints "true".
|
|
257
|
+
console.log(iteratorReduce(iterator, (sum, value) => sum + value, 0)); // Prints "15".
|
|
258
|
+
console.log(iteratorSome(iterator, value => value % 2)); // Prints "true".
|
|
234
259
|
```
|
|
235
260
|
|
|
236
|
-
List of ported functions: [`at`](https://tc39.es/ecma262/#sec-array.prototype.at), [`concat`](https://tc39.es/ecma262/#sec-array.prototype.concat), [`entries`](https://tc39.es/ecma262/#sec-array.prototype.entries), [`
|
|
261
|
+
List of ported functions: [`at`](https://tc39.es/ecma262/#sec-array.prototype.at), [`concat`](https://tc39.es/ecma262/#sec-array.prototype.concat), [`entries`](https://tc39.es/ecma262/#sec-array.prototype.entries), [`findIndex`](https://tc39.es/ecma262/#sec-array.prototype.findindex), [`findLast`](https://tc39.es/ecma262/#sec-array.prototype.findlast), [`findLastIndex`](https://tc39.es/ecma262/#sec-array.prototype.findlastindex), [`includes`](https://tc39.es/ecma262/#sec-array.prototype.includes), [`indexOf`](https://tc39.es/ecma262/#sec-array.prototype.indexof), [`join`](https://tc39.es/ecma262/#sec-array.prototype.join), [`keys`](https://tc39.es/ecma262/#sec-array.prototype.keys), [`slice`](https://tc39.es/ecma262/#sec-array.prototype.slice), [`toSpliced`](https://tc39.es/ecma262/#sec-array.prototype.tospliced), and [`toString`](https://tc39.es/ecma262/#sec-array.prototype.tostring).
|
|
237
262
|
|
|
238
263
|
## Behaviors
|
|
239
264
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/iteratorSome.ts"],"sourcesContent":["// @ts-expect-error core-js-pure is not typed.\nimport some from 'core-js-pure/full/iterator/some';\n\n/**\n * Determines whether the specified callback function returns true for any element of an iterable.\n *\n * @param predicate A function that accepts up to three arguments. The some method calls the predicate function for each element in the iterable until the predicate returns a value which is coercible to the Boolean value true, or until the end of the iterable.\n *\n * @link https://github.com/tc39/proposal-iterator-helpers/blob/main/README.md\n */\nexport function iteratorSome<T>(iterator: Iterator<T>, predicate: (value: T, index: number) => unknown): boolean {\n return some(iterator, predicate);\n}\n"],"mappings":";AACA,OAAO,UAAU;AASV,SAAS,aAAgB,UAAuB,WAA0D;AAC/G,SAAO,KAAK,UAAU,SAAS;AACjC;","names":[]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// src/private/withResolvers.ts
|
|
2
|
+
import coreJSPromiseWithResolvers from "core-js-pure/full/promise/with-resolvers";
|
|
3
|
+
function withResolvers() {
|
|
4
|
+
return coreJSPromiseWithResolvers();
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
// src/iterableWritableStream.ts
|
|
8
|
+
var CLOSE = Symbol();
|
|
9
|
+
var IterableWritableStream = class extends WritableStream {
|
|
10
|
+
constructor() {
|
|
11
|
+
super({
|
|
12
|
+
close: () => {
|
|
13
|
+
this.#buffer.push(CLOSE);
|
|
14
|
+
this.#writeResolvers.resolve();
|
|
15
|
+
},
|
|
16
|
+
write: (chunk) => {
|
|
17
|
+
this.#buffer.push(chunk);
|
|
18
|
+
this.#writeResolvers.resolve();
|
|
19
|
+
this.#writeResolvers = withResolvers();
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
#buffer = [];
|
|
24
|
+
#writeResolvers = withResolvers();
|
|
25
|
+
[Symbol.asyncIterator]() {
|
|
26
|
+
return {
|
|
27
|
+
next: async () => {
|
|
28
|
+
while (!this.#buffer.length) {
|
|
29
|
+
await this.#writeResolvers.promise;
|
|
30
|
+
}
|
|
31
|
+
const value = this.#buffer[0];
|
|
32
|
+
if (value === CLOSE) {
|
|
33
|
+
return { done: true, value: void 0 };
|
|
34
|
+
}
|
|
35
|
+
this.#buffer.shift();
|
|
36
|
+
await void 0;
|
|
37
|
+
return { done: false, value };
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export {
|
|
44
|
+
IterableWritableStream
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=chunk-BWMXKULC.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/private/withResolvers.ts","../src/iterableWritableStream.ts"],"sourcesContent":["// @ts-expect-error \"core-js\" is not typed.\nimport coreJSPromiseWithResolvers from 'core-js-pure/full/promise/with-resolvers';\n\nexport default function withResolvers<T>(): PromiseWithResolvers<T> {\n return coreJSPromiseWithResolvers();\n}\n","import withResolvers from './private/withResolvers';\n\nconst CLOSE = Symbol();\n\nexport class IterableWritableStream<T> extends WritableStream<T> {\n constructor() {\n super({\n close: () => {\n this.#buffer.push(CLOSE);\n this.#writeResolvers.resolve();\n },\n write: (chunk: T) => {\n this.#buffer.push(chunk);\n this.#writeResolvers.resolve();\n this.#writeResolvers = withResolvers();\n }\n });\n }\n\n #buffer: (T | typeof CLOSE)[] = [];\n #writeResolvers: PromiseWithResolvers<void> = withResolvers();\n\n [Symbol.asyncIterator](): AsyncIterator<T> {\n return {\n next: async () => {\n while (!this.#buffer.length) {\n await this.#writeResolvers.promise;\n }\n\n const value = this.#buffer[0] as T | typeof CLOSE;\n\n if (value === CLOSE) {\n return { done: true, value: undefined };\n }\n\n // If it is not CLOSE, remove it from the queue.\n this.#buffer.shift();\n\n // Idle here so concurrent iteration has a chance to pick up the next value in a round robin fashion.\n await undefined;\n\n return { done: false, value };\n }\n };\n }\n}\n"],"mappings":";AACA,OAAO,gCAAgC;AAExB,SAAR,gBAA6D;AAClE,SAAO,2BAA2B;AACpC;;;ACHA,IAAM,QAAQ,OAAO;AAEd,IAAM,yBAAN,cAAwC,eAAkB;AAAA,EAC/D,cAAc;AACZ,UAAM;AAAA,MACJ,OAAO,MAAM;AACX,aAAK,QAAQ,KAAK,KAAK;AACvB,aAAK,gBAAgB,QAAQ;AAAA,MAC/B;AAAA,MACA,OAAO,CAAC,UAAa;AACnB,aAAK,QAAQ,KAAK,KAAK;AACvB,aAAK,gBAAgB,QAAQ;AAC7B,aAAK,kBAAkB,cAAc;AAAA,MACvC;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEA,UAAgC,CAAC;AAAA,EACjC,kBAA8C,cAAc;AAAA,EAE5D,CAAC,OAAO,aAAa,IAAsB;AACzC,WAAO;AAAA,MACL,MAAM,YAAY;AAChB,eAAO,CAAC,KAAK,QAAQ,QAAQ;AAC3B,gBAAM,KAAK,gBAAgB;AAAA,QAC7B;AAEA,cAAM,QAAQ,KAAK,QAAQ,CAAC;AAE5B,YAAI,UAAU,OAAO;AACnB,iBAAO,EAAE,MAAM,MAAM,OAAO,OAAU;AAAA,QACxC;AAGA,aAAK,QAAQ,MAAM;AAGnB,cAAM;AAEN,eAAO,EAAE,MAAM,OAAO,MAAM;AAAA,MAC9B;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/iteratorFind.ts"],"sourcesContent":["// @ts-expect-error core-js-pure is not typed.\nimport find from 'core-js-pure/full/iterator/find';\n\n/**\n * Returns the value of the first element in the iterator where predicate is true, and undefined\n * otherwise.\n *\n * @param predicate find calls predicate once for each element of the iterator, in ascending\n * order, until it finds one where predicate returns true. If such an element is found, find\n * immediately returns that element value. Otherwise, find returns undefined.\n *\n * @link https://github.com/tc39/proposal-iterator-helpers/blob/main/README.md\n */\nexport function iteratorFind<T, S extends T>(\n iterator: Iterator<T>,\n predicate: (value: T, index: number) => value is S\n): S | undefined;\n\nexport function iteratorFind<T>(iterator: Iterator<T>, predicate: (value: T, index: number) => unknown): T | undefined;\n\nexport function iteratorFind<T, S extends T>(\n iterator: Iterator<T>,\n predicate: (value: T, index: number) => unknown\n): S | undefined {\n return find(iterator, predicate);\n}\n"],"mappings":";AACA,OAAO,UAAU;AAmBV,SAAS,aACd,UACA,WACe;AACf,SAAO,KAAK,UAAU,SAAS;AACjC;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/iteratorForEach.ts"],"sourcesContent":["// @ts-expect-error core-js-pure is not typed.\nimport forEach from 'core-js-pure/full/iterator/for-each';\n\n/**\n * Performs the specified action for each element in an iterator.\n *\n * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the iterator.\n *\n * @link https://github.com/tc39/proposal-iterator-helpers/blob/main/README.md\n */\nexport function iteratorForEach<T>(iterator: Iterator<T>, callbackfn: (value: T, index: number) => void): void {\n forEach(iterator, callbackfn);\n}\n"],"mappings":";AACA,OAAO,aAAa;AASb,SAAS,gBAAmB,UAAuB,YAAqD;AAC7G,UAAQ,UAAU,UAAU;AAC9B;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/iteratorFrom.ts"],"sourcesContent":["// @ts-expect-error core-js-pure is not typed.\nimport from from 'core-js-pure/full/iterator/from';\n\n/**\n * `.from` is a static method (unlike the others listed above) which takes an object as an argument. This method allows wrapping \"iterator-like\" objects with an iterator.\n *\n * @param limit\n *\n * @return Returns the object if it is already an iterator, returns a wrapping iterator if the passed object implements a callable @@iterator property.\n *\n * @link https://github.com/tc39/proposal-iterator-helpers/blob/main/README.md\n */\nexport function iteratorFrom<T>(iteratorLike: Iterator<T>): Iterator<T> {\n return from(iteratorLike);\n}\n"],"mappings":";AACA,OAAO,UAAU;AAWV,SAAS,aAAgB,cAAwC;AACtE,SAAO,KAAK,YAAY;AAC1B;","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// src/iteratorReduce.ts
|
|
2
|
+
import reduce from "core-js-pure/full/iterator/reduce";
|
|
3
|
+
function iteratorReduce(iterator, callbackfn, initialValue) {
|
|
4
|
+
return reduce(iterator, callbackfn, initialValue);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export {
|
|
8
|
+
iteratorReduce
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=chunk-LIMQXDFK.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/iteratorReduce.ts"],"sourcesContent":["// @ts-expect-error core-js-pure is not typed.\nimport reduce from 'core-js-pure/full/iterator/reduce';\n\n/**\n * Calls the specified callback function for all the elements in an iterator. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.\n *\n * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the iterator.\n *\n * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an iterator value.\n *\n * @link https://github.com/tc39/proposal-iterator-helpers/blob/main/README.md\n */\nexport function iteratorReduce<T>(\n iterator: Iterator<T>,\n callbackfn: (previousValue: T, currentValue: T, currentIndex: number) => T\n): T;\n\nexport function iteratorReduce<T>(\n iterator: Iterator<T>,\n callbackfn: (previousValue: T, currentValue: T, currentIndex: number) => T,\n initialValue: T\n): T;\n\n/**\n * Calls the specified callback function for all the elements in an iterator. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.\n *\n * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the iterator.\n *\n * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.\n *\n * @link https://github.com/tc39/proposal-iterator-helpers/blob/main/README.md\n */\nexport function iteratorReduce<T, U>(\n iterator: Iterator<T>,\n callbackfn: (previousValue: U, currentValue: T, currentIndex: number) => U,\n initialValue: U\n): U;\n\nexport function iteratorReduce<T, U = undefined>(\n iterator: Iterator<T>,\n callbackfn: (previousValue: U | undefined, currentValue: T, currentIndex: number) => U,\n initialValue?: U\n): U | undefined {\n return reduce(iterator, callbackfn, initialValue);\n}\n"],"mappings":";AACA,OAAO,YAAY;AAqCZ,SAAS,eACd,UACA,YACA,cACe;AACf,SAAO,OAAO,UAAU,YAAY,YAAY;AAClD;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/iteratorEvery.ts"],"sourcesContent":["// @ts-expect-error core-js-pure is not typed.\nimport every from 'core-js-pure/full/iterator/every';\n\n/**\n * Determines whether all the members of an iterator satisfy the specified test.\n *\n * @param predicate A function that accepts up to three arguments. The every method calls\n * the predicate function for each element in the iterator until the predicate returns a value\n * which is coercible to the Boolean value false, or until the end of the iterator.\n *\n * @link https://github.com/tc39/proposal-iterator-helpers/blob/main/README.md\n */\nexport function iteratorEvery<T, S extends T>(\n iterator: Iterator<T>,\n predicate: (value: T, index: number) => value is S\n): iterator is Iterator<S>;\n\n/**\n * Determines whether all the members of an iterator satisfy the specified test.\n *\n * @param predicate A function that accepts up to three arguments. The every method calls\n * the predicate function for each element in the iterator until the predicate returns a value\n * which is coercible to the Boolean value false, or until the end of the iterator.\n *\n * @param thisArg An object to which the this keyword can refer in the predicate function.\n * If thisArg is omitted, undefined is used as the this value.\n *\n * @link https://github.com/tc39/proposal-iterator-helpers/blob/main/README.md\n */\nexport function iteratorEvery<T>(iterator: Iterator<T>, predicate: (value: T, index: number) => unknown): boolean;\n\nexport function iteratorEvery<T>(iterator: Iterator<T>, predicate: (value: T, index: number) => unknown): boolean {\n return every(iterator, predicate);\n}\n"],"mappings":";AACA,OAAO,WAAW;AA8BX,SAAS,cAAiB,UAAuB,WAA0D;AAChH,SAAO,MAAM,UAAU,SAAS;AAClC;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/iteratorFlatMap.ts"],"sourcesContent":["// @ts-expect-error core-js-pure is not typed.\nimport flatMap from 'core-js-pure/full/iterator/flat-map';\n\n/**\n * `.flatMap` takes a mapping function as an argument. It returns an iterator that produces all elements of the iterators produced by applying the mapping function to the elements produced by the underlying iterator.\n *\n * @param mapperFn\n *\n * @return Returns an iterator of flat values.\n *\n * @link https://github.com/tc39/proposal-iterator-helpers/blob/main/README.md\n */\nexport function iteratorFlatMap<T, U>(iterable: Iterable<T>, mapperFn: (value: T, index: number) => U): Iterator<T> {\n return flatMap(iterable, mapperFn);\n}\n"],"mappings":";AACA,OAAO,aAAa;AAWb,SAAS,gBAAsB,UAAuB,UAAuD;AAClH,SAAO,QAAQ,UAAU,QAAQ;AACnC;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/iteratorDrop.ts"],"sourcesContent":["// @ts-expect-error core-js-pure is not typed.\nimport drop from 'core-js-pure/full/iterator/drop';\n\n/**\n * `drop` takes an integer as an argument. It skips the given number of elements produced by the underlying iterator before itself producing any remaining elements.\n *\n * @param limit\n *\n * @return Returns an iterator of items after the limit.\n *\n * @link https://github.com/tc39/proposal-iterator-helpers/blob/main/README.md\n */\nexport function iteratorDrop<T>(iterator: Iterator<T>, limit: number): Iterator<T> {\n return drop(iterator, limit);\n}\n"],"mappings":";AACA,OAAO,UAAU;AAWV,SAAS,aAAgB,UAAuB,OAA4B;AACjF,SAAO,KAAK,UAAU,KAAK;AAC7B;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/iteratorFilter.ts"],"sourcesContent":["// @ts-expect-error core-js-pure is not typed.\nimport filter from 'core-js-pure/full/iterator/filter';\n\n/**\n * Returns the elements of an iterator that meet the condition specified in a callback function.\n *\n * @param predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the iterator.\n *\n * @link https://github.com/tc39/proposal-iterator-helpers/blob/main/README.md\n */\nexport function iteratorFilter<T, S extends T>(\n iterator: Iterator<T>,\n predicate: (value: T, index: number) => value is S\n): IterableIterator<S>;\n\n/**\n * Returns the elements of an iterator that meet the condition specified in a callback function.\n *\n * @param predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the iterator.\n *\n * @link https://github.com/tc39/proposal-iterator-helpers/blob/main/README.md\n */\nexport function iteratorFilter<T>(\n iterator: Iterator<T>,\n predicate: (value: T, index: number) => unknown\n): IterableIterator<T>;\n\nexport function iteratorFilter<T, S extends T>(\n iterator: Iterator<T>,\n predicate: (value: T, index: number) => unknown\n): IterableIterator<S> {\n return filter(iterator, predicate);\n}\n"],"mappings":";AACA,OAAO,YAAY;AA0BZ,SAAS,eACd,UACA,WACqB;AACrB,SAAO,OAAO,UAAU,SAAS;AACnC;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/iteratorTake.ts"],"sourcesContent":["// @ts-expect-error core-js-pure is not typed.\nimport take from 'core-js-pure/full/iterator/take';\n\n/**\n * `take` takes an integer as an argument. It returns an iterator that produces, at most, the given number of elements produced by the underlying iterator.\n *\n * @param limit\n *\n * @return Returns an iterator with items from the original iterator from 0 until the limit.\n *\n * @link https://github.com/tc39/proposal-iterator-helpers/blob/main/README.md\n */\nexport function iteratorTake<T>(iterator: Iterator<T>, limit: number): Iterator<T> {\n return take(iterator, limit);\n}\n"],"mappings":";AACA,OAAO,UAAU;AAWV,SAAS,aAAgB,UAAuB,OAA4B;AACjF,SAAO,KAAK,UAAU,KAAK;AAC7B;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/iteratorMap.ts"],"sourcesContent":["// @ts-expect-error core-js-pure is not typed.\nimport map from 'core-js-pure/full/iterator/map';\n\n/**\n * Calls a defined callback function on each element of an array, and returns an array that contains the results.\n *\n * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.\n *\n * @link https://github.com/tc39/proposal-iterator-helpers/blob/main/README.md\n */\nexport function iteratorMap<T, U>(\n iterator: Iterator<T>,\n callbackfn: (value: T, index: number) => U\n): IterableIterator<U> {\n return map(iterator, callbackfn);\n}\n"],"mappings":";AACA,OAAO,SAAS;AAST,SAAS,YACd,UACA,YACqB;AACrB,SAAO,IAAI,UAAU,UAAU;AACjC;","names":[]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
// src/
|
|
1
|
+
// src/readableStreamFrom.ts
|
|
2
2
|
function isIterable(iterable) {
|
|
3
3
|
return !!(iterable && typeof iterable === "object" && Symbol.iterator in iterable);
|
|
4
4
|
}
|
|
5
|
-
function
|
|
6
|
-
const iterator = isIterable(
|
|
5
|
+
function readableStreamFrom(anyIterable) {
|
|
6
|
+
const iterator = isIterable(anyIterable) ? anyIterable[Symbol.iterator]() : anyIterable[Symbol.asyncIterator]();
|
|
7
7
|
return new ReadableStream({
|
|
8
8
|
async pull(controller) {
|
|
9
9
|
const result = await iterator.next();
|
|
@@ -17,6 +17,6 @@ function iterableGetReadable(iterable) {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export {
|
|
20
|
-
|
|
20
|
+
readableStreamFrom
|
|
21
21
|
};
|
|
22
|
-
//# sourceMappingURL=chunk-
|
|
22
|
+
//# sourceMappingURL=chunk-YJSIVBF7.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/readableStreamFrom.ts"],"sourcesContent":["function isIterable(iterable: unknown): iterable is Iterable<unknown> {\n return !!(iterable && typeof iterable === 'object' && Symbol.iterator in iterable);\n}\n\nexport function readableStreamFrom<T>(anyIterable: AsyncIterable<T> | Iterable<T>): ReadableStream<T> {\n const iterator = isIterable(anyIterable) ? anyIterable[Symbol.iterator]() : anyIterable[Symbol.asyncIterator]();\n\n return new ReadableStream({\n async pull(controller) {\n const result = await iterator.next();\n\n if (result.done) {\n controller.close();\n } else {\n controller.enqueue(result.value);\n }\n }\n });\n}\n"],"mappings":";AAAA,SAAS,WAAW,UAAkD;AACpE,SAAO,CAAC,EAAE,YAAY,OAAO,aAAa,YAAY,OAAO,YAAY;AAC3E;AAEO,SAAS,mBAAsB,aAAgE;AACpG,QAAM,WAAW,WAAW,WAAW,IAAI,YAAY,OAAO,QAAQ,EAAE,IAAI,YAAY,OAAO,aAAa,EAAE;AAE9G,SAAO,IAAI,eAAe;AAAA,IACxB,MAAM,KAAK,YAAY;AACrB,YAAM,SAAS,MAAM,SAAS,KAAK;AAEnC,UAAI,OAAO,MAAM;AACf,mBAAW,MAAM;AAAA,MACnB,OAAO;AACL,mBAAW,QAAQ,OAAO,KAAK;AAAA,MACjC;AAAA,IACF;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/iteratorToArray.ts"],"sourcesContent":["// @ts-expect-error core-js-pure is not typed.\nimport toArray from 'core-js-pure/full/iterator/to-array';\n\ntype IteratorLike<T> = Pick<Iterator<T>, 'next'>;\n\n/**\n * When you have a non-infinite iterator which you wish to transform into an array, you can do so with the builtin toArray method.\n *\n * @param limit\n *\n * @return Returns an Array containing the values from the iterator.\n *\n * @link https://github.com/tc39/proposal-iterator-helpers/blob/main/README.md\n */\nexport function iteratorToArray<T>(iteratorLike: IteratorLike<T>): T[] {\n return toArray(iteratorLike);\n}\n"],"mappings":";AACA,OAAO,aAAa;AAab,SAAS,gBAAmB,cAAoC;AACrE,SAAO,QAAQ,YAAY;AAC7B;","names":[]}
|
package/dist/iter-fest.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { CompleteFunction, ErrorFunction, NextFunction, Observable, Observer, StartFunction, SubscriberFunction, Subscription, SubscriptionObserver } from './iter-fest.observable.mjs';
|
|
2
|
-
export { PushAsyncIterableIterator } from './iter-fest.pushAsyncIterableIterator.mjs';
|
|
3
2
|
export { SymbolObservable } from './iter-fest.symbolObservable.mjs';
|
|
4
3
|
export { AsyncGeneratorWithLastValue, asyncGeneratorWithLastValue } from './iter-fest.asyncGeneratorWithLastValue.mjs';
|
|
5
4
|
export { asyncIteratorToAsyncIterable } from './iter-fest.asyncIteratorToAsyncIterable.mjs';
|
|
@@ -7,26 +6,32 @@ export { GeneratorWithLastValue, generatorWithLastValue } from './iter-fest.gene
|
|
|
7
6
|
export { iterableAt } from './iter-fest.iterableAt.mjs';
|
|
8
7
|
export { iterableConcat } from './iter-fest.iterableConcat.mjs';
|
|
9
8
|
export { iterableEntries } from './iter-fest.iterableEntries.mjs';
|
|
10
|
-
export { iterableEvery } from './iter-fest.iterableEvery.mjs';
|
|
11
|
-
export { iterableFilter } from './iter-fest.iterableFilter.mjs';
|
|
12
|
-
export { iterableFind } from './iter-fest.iterableFind.mjs';
|
|
13
9
|
export { iterableFindIndex } from './iter-fest.iterableFindIndex.mjs';
|
|
14
10
|
export { iterableFindLast } from './iter-fest.iterableFindLast.mjs';
|
|
15
11
|
export { iterableFindLastIndex } from './iter-fest.iterableFindLastIndex.mjs';
|
|
16
|
-
export { iterableForEach } from './iter-fest.iterableForEach.mjs';
|
|
17
|
-
export { iterableGetReadable } from './iter-fest.iterableGetReadable.mjs';
|
|
18
12
|
export { iterableIncludes } from './iter-fest.iterableIncludes.mjs';
|
|
19
13
|
export { iterableIndexOf } from './iter-fest.iterableIndexOf.mjs';
|
|
20
14
|
export { iterableJoin } from './iter-fest.iterableJoin.mjs';
|
|
21
15
|
export { iterableKeys } from './iter-fest.iterableKeys.mjs';
|
|
22
|
-
export { iterableMap } from './iter-fest.iterableMap.mjs';
|
|
23
|
-
export { iterableReduce } from './iter-fest.iterableReduce.mjs';
|
|
24
16
|
export { iterableSlice } from './iter-fest.iterableSlice.mjs';
|
|
25
|
-
export { iterableSome } from './iter-fest.iterableSome.mjs';
|
|
26
17
|
export { iterableToSpliced } from './iter-fest.iterableToSpliced.mjs';
|
|
27
18
|
export { iterableToString } from './iter-fest.iterableToString.mjs';
|
|
19
|
+
export { IterableWritableStream } from './iter-fest.iterableWritableStream.mjs';
|
|
20
|
+
export { iteratorDrop } from './iter-fest.iteratorDrop.mjs';
|
|
21
|
+
export { iteratorEvery } from './iter-fest.iteratorEvery.mjs';
|
|
22
|
+
export { iteratorFilter } from './iter-fest.iteratorFilter.mjs';
|
|
23
|
+
export { iteratorFind } from './iter-fest.iteratorFind.mjs';
|
|
24
|
+
export { iteratorFlatMap } from './iter-fest.iteratorFlatMap.mjs';
|
|
25
|
+
export { iteratorForEach } from './iter-fest.iteratorForEach.mjs';
|
|
26
|
+
export { iteratorFrom } from './iter-fest.iteratorFrom.mjs';
|
|
27
|
+
export { iteratorMap } from './iter-fest.iteratorMap.mjs';
|
|
28
|
+
export { iteratorReduce } from './iter-fest.iteratorReduce.mjs';
|
|
29
|
+
export { iteratorSome } from './iter-fest.iteratorSome.mjs';
|
|
30
|
+
export { iteratorTake } from './iter-fest.iteratorTake.mjs';
|
|
31
|
+
export { iteratorToArray } from './iter-fest.iteratorToArray.mjs';
|
|
28
32
|
export { iteratorToIterable } from './iter-fest.iteratorToIterable.mjs';
|
|
29
33
|
export { observableFromAsync } from './iter-fest.observableFromAsync.mjs';
|
|
30
34
|
export { observableSubscribeAsReadable } from './iter-fest.observableSubscribeAsReadable.mjs';
|
|
35
|
+
export { readableStreamFrom } from './iter-fest.readableStreamFrom.mjs';
|
|
31
36
|
export { readerValues } from './iter-fest.readerValues.mjs';
|
|
32
37
|
import 'core-js-pure/full/observable';
|
package/dist/iter-fest.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { CompleteFunction, ErrorFunction, NextFunction, Observable, Observer, StartFunction, SubscriberFunction, Subscription, SubscriptionObserver } from './iter-fest.observable.js';
|
|
2
|
-
export { PushAsyncIterableIterator } from './iter-fest.pushAsyncIterableIterator.js';
|
|
3
2
|
export { SymbolObservable } from './iter-fest.symbolObservable.js';
|
|
4
3
|
export { AsyncGeneratorWithLastValue, asyncGeneratorWithLastValue } from './iter-fest.asyncGeneratorWithLastValue.js';
|
|
5
4
|
export { asyncIteratorToAsyncIterable } from './iter-fest.asyncIteratorToAsyncIterable.js';
|
|
@@ -7,26 +6,32 @@ export { GeneratorWithLastValue, generatorWithLastValue } from './iter-fest.gene
|
|
|
7
6
|
export { iterableAt } from './iter-fest.iterableAt.js';
|
|
8
7
|
export { iterableConcat } from './iter-fest.iterableConcat.js';
|
|
9
8
|
export { iterableEntries } from './iter-fest.iterableEntries.js';
|
|
10
|
-
export { iterableEvery } from './iter-fest.iterableEvery.js';
|
|
11
|
-
export { iterableFilter } from './iter-fest.iterableFilter.js';
|
|
12
|
-
export { iterableFind } from './iter-fest.iterableFind.js';
|
|
13
9
|
export { iterableFindIndex } from './iter-fest.iterableFindIndex.js';
|
|
14
10
|
export { iterableFindLast } from './iter-fest.iterableFindLast.js';
|
|
15
11
|
export { iterableFindLastIndex } from './iter-fest.iterableFindLastIndex.js';
|
|
16
|
-
export { iterableForEach } from './iter-fest.iterableForEach.js';
|
|
17
|
-
export { iterableGetReadable } from './iter-fest.iterableGetReadable.js';
|
|
18
12
|
export { iterableIncludes } from './iter-fest.iterableIncludes.js';
|
|
19
13
|
export { iterableIndexOf } from './iter-fest.iterableIndexOf.js';
|
|
20
14
|
export { iterableJoin } from './iter-fest.iterableJoin.js';
|
|
21
15
|
export { iterableKeys } from './iter-fest.iterableKeys.js';
|
|
22
|
-
export { iterableMap } from './iter-fest.iterableMap.js';
|
|
23
|
-
export { iterableReduce } from './iter-fest.iterableReduce.js';
|
|
24
16
|
export { iterableSlice } from './iter-fest.iterableSlice.js';
|
|
25
|
-
export { iterableSome } from './iter-fest.iterableSome.js';
|
|
26
17
|
export { iterableToSpliced } from './iter-fest.iterableToSpliced.js';
|
|
27
18
|
export { iterableToString } from './iter-fest.iterableToString.js';
|
|
19
|
+
export { IterableWritableStream } from './iter-fest.iterableWritableStream.js';
|
|
20
|
+
export { iteratorDrop } from './iter-fest.iteratorDrop.js';
|
|
21
|
+
export { iteratorEvery } from './iter-fest.iteratorEvery.js';
|
|
22
|
+
export { iteratorFilter } from './iter-fest.iteratorFilter.js';
|
|
23
|
+
export { iteratorFind } from './iter-fest.iteratorFind.js';
|
|
24
|
+
export { iteratorFlatMap } from './iter-fest.iteratorFlatMap.js';
|
|
25
|
+
export { iteratorForEach } from './iter-fest.iteratorForEach.js';
|
|
26
|
+
export { iteratorFrom } from './iter-fest.iteratorFrom.js';
|
|
27
|
+
export { iteratorMap } from './iter-fest.iteratorMap.js';
|
|
28
|
+
export { iteratorReduce } from './iter-fest.iteratorReduce.js';
|
|
29
|
+
export { iteratorSome } from './iter-fest.iteratorSome.js';
|
|
30
|
+
export { iteratorTake } from './iter-fest.iteratorTake.js';
|
|
31
|
+
export { iteratorToArray } from './iter-fest.iteratorToArray.js';
|
|
28
32
|
export { iteratorToIterable } from './iter-fest.iteratorToIterable.js';
|
|
29
33
|
export { observableFromAsync } from './iter-fest.observableFromAsync.js';
|
|
30
34
|
export { observableSubscribeAsReadable } from './iter-fest.observableSubscribeAsReadable.js';
|
|
35
|
+
export { readableStreamFrom } from './iter-fest.readableStreamFrom.js';
|
|
31
36
|
export { readerValues } from './iter-fest.readerValues.js';
|
|
32
37
|
import 'core-js-pure/full/observable';
|
|
@@ -27,12 +27,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
|
|
30
|
-
// src/
|
|
31
|
-
var
|
|
32
|
-
__export(
|
|
33
|
-
|
|
30
|
+
// src/iterableWritableStream.ts
|
|
31
|
+
var iterableWritableStream_exports = {};
|
|
32
|
+
__export(iterableWritableStream_exports, {
|
|
33
|
+
IterableWritableStream: () => IterableWritableStream
|
|
34
34
|
});
|
|
35
|
-
module.exports = __toCommonJS(
|
|
35
|
+
module.exports = __toCommonJS(iterableWritableStream_exports);
|
|
36
36
|
|
|
37
37
|
// src/private/withResolvers.ts
|
|
38
38
|
var import_with_resolvers = __toESM(require("core-js-pure/full/promise/with-resolvers"));
|
|
@@ -40,34 +40,43 @@ function withResolvers() {
|
|
|
40
40
|
return (0, import_with_resolvers.default)();
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
// src/
|
|
44
|
-
var CLOSE = Symbol(
|
|
45
|
-
var
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
43
|
+
// src/iterableWritableStream.ts
|
|
44
|
+
var CLOSE = Symbol();
|
|
45
|
+
var IterableWritableStream = class extends WritableStream {
|
|
46
|
+
constructor() {
|
|
47
|
+
super({
|
|
48
|
+
close: () => {
|
|
49
|
+
this.#buffer.push(CLOSE);
|
|
50
|
+
this.#writeResolvers.resolve();
|
|
51
|
+
},
|
|
52
|
+
write: (chunk) => {
|
|
53
|
+
this.#buffer.push(chunk);
|
|
54
|
+
this.#writeResolvers.resolve();
|
|
55
|
+
this.#writeResolvers = withResolvers();
|
|
56
|
+
}
|
|
57
|
+
});
|
|
54
58
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
59
|
+
#buffer = [];
|
|
60
|
+
#writeResolvers = withResolvers();
|
|
61
|
+
[Symbol.asyncIterator]() {
|
|
62
|
+
return {
|
|
63
|
+
next: async () => {
|
|
64
|
+
while (!this.#buffer.length) {
|
|
65
|
+
await this.#writeResolvers.promise;
|
|
66
|
+
}
|
|
67
|
+
const value = this.#buffer[0];
|
|
68
|
+
if (value === CLOSE) {
|
|
69
|
+
return { done: true, value: void 0 };
|
|
70
|
+
}
|
|
71
|
+
this.#buffer.shift();
|
|
72
|
+
await void 0;
|
|
73
|
+
return { done: false, value };
|
|
74
|
+
}
|
|
75
|
+
};
|
|
67
76
|
}
|
|
68
77
|
};
|
|
69
78
|
// Annotate the CommonJS export names for ESM import in node:
|
|
70
79
|
0 && (module.exports = {
|
|
71
|
-
|
|
80
|
+
IterableWritableStream
|
|
72
81
|
});
|
|
73
|
-
//# sourceMappingURL=iter-fest.
|
|
82
|
+
//# sourceMappingURL=iter-fest.iterableWritableStream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/iterableWritableStream.ts","../src/private/withResolvers.ts"],"sourcesContent":["import withResolvers from './private/withResolvers';\n\nconst CLOSE = Symbol();\n\nexport class IterableWritableStream<T> extends WritableStream<T> {\n constructor() {\n super({\n close: () => {\n this.#buffer.push(CLOSE);\n this.#writeResolvers.resolve();\n },\n write: (chunk: T) => {\n this.#buffer.push(chunk);\n this.#writeResolvers.resolve();\n this.#writeResolvers = withResolvers();\n }\n });\n }\n\n #buffer: (T | typeof CLOSE)[] = [];\n #writeResolvers: PromiseWithResolvers<void> = withResolvers();\n\n [Symbol.asyncIterator](): AsyncIterator<T> {\n return {\n next: async () => {\n while (!this.#buffer.length) {\n await this.#writeResolvers.promise;\n }\n\n const value = this.#buffer[0] as T | typeof CLOSE;\n\n if (value === CLOSE) {\n return { done: true, value: undefined };\n }\n\n // If it is not CLOSE, remove it from the queue.\n this.#buffer.shift();\n\n // Idle here so concurrent iteration has a chance to pick up the next value in a round robin fashion.\n await undefined;\n\n return { done: false, value };\n }\n };\n }\n}\n","// @ts-expect-error \"core-js\" is not typed.\nimport coreJSPromiseWithResolvers from 'core-js-pure/full/promise/with-resolvers';\n\nexport default function withResolvers<T>(): PromiseWithResolvers<T> {\n return coreJSPromiseWithResolvers();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,4BAAuC;AAExB,SAAR,gBAA6D;AAClE,aAAO,sBAAAA,SAA2B;AACpC;;;ADHA,IAAM,QAAQ,OAAO;AAEd,IAAM,yBAAN,cAAwC,eAAkB;AAAA,EAC/D,cAAc;AACZ,UAAM;AAAA,MACJ,OAAO,MAAM;AACX,aAAK,QAAQ,KAAK,KAAK;AACvB,aAAK,gBAAgB,QAAQ;AAAA,MAC/B;AAAA,MACA,OAAO,CAAC,UAAa;AACnB,aAAK,QAAQ,KAAK,KAAK;AACvB,aAAK,gBAAgB,QAAQ;AAC7B,aAAK,kBAAkB,cAAc;AAAA,MACvC;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEA,UAAgC,CAAC;AAAA,EACjC,kBAA8C,cAAc;AAAA,EAE5D,CAAC,OAAO,aAAa,IAAsB;AACzC,WAAO;AAAA,MACL,MAAM,YAAY;AAChB,eAAO,CAAC,KAAK,QAAQ,QAAQ;AAC3B,gBAAM,KAAK,gBAAgB;AAAA,QAC7B;AAEA,cAAM,QAAQ,KAAK,QAAQ,CAAC;AAE5B,YAAI,UAAU,OAAO;AACnB,iBAAO,EAAE,MAAM,MAAM,OAAO,OAAU;AAAA,QACxC;AAGA,aAAK,QAAQ,MAAM;AAGnB,cAAM;AAEN,eAAO,EAAE,MAAM,OAAO,MAAM;AAAA,MAC9B;AAAA,IACF;AAAA,EACF;AACF;","names":["coreJSPromiseWithResolvers"]}
|