iter-fest 0.1.1-main.22b897b → 0.1.1-main.2a21293

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/README.md +134 -35
  2. package/dist/chunk-2DE3J4J7.mjs +35 -0
  3. package/dist/chunk-2DE3J4J7.mjs.map +1 -0
  4. package/dist/chunk-ANRVAYLW.mjs +35 -0
  5. package/dist/chunk-ANRVAYLW.mjs.map +1 -0
  6. package/dist/chunk-EIIP7YWB.mjs +27 -0
  7. package/dist/chunk-EIIP7YWB.mjs.map +1 -0
  8. package/dist/{chunk-2HLJODU3.mjs → chunk-EUVK4YM7.mjs} +8 -4
  9. package/dist/chunk-EUVK4YM7.mjs.map +1 -0
  10. package/dist/chunk-MOBXUTO5.mjs +22 -0
  11. package/dist/chunk-MOBXUTO5.mjs.map +1 -0
  12. package/dist/{chunk-K5XV4W7G.mjs → chunk-O5SQJUKB.mjs} +6 -4
  13. package/dist/chunk-O5SQJUKB.mjs.map +1 -0
  14. package/dist/chunk-P4OSZLEH.mjs +15 -0
  15. package/dist/chunk-P4OSZLEH.mjs.map +1 -0
  16. package/dist/iter-fest.asyncGeneratorWithLastValue.d.mts +6 -0
  17. package/dist/iter-fest.asyncGeneratorWithLastValue.d.ts +6 -0
  18. package/dist/iter-fest.asyncGeneratorWithLastValue.js +59 -0
  19. package/dist/iter-fest.asyncGeneratorWithLastValue.js.map +1 -0
  20. package/dist/iter-fest.asyncGeneratorWithLastValue.mjs +7 -0
  21. package/dist/iter-fest.asyncIteratorToAsyncIterable.d.mts +3 -0
  22. package/dist/iter-fest.asyncIteratorToAsyncIterable.d.ts +3 -0
  23. package/dist/iter-fest.asyncIteratorToAsyncIterable.js +39 -0
  24. package/dist/iter-fest.asyncIteratorToAsyncIterable.js.map +1 -0
  25. package/dist/iter-fest.asyncIteratorToAsyncIterable.mjs +7 -0
  26. package/dist/iter-fest.d.mts +6 -2
  27. package/dist/iter-fest.d.ts +6 -2
  28. package/dist/iter-fest.generatorWithLastValue.d.mts +6 -0
  29. package/dist/iter-fest.generatorWithLastValue.d.ts +6 -0
  30. package/dist/iter-fest.generatorWithLastValue.js +59 -0
  31. package/dist/iter-fest.generatorWithLastValue.js.map +1 -0
  32. package/dist/iter-fest.generatorWithLastValue.mjs +7 -0
  33. package/dist/iter-fest.generatorWithLastValue.mjs.map +1 -0
  34. package/dist/iter-fest.iterableGetReadable.d.mts +3 -0
  35. package/dist/iter-fest.iterableGetReadable.d.ts +3 -0
  36. package/dist/iter-fest.iterableGetReadable.js +46 -0
  37. package/dist/iter-fest.iterableGetReadable.js.map +1 -0
  38. package/dist/iter-fest.iterableGetReadable.mjs +7 -0
  39. package/dist/iter-fest.iterableGetReadable.mjs.map +1 -0
  40. package/dist/iter-fest.js +127 -55
  41. package/dist/iter-fest.js.map +1 -1
  42. package/dist/iter-fest.mjs +53 -38
  43. package/dist/{iter-fest.observableValues.d.mts → iter-fest.observableSubscribeAsReadable.d.mts} +2 -2
  44. package/dist/{iter-fest.observableValues.d.ts → iter-fest.observableSubscribeAsReadable.d.ts} +2 -2
  45. package/dist/iter-fest.observableSubscribeAsReadable.js +51 -0
  46. package/dist/iter-fest.observableSubscribeAsReadable.js.map +1 -0
  47. package/dist/iter-fest.observableSubscribeAsReadable.mjs +7 -0
  48. package/dist/iter-fest.observableSubscribeAsReadable.mjs.map +1 -0
  49. package/dist/iter-fest.pushAsyncIterableIterator.mjs +1 -2
  50. package/dist/iter-fest.readerValues.d.mts +3 -0
  51. package/dist/iter-fest.readerValues.d.ts +3 -0
  52. package/dist/{iter-fest.readerToAsyncIterableIterator.js → iter-fest.readerValues.js} +12 -8
  53. package/dist/iter-fest.readerValues.js.map +1 -0
  54. package/dist/iter-fest.readerValues.mjs +7 -0
  55. package/dist/iter-fest.readerValues.mjs.map +1 -0
  56. package/package.json +52 -12
  57. package/dist/chunk-2HLJODU3.mjs.map +0 -1
  58. package/dist/chunk-4LRYDU2Y.mjs +0 -62
  59. package/dist/chunk-4LRYDU2Y.mjs.map +0 -1
  60. package/dist/chunk-K5XV4W7G.mjs.map +0 -1
  61. package/dist/chunk-U6G4RNZ2.mjs +0 -10
  62. package/dist/chunk-U6G4RNZ2.mjs.map +0 -1
  63. package/dist/iter-fest.observableValues.js +0 -100
  64. package/dist/iter-fest.observableValues.js.map +0 -1
  65. package/dist/iter-fest.observableValues.mjs +0 -8
  66. package/dist/iter-fest.readerToAsyncIterableIterator.d.mts +0 -3
  67. package/dist/iter-fest.readerToAsyncIterableIterator.d.ts +0 -3
  68. package/dist/iter-fest.readerToAsyncIterableIterator.js.map +0 -1
  69. package/dist/iter-fest.readerToAsyncIterableIterator.mjs +0 -7
  70. /package/dist/{iter-fest.observableValues.mjs.map → iter-fest.asyncGeneratorWithLastValue.mjs.map} +0 -0
  71. /package/dist/{iter-fest.readerToAsyncIterableIterator.mjs.map → iter-fest.asyncIteratorToAsyncIterable.mjs.map} +0 -0
package/README.md CHANGED
@@ -16,26 +16,22 @@ Iterables can contains infinite number of items, please use this package respons
16
16
  npm install iter-fest
17
17
  ```
18
18
 
19
- ### `Array.prototype` ports
19
+ ## Conversions
20
20
 
21
- We ported majority of functions from `Array.prototype.*` to `iterable*`.
22
-
23
- ```ts
24
- import { iterableIncludes, iterableReduce } from 'iter-fest'; // Via default exports.
25
- import { iterableSome } from 'iter-fest/iterableSome'; // Via named exports.
26
-
27
- const iterable: Iterable<number> = [1, 2, 3, 4, 5].values();
28
-
29
- console.log(iterableIncludes(iterable, 3)); // Prints "true".
30
- console.log(iterableReduce(iterable, (sum, value) => sum + value, 0)); // Prints "15".
31
- console.log(iterableSome(iterable, value => value % 2)); // Prints "true".
32
- ```
21
+ | From | To | Function signature |
22
+ | ----------------------------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
23
+ | `Iterator` | `IterableIterator` | [`iteratorToIterable<T>(iterator: Iterator<T>): IterableIterator<T>`](#converting-an-iterator-to-iterable) |
24
+ | `AsyncIterator` | `AsyncIterableIterator` | [`asyncIteratorToAsyncIterable<T>(asyncIterator: AsyncIterator<T>): AsyncIterableIterator<T>`](#converting-an-iterator-to-iterable) |
25
+ | `Observable` | `ReadableStream` | [`observableSubscribeAsReadable<T>(observable: Observable<T>): ReadableStream<T>`](#converting-an-observable-to-readablestream) |
26
+ | `ReadableStreamDefaultReader` | `AsyncIterableIterator` | [`readerValues`<T>(reader: ReadableStreamDefaultReader<T>): AsyncIterableIterator<T>`](#iterating-readablestreamdefaultreader) |
27
+ | `AsyncIterable` | `Observable` | [`observableFromAsync<T>(iterable: AsyncIterable<T>): Observable<T>`](#converting-an-asynciterable-to-observable) |
28
+ | `AsyncIterable`/`Iterable` | `ReadableStream` | [`iterableGetReadable<T>(iterable: AsyncIterable<T> \| Iterable<T>): ReadableStream<T>`](#converting-an-asynciterableiterable-to-readablestream) |
33
29
 
34
- 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), [`every`](https://tc39.es/ecma262/#sec-array.prototype.every), [`filter`](https://tc39.es/ecma262/#sec-array.prototype.filter), [`find`](https://tc39.es/ecma262/#sec-array.prototype.find), [`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), [`forEach`](https://tc39.es/ecma262/#sec-array.prototype.foreach), [`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), [`map`](https://tc39.es/ecma262/#sec-array.prototype.map), [`reduce`](https://tc39.es/ecma262/#sec-array.prototype.reduce), [`slice`](https://tc39.es/ecma262/#sec-array.prototype.slice), [`some`](https://tc39.es/ecma262/#sec-array.prototype.some), [`toSpliced`](https://tc39.es/ecma262/#sec-array.prototype.tospliced), and [`toString`](https://tc39.es/ecma262/#sec-array.prototype.tostring).
30
+ To convert `Observable` to `AsyncIterableIterator`, [use `ReadableStream` as intermediate format](#converting-an-observable-to-asynciterableiterator).
35
31
 
36
32
  ### Converting an iterator to iterable
37
33
 
38
- `iteratorToIterable` converts a pure iterator to `IterableIterator` and enable for-loop iteration.
34
+ `iteratorToIterable` and `asyncIteratorToAsyncIterable` enable a [pure iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator) to be iterable using a for-loop statement.
39
35
 
40
36
  ```ts
41
37
  const iterate = (): Iterator<number> => {
@@ -44,7 +40,7 @@ const iterate = (): Iterator<number> => {
44
40
  return {
45
41
  next: () => {
46
42
  if (++value <= 3) {
47
- return { done: false, value };
43
+ return { value };
48
44
  }
49
45
 
50
46
  return { done: true, value: undefined };
@@ -57,29 +53,31 @@ for (const value of iteratorToIterable(iterate())) {
57
53
  }
58
54
  ```
59
55
 
60
- ### Typed `Observable`
61
-
62
- `Observable` and `Symbol.observable` is re-exported from `core-js-pure` with proper type definitions.
56
+ Note: calling `[Symbol.iterator]()` or `[Symbol.asyncIterator]()` will not restart the iteration. This is because iterator is an instance of iteration and is not restartable.
63
57
 
64
58
  ### Converting an `Observable` to `AsyncIterableIterator`
65
59
 
66
- `observableValues` subscribes to an `Observable` and return as `AsyncIterableIterator`.
60
+ `ReadableStream` can be used as an intermediate format when converting an `Observable` to `AsyncIterableIterator`.
67
61
 
68
- `Observable` is push-based and `AsyncIterableIterator` is pull-based. Values from `Observable` may push continuously and will be buffered internally. When for-loop break or complete, the iterator will unsubscribe from the `Observable`.
62
+ Note: `Observable` is push-based and it does not support flow control. When converting to `AsyncIterableIteratorrr`, the internal buffer of `ReadableStream` could build up quickly.
69
63
 
70
64
  ```ts
71
65
  const observable = Observable.from([1, 2, 3]);
66
+ const readable = observableSubscribeAsReadable(observable);
67
+ const iterable = readerValues(readable.getReader());
72
68
 
73
- for await (const value of observableValues(observable)) {
69
+ for await (const value of iterable) {
74
70
  console.log(value); // Prints "1", "2", "3".
75
71
  }
76
72
  ```
77
73
 
74
+ Note: calling `[Symbol.asyncIterator]()` will not resubscribe and read from the start of the observable. This is because the intermediate format does not support restart.
75
+
78
76
  ### Converting an `AsyncIterable` to `Observable`
79
77
 
80
78
  `Observable.from` converts `Iterable` into `Observable`. However, it does not convert `AsyncIterable`.
81
79
 
82
- `observableFromAsync` will convert `AsyncIterable` into `Observable`.
80
+ `observableFromAsync` will convert `AsyncIterable` into `Observable`. It will try to restart the iteration by calling `[Symbol.asyncIterator]()`.
83
81
 
84
82
  ```ts
85
83
  async function* generate() {
@@ -94,11 +92,70 @@ const next = value => console.log(value);
94
92
  observable.subscribe({ next }); // Prints "1", "2", "3".
95
93
  ```
96
94
 
95
+ Note: `observableFromAsync` will call `[Symbol.asyncIterator]()` initially to restart the iteration where possible.
96
+
97
+ ### Converting an `Observable` to `ReadableStream`
98
+
99
+ `ReadableStream` is powerful for transforming and piping stream of data. It can be formed using data from both push-based and pull-based source with backpressuree.
100
+
101
+ Note: `Observable` is push-based and it does not support flow control. When converting to `ReadableStream`, the internal buffer could build up quickly.
102
+
103
+ ```ts
104
+ const observable = Observable.from([1, 2, 3]);
105
+ const readable = observableSubscribeAsReadable(observable);
106
+
107
+ readable.pipeTo(stream.writable); // Will write 1, 2, 3.
108
+ ```
109
+
110
+ ### Iterating `ReadableStreamDefaultReader`
111
+
112
+ `readerValues` will convert default reader of `ReadableStream` into an `AsyncIterableIterator` to use in for-loop.
113
+
114
+ ```ts
115
+ const readableStream = new ReadableStream({
116
+ start(controller) {
117
+ controller.enqueue(1);
118
+ controller.enqueue(2);
119
+ },
120
+ pull(controller) {
121
+ controller.enqueue(3);
122
+ controller.close();
123
+ }
124
+ });
125
+
126
+ const iterable = readerValues(readableStream.getReader());
127
+
128
+ for await (const value of iterable) {
129
+ console.log(value); // Prints "1", "2", "3".
130
+ }
131
+ ```
132
+
133
+ Note: `[Symbol.asyncIterator]()` will not restart the reader and read from start of the stream. Reader is not restartable and streams are not seekable.
134
+
135
+ ### Converting an `AsyncIterable`/`Iterable` to `ReadableStream`
136
+
137
+ ```ts
138
+ const iterable = [1, 2, 3].values();
139
+ const readable = iterableGetReadable(iterable);
140
+
141
+ readable.pipeTo(stream.writable); // Will write 1, 2, 3.
142
+ ```
143
+
144
+ Note: `iterableGetReadable()` will call `[Symbol.iterator]()` initially to restart the iteration where possible.
145
+
146
+ ## Others
147
+
148
+ ### Typed `Observable`
149
+
150
+ `Observable` and `Symbol.observable` is re-exported from `core-js-pure` with proper type definitions.
151
+
97
152
  ### Producer-consumer queue
98
153
 
99
- `PushAsyncIterableIterator` is a simple push-based producer-consumer queue. The producer can push a new job at anytime. The consumer will wait for jobs to be available.
154
+ `PushAsyncIterableIterator` is a simple push-based producer-consumer queue and designed to decouple the flow between a producer and consumer. The producer can push a new job at anytime. The consumer can pull a job at its own convenience via for-loop.
100
155
 
101
- A push-based queue is easier to use than a pull-based queue. However, pull-based queue offers better flow control. For a full-featured producer-consumer queue that supports flow control, use `ReadableStream` instead.
156
+ Compare to pull-based queue, a push-based queue is very 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.
157
+
158
+ For a full-featured producer-consumer queue that supports flow control, use `ReadableStream` instead.
102
159
 
103
160
  ```ts
104
161
  const iterable = new PushAsyncIterableIterator();
@@ -121,22 +178,61 @@ const iterable = new PushAsyncIterableIterator();
121
178
  // Prints "1", "2", "3", "Done".
122
179
  ```
123
180
 
124
- ### Iterating `ReadableStreamDefaultReader`
181
+ ### Using for-loop with generator
182
+
183
+ Compare to `Iterator`, `Generator` offers advanced capability.
125
184
 
126
- `readerToAsyncIterableIterator` will convert default reader of `ReadableStream` into an `AsyncIterableIterator` to use in for-loop.
185
+ When using for-loop with generator, the last value return from the generator is lost.
186
+
187
+ The `generatorWithLastValue()` and `asyncGeneratorWithLastValue()` helps bridge the for-loop usage by capturing the value returned as `{ done: true }` and make it accessible via `lastValue()`.
127
188
 
128
189
  ```ts
129
- const readableStream = new ReadableStream({ start(controller) {
130
- controller.enqueue(1);
131
- controller.enqueue(2);
132
- controller.close();
133
- } });
190
+ const generator = generatorWithLastValue(
191
+ (function* () {
192
+ yield 1;
193
+ yield 2;
194
+ yield 3;
195
+
196
+ return 'end';
197
+ })()
198
+ );
134
199
 
135
- for await (const value of readerToAsyncIterableIterator(readableStream.getReader())) {
200
+ for (const value of generator) {
136
201
  console.log(value); // Prints "1", "2", "3".
137
202
  }
203
+
204
+ console.log(generator.lastValue()); // Prints "end".
205
+ ```
206
+
207
+ Note: `lastValue()` will throw if it is being called before end of iteration. Also, excessive calls to `next()` will return `{ done: true, value: undefined }`, thus, `lastValue()` could become `undefined` if `next()` is called after the end of iteration.
208
+
209
+ The value returned from `generatorWithLastValue()`/`asyncGeneratorWithLastValue()` will passthrough all function calls to original `Generator` with a minor difference. Calling `[Symbol.iterator]()`/`[Symbol.asyncIterator]()` on the returned generator will not start a fresh iteration. If a fresh iteration is required, create a new one before passing it to `generatorWithLastValue()`/`asyncGeneratorWithLastValue()`.
210
+
211
+ ```ts
212
+ const generator = generatorWithLastValue(
213
+ (function* () {
214
+ // ...
215
+ })()[Symbol.iterator]() // Creates a fresh iteration.
216
+ );
138
217
  ```
139
218
 
219
+ ## `Array.prototype` ports
220
+
221
+ We ported majority of functions from `Array.prototype.*` to `iterable*`.
222
+
223
+ ```ts
224
+ import { iterableIncludes, iterableReduce } from 'iter-fest'; // Via default exports.
225
+ import { iterableSome } from 'iter-fest/iterableSome'; // Via named exports.
226
+
227
+ const iterable: Iterable<number> = [1, 2, 3, 4, 5].values();
228
+
229
+ console.log(iterableIncludes(iterable, 3)); // Prints "true".
230
+ console.log(iterableReduce(iterable, (sum, value) => sum + value, 0)); // Prints "15".
231
+ console.log(iterableSome(iterable, value => value % 2)); // Prints "true".
232
+ ```
233
+
234
+ 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), [`every`](https://tc39.es/ecma262/#sec-array.prototype.every), [`filter`](https://tc39.es/ecma262/#sec-array.prototype.filter), [`find`](https://tc39.es/ecma262/#sec-array.prototype.find), [`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), [`forEach`](https://tc39.es/ecma262/#sec-array.prototype.foreach), [`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), [`map`](https://tc39.es/ecma262/#sec-array.prototype.map), [`reduce`](https://tc39.es/ecma262/#sec-array.prototype.reduce), [`slice`](https://tc39.es/ecma262/#sec-array.prototype.slice), [`some`](https://tc39.es/ecma262/#sec-array.prototype.some), [`toSpliced`](https://tc39.es/ecma262/#sec-array.prototype.tospliced), and [`toString`](https://tc39.es/ecma262/#sec-array.prototype.tostring).
235
+
140
236
  ## Behaviors
141
237
 
142
238
  ### How this compares to the TC39 proposals?
@@ -185,18 +281,21 @@ Generator has more functionalities than iterator and array. It is not recommende
185
281
  - Generator can define the return value
186
282
  - `return { done: true, value: 'the very last value' }`
187
283
  - Iterating generator using for-loop will not get any values from `{ done: true }`
284
+ - The `generatorWithLastValue()` will help capturing and retrieving the last return value
188
285
  - Generator can receive feedback values from its iterator
189
286
  - `generator.next('something')`, the feedback can be assigned to variable via `const feedback = yield;`
190
287
  - For-loop cannot send feedbacks to generator
191
288
 
192
289
  ### When should I use `Iterable`, `IterableIterator` and `Iterator`?
193
290
 
194
- For best compatibility, you should generally follow this API signature: use `Iterable` for inputs, and use `IterableIterator` for outputs. You should avoid exporting pure `Iterator`.
291
+ For best compatibility, you should generally follow this API signature: use `Iterable` for inputs, and use `IterableIterator` for outputs. You should avoid exporting pure `Iterator`. Sample function signature should looks below.
195
292
 
196
293
  ```ts
197
- function transform<T>(iterable: Iterable<T>): IterableIterator<T>;
294
+ function myFunction<T>(input: Iterable<T>): IterableIterator<T>;
198
295
  ```
199
296
 
297
+ `IterableIterator` may opt to support restarting the iteration through `[Symbol.iterator]()`. When consuming an `IterableIterator`, you should call `[Symbol.iterator]()` to obtain a fresh iteration or use for-loop statement if possible. However, `[Symbol.iterator]()` is an opt-in feature and does not always guarantee a fresh iteration.
298
+
200
299
  ### What is on the roadmap?
201
300
 
202
301
  We are planning to bring iterables and its siblings together, including:
@@ -0,0 +1,35 @@
1
+ // src/generatorWithLastValue.ts
2
+ var STILL_ITERATING = Symbol();
3
+ function generatorWithLastValue(generator) {
4
+ let lastValue = STILL_ITERATING;
5
+ const generatorWithLastValue2 = {
6
+ [Symbol.iterator]() {
7
+ return generatorWithLastValue2;
8
+ },
9
+ lastValue() {
10
+ if (lastValue === STILL_ITERATING) {
11
+ throw new Error("Iteration has not complete yet, cannot get last value.");
12
+ }
13
+ return lastValue;
14
+ },
15
+ next(next) {
16
+ const result = generator.next(next);
17
+ if (result.done) {
18
+ lastValue = result.value;
19
+ }
20
+ return result;
21
+ },
22
+ return(value) {
23
+ return generator.return(value);
24
+ },
25
+ throw(error) {
26
+ return generator.throw(error);
27
+ }
28
+ };
29
+ return generatorWithLastValue2;
30
+ }
31
+
32
+ export {
33
+ generatorWithLastValue
34
+ };
35
+ //# sourceMappingURL=chunk-2DE3J4J7.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/generatorWithLastValue.ts"],"sourcesContent":["const STILL_ITERATING = Symbol();\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type GeneratorWithLastValue<T = unknown, TReturn = any, TNext = unknown> = Generator<T, TReturn, TNext> & {\n lastValue(): TReturn;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function generatorWithLastValue<T = unknown, TReturn = any, TNext = unknown>(\n generator: Generator<T, TReturn, TNext>\n): GeneratorWithLastValue<T, TReturn, TNext> {\n let lastValue: typeof STILL_ITERATING | TReturn = STILL_ITERATING;\n\n const generatorWithLastValue = {\n [Symbol.iterator]() {\n return generatorWithLastValue;\n },\n lastValue(): TReturn {\n if (lastValue === STILL_ITERATING) {\n throw new Error('Iteration has not complete yet, cannot get last value.');\n }\n\n return lastValue;\n },\n next(next: TNext) {\n const result = generator.next(next);\n\n if (result.done) {\n lastValue = result.value;\n }\n\n return result;\n },\n return(value: TReturn) {\n return generator.return(value);\n },\n throw(error: unknown) {\n return generator.throw(error);\n }\n };\n\n return generatorWithLastValue;\n}\n"],"mappings":";AAAA,IAAM,kBAAkB,OAAO;AAQxB,SAAS,uBACd,WAC2C;AAC3C,MAAI,YAA8C;AAElD,QAAMA,0BAAyB;AAAA,IAC7B,CAAC,OAAO,QAAQ,IAAI;AAClB,aAAOA;AAAA,IACT;AAAA,IACA,YAAqB;AACnB,UAAI,cAAc,iBAAiB;AACjC,cAAM,IAAI,MAAM,wDAAwD;AAAA,MAC1E;AAEA,aAAO;AAAA,IACT;AAAA,IACA,KAAK,MAAa;AAChB,YAAM,SAAS,UAAU,KAAK,IAAI;AAElC,UAAI,OAAO,MAAM;AACf,oBAAY,OAAO;AAAA,MACrB;AAEA,aAAO;AAAA,IACT;AAAA,IACA,OAAO,OAAgB;AACrB,aAAO,UAAU,OAAO,KAAK;AAAA,IAC/B;AAAA,IACA,MAAM,OAAgB;AACpB,aAAO,UAAU,MAAM,KAAK;AAAA,IAC9B;AAAA,EACF;AAEA,SAAOA;AACT;","names":["generatorWithLastValue"]}
@@ -0,0 +1,35 @@
1
+ // src/asyncGeneratorWithLastValue.ts
2
+ var STILL_ITERATING = Symbol();
3
+ function asyncGeneratorWithLastValue(generator) {
4
+ let lastValue = STILL_ITERATING;
5
+ const asyncGeneratorWithLastValue2 = {
6
+ [Symbol.asyncIterator]() {
7
+ return asyncGeneratorWithLastValue2;
8
+ },
9
+ lastValue() {
10
+ if (lastValue === STILL_ITERATING) {
11
+ throw new Error("Iteration has not complete yet, cannot get last value.");
12
+ }
13
+ return lastValue;
14
+ },
15
+ async next(next) {
16
+ const result = await generator.next(next);
17
+ if (result.done) {
18
+ lastValue = result.value;
19
+ }
20
+ return result;
21
+ },
22
+ return(value) {
23
+ return generator.return(value);
24
+ },
25
+ throw(error) {
26
+ return generator.throw(error);
27
+ }
28
+ };
29
+ return asyncGeneratorWithLastValue2;
30
+ }
31
+
32
+ export {
33
+ asyncGeneratorWithLastValue
34
+ };
35
+ //# sourceMappingURL=chunk-ANRVAYLW.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/asyncGeneratorWithLastValue.ts"],"sourcesContent":["const STILL_ITERATING = Symbol();\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AsyncGeneratorWithLastValue<T = unknown, TReturn = any, TNext = unknown> = AsyncGenerator<\n T,\n TReturn,\n TNext\n> & {\n lastValue(): TReturn;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function asyncGeneratorWithLastValue<T = unknown, TReturn = any, TNext = unknown>(\n generator: AsyncGenerator<T, TReturn, TNext>\n): AsyncGeneratorWithLastValue<T, TReturn, TNext> {\n let lastValue: typeof STILL_ITERATING | TReturn = STILL_ITERATING;\n\n const asyncGeneratorWithLastValue = {\n [Symbol.asyncIterator]() {\n return asyncGeneratorWithLastValue;\n },\n lastValue(): TReturn {\n if (lastValue === STILL_ITERATING) {\n throw new Error('Iteration has not complete yet, cannot get last value.');\n }\n\n return lastValue;\n },\n async next(next: TNext) {\n const result = await generator.next(next);\n\n if (result.done) {\n lastValue = result.value;\n }\n\n return result;\n },\n return(value: TReturn) {\n return generator.return(value);\n },\n throw(error: unknown) {\n return generator.throw(error);\n }\n };\n\n return asyncGeneratorWithLastValue;\n}\n"],"mappings":";AAAA,IAAM,kBAAkB,OAAO;AAYxB,SAAS,4BACd,WACgD;AAChD,MAAI,YAA8C;AAElD,QAAMA,+BAA8B;AAAA,IAClC,CAAC,OAAO,aAAa,IAAI;AACvB,aAAOA;AAAA,IACT;AAAA,IACA,YAAqB;AACnB,UAAI,cAAc,iBAAiB;AACjC,cAAM,IAAI,MAAM,wDAAwD;AAAA,MAC1E;AAEA,aAAO;AAAA,IACT;AAAA,IACA,MAAM,KAAK,MAAa;AACtB,YAAM,SAAS,MAAM,UAAU,KAAK,IAAI;AAExC,UAAI,OAAO,MAAM;AACf,oBAAY,OAAO;AAAA,MACrB;AAEA,aAAO;AAAA,IACT;AAAA,IACA,OAAO,OAAgB;AACrB,aAAO,UAAU,OAAO,KAAK;AAAA,IAC/B;AAAA,IACA,MAAM,OAAgB;AACpB,aAAO,UAAU,MAAM,KAAK;AAAA,IAC9B;AAAA,EACF;AAEA,SAAOA;AACT;","names":["asyncGeneratorWithLastValue"]}
@@ -0,0 +1,27 @@
1
+ // src/observableSubscribeAsReadable.ts
2
+ function observableSubscribeAsReadable(observable) {
3
+ let subscription;
4
+ return new ReadableStream({
5
+ cancel() {
6
+ subscription.unsubscribe();
7
+ },
8
+ start(controller) {
9
+ subscription = observable.subscribe({
10
+ complete() {
11
+ controller.close();
12
+ },
13
+ error(err) {
14
+ controller.error(err);
15
+ },
16
+ next(value) {
17
+ controller.enqueue(value);
18
+ }
19
+ });
20
+ }
21
+ });
22
+ }
23
+
24
+ export {
25
+ observableSubscribeAsReadable
26
+ };
27
+ //# sourceMappingURL=chunk-EIIP7YWB.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/observableSubscribeAsReadable.ts"],"sourcesContent":["import type { Observable, Subscription } from './Observable';\n\nexport function observableSubscribeAsReadable<T>(observable: Observable<T>): ReadableStream<T> {\n let subscription: Subscription;\n\n return new ReadableStream<T>({\n cancel() {\n subscription.unsubscribe();\n },\n start(controller) {\n subscription = observable.subscribe({\n complete() {\n controller.close();\n },\n error(err: unknown) {\n controller.error(err);\n },\n next(value) {\n controller.enqueue(value);\n }\n });\n }\n });\n}\n"],"mappings":";AAEO,SAAS,8BAAiC,YAA8C;AAC7F,MAAI;AAEJ,SAAO,IAAI,eAAkB;AAAA,IAC3B,SAAS;AACP,mBAAa,YAAY;AAAA,IAC3B;AAAA,IACA,MAAM,YAAY;AAChB,qBAAe,WAAW,UAAU;AAAA,QAClC,WAAW;AACT,qBAAW,MAAM;AAAA,QACnB;AAAA,QACA,MAAM,KAAc;AAClB,qBAAW,MAAM,GAAG;AAAA,QACtB;AAAA,QACA,KAAK,OAAO;AACV,qBAAW,QAAQ,KAAK;AAAA,QAC1B;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AACH;","names":[]}
@@ -1,5 +1,5 @@
1
- // src/readerToAsyncIterableIterator.ts
2
- function readerToAsyncIterableIterator(reader) {
1
+ // src/readerValues.ts
2
+ function readerValues(reader) {
3
3
  const iterable = {
4
4
  [Symbol.asyncIterator]() {
5
5
  return iterable;
@@ -10,12 +10,16 @@ function readerToAsyncIterableIterator(reader) {
10
10
  return { done: true, value: void 0 };
11
11
  }
12
12
  return { value: result.value };
13
+ },
14
+ async return() {
15
+ reader.cancel();
16
+ return { done: true, value: void 0 };
13
17
  }
14
18
  };
15
19
  return iterable;
16
20
  }
17
21
 
18
22
  export {
19
- readerToAsyncIterableIterator
23
+ readerValues
20
24
  };
21
- //# sourceMappingURL=chunk-2HLJODU3.mjs.map
25
+ //# sourceMappingURL=chunk-EUVK4YM7.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/readerValues.ts"],"sourcesContent":["export function readerValues<T>(reader: ReadableStreamDefaultReader<T>): AsyncIterableIterator<T> {\n const iterable: AsyncIterableIterator<T> = {\n [Symbol.asyncIterator]() {\n return iterable;\n },\n async next(): Promise<IteratorResult<T>> {\n const result = await Promise.race([reader.read(), reader.closed]);\n\n if (!result || result.done) {\n return { done: true, value: undefined };\n }\n\n return { value: result.value };\n },\n async return() {\n // Throw inside for-loop is return().\n reader.cancel();\n\n return { done: true, value: undefined };\n }\n };\n\n return iterable;\n}\n"],"mappings":";AAAO,SAAS,aAAgB,QAAkE;AAChG,QAAM,WAAqC;AAAA,IACzC,CAAC,OAAO,aAAa,IAAI;AACvB,aAAO;AAAA,IACT;AAAA,IACA,MAAM,OAAmC;AACvC,YAAM,SAAS,MAAM,QAAQ,KAAK,CAAC,OAAO,KAAK,GAAG,OAAO,MAAM,CAAC;AAEhE,UAAI,CAAC,UAAU,OAAO,MAAM;AAC1B,eAAO,EAAE,MAAM,MAAM,OAAO,OAAU;AAAA,MACxC;AAEA,aAAO,EAAE,OAAO,OAAO,MAAM;AAAA,IAC/B;AAAA,IACA,MAAM,SAAS;AAEb,aAAO,OAAO;AAEd,aAAO,EAAE,MAAM,MAAM,OAAO,OAAU;AAAA,IACxC;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
@@ -0,0 +1,22 @@
1
+ // src/iterableGetReadable.ts
2
+ function isIterable(iterable) {
3
+ return !!(iterable && typeof iterable === "object" && Symbol.iterator in iterable);
4
+ }
5
+ function iterableGetReadable(iterable) {
6
+ const iterator = isIterable(iterable) ? iterable[Symbol.iterator]() : iterable[Symbol.asyncIterator]();
7
+ return new ReadableStream({
8
+ async pull(controller) {
9
+ const result = await iterator.next();
10
+ if (result.done) {
11
+ controller.close();
12
+ } else {
13
+ controller.enqueue(result.value);
14
+ }
15
+ }
16
+ });
17
+ }
18
+
19
+ export {
20
+ iterableGetReadable
21
+ };
22
+ //# sourceMappingURL=chunk-MOBXUTO5.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/iterableGetReadable.ts"],"sourcesContent":["function isIterable(iterable: unknown): iterable is Iterable<unknown> {\n return !!(iterable && typeof iterable === 'object' && Symbol.iterator in iterable);\n}\n\nexport function iterableGetReadable<T>(iterable: AsyncIterable<T> | Iterable<T>): ReadableStream<T> {\n const iterator = isIterable(iterable) ? iterable[Symbol.iterator]() : iterable[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,oBAAuB,UAA6D;AAClG,QAAM,WAAW,WAAW,QAAQ,IAAI,SAAS,OAAO,QAAQ,EAAE,IAAI,SAAS,OAAO,aAAa,EAAE;AAErG,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":[]}
@@ -1,6 +1,8 @@
1
- import {
2
- withResolvers
3
- } from "./chunk-U6G4RNZ2.mjs";
1
+ // src/private/withResolvers.ts
2
+ import coreJSPromiseWithResolvers from "core-js-pure/full/promise/with-resolvers";
3
+ function withResolvers() {
4
+ return coreJSPromiseWithResolvers();
5
+ }
4
6
 
5
7
  // src/PushAsyncIterableIterator.ts
6
8
  var CLOSE = Symbol("close");
@@ -32,4 +34,4 @@ var PushAsyncIterableIterator = class {
32
34
  export {
33
35
  PushAsyncIterableIterator
34
36
  };
35
- //# sourceMappingURL=chunk-K5XV4W7G.mjs.map
37
+ //# sourceMappingURL=chunk-O5SQJUKB.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/private/withResolvers.ts","../src/PushAsyncIterableIterator.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('close');\n\nexport class PushAsyncIterableIterator<T> implements AsyncIterableIterator<T> {\n #closed: boolean = false;\n #pushResolvers: PromiseWithResolvers<T | typeof CLOSE> = withResolvers();\n\n [Symbol.asyncIterator]() {\n return this;\n }\n\n close() {\n this.#closed = true;\n this.#pushResolvers.resolve(CLOSE);\n }\n\n async next(): Promise<IteratorResult<T>> {\n const value = await this.#pushResolvers.promise;\n\n if (value === CLOSE) {\n return { done: true, value: undefined };\n }\n\n return { done: false, value };\n }\n\n push(value: T) {\n if (!this.#closed) {\n this.#pushResolvers.resolve(value);\n this.#pushResolvers = withResolvers();\n }\n }\n}\n"],"mappings":";AACA,OAAO,gCAAgC;AAExB,SAAR,gBAA6D;AAClE,SAAO,2BAA2B;AACpC;;;ACHA,IAAM,QAAQ,OAAO,OAAO;AAErB,IAAM,4BAAN,MAAuE;AAAA,EAC5E,UAAmB;AAAA,EACnB,iBAAyD,cAAc;AAAA,EAEvE,CAAC,OAAO,aAAa,IAAI;AACvB,WAAO;AAAA,EACT;AAAA,EAEA,QAAQ;AACN,SAAK,UAAU;AACf,SAAK,eAAe,QAAQ,KAAK;AAAA,EACnC;AAAA,EAEA,MAAM,OAAmC;AACvC,UAAM,QAAQ,MAAM,KAAK,eAAe;AAExC,QAAI,UAAU,OAAO;AACnB,aAAO,EAAE,MAAM,MAAM,OAAO,OAAU;AAAA,IACxC;AAEA,WAAO,EAAE,MAAM,OAAO,MAAM;AAAA,EAC9B;AAAA,EAEA,KAAK,OAAU;AACb,QAAI,CAAC,KAAK,SAAS;AACjB,WAAK,eAAe,QAAQ,KAAK;AACjC,WAAK,iBAAiB,cAAc;AAAA,IACtC;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,15 @@
1
+ // src/asyncIteratorToAsyncIterable.ts
2
+ function asyncIteratorToAsyncIterable(asyncIterator) {
3
+ const asyncIterableIterator = {
4
+ [Symbol.asyncIterator]: () => asyncIterableIterator,
5
+ next: asyncIterator.next.bind(asyncIterator),
6
+ ...asyncIterator.return ? { return: asyncIterator.return.bind(asyncIterator) } : {},
7
+ ...asyncIterator.throw ? { throw: asyncIterator.throw.bind(asyncIterator) } : {}
8
+ };
9
+ return asyncIterableIterator;
10
+ }
11
+
12
+ export {
13
+ asyncIteratorToAsyncIterable
14
+ };
15
+ //# sourceMappingURL=chunk-P4OSZLEH.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/asyncIteratorToAsyncIterable.ts"],"sourcesContent":["export function asyncIteratorToAsyncIterable<T>(asyncIterator: AsyncIterator<T>): AsyncIterableIterator<T> {\n const asyncIterableIterator: AsyncIterableIterator<T> = {\n [Symbol.asyncIterator]: () => asyncIterableIterator,\n next: asyncIterator.next.bind(asyncIterator),\n ...(asyncIterator.return ? { return: asyncIterator.return.bind(asyncIterator) } : {}),\n ...(asyncIterator.throw ? { throw: asyncIterator.throw.bind(asyncIterator) } : {})\n };\n\n return asyncIterableIterator;\n}\n"],"mappings":";AAAO,SAAS,6BAAgC,eAA2D;AACzG,QAAM,wBAAkD;AAAA,IACtD,CAAC,OAAO,aAAa,GAAG,MAAM;AAAA,IAC9B,MAAM,cAAc,KAAK,KAAK,aAAa;AAAA,IAC3C,GAAI,cAAc,SAAS,EAAE,QAAQ,cAAc,OAAO,KAAK,aAAa,EAAE,IAAI,CAAC;AAAA,IACnF,GAAI,cAAc,QAAQ,EAAE,OAAO,cAAc,MAAM,KAAK,aAAa,EAAE,IAAI,CAAC;AAAA,EAClF;AAEA,SAAO;AACT;","names":[]}
@@ -0,0 +1,6 @@
1
+ type AsyncGeneratorWithLastValue<T = unknown, TReturn = any, TNext = unknown> = AsyncGenerator<T, TReturn, TNext> & {
2
+ lastValue(): TReturn;
3
+ };
4
+ declare function asyncGeneratorWithLastValue<T = unknown, TReturn = any, TNext = unknown>(generator: AsyncGenerator<T, TReturn, TNext>): AsyncGeneratorWithLastValue<T, TReturn, TNext>;
5
+
6
+ export { type AsyncGeneratorWithLastValue, asyncGeneratorWithLastValue };
@@ -0,0 +1,6 @@
1
+ type AsyncGeneratorWithLastValue<T = unknown, TReturn = any, TNext = unknown> = AsyncGenerator<T, TReturn, TNext> & {
2
+ lastValue(): TReturn;
3
+ };
4
+ declare function asyncGeneratorWithLastValue<T = unknown, TReturn = any, TNext = unknown>(generator: AsyncGenerator<T, TReturn, TNext>): AsyncGeneratorWithLastValue<T, TReturn, TNext>;
5
+
6
+ export { type AsyncGeneratorWithLastValue, asyncGeneratorWithLastValue };
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/asyncGeneratorWithLastValue.ts
21
+ var asyncGeneratorWithLastValue_exports = {};
22
+ __export(asyncGeneratorWithLastValue_exports, {
23
+ asyncGeneratorWithLastValue: () => asyncGeneratorWithLastValue
24
+ });
25
+ module.exports = __toCommonJS(asyncGeneratorWithLastValue_exports);
26
+ var STILL_ITERATING = Symbol();
27
+ function asyncGeneratorWithLastValue(generator) {
28
+ let lastValue = STILL_ITERATING;
29
+ const asyncGeneratorWithLastValue2 = {
30
+ [Symbol.asyncIterator]() {
31
+ return asyncGeneratorWithLastValue2;
32
+ },
33
+ lastValue() {
34
+ if (lastValue === STILL_ITERATING) {
35
+ throw new Error("Iteration has not complete yet, cannot get last value.");
36
+ }
37
+ return lastValue;
38
+ },
39
+ async next(next) {
40
+ const result = await generator.next(next);
41
+ if (result.done) {
42
+ lastValue = result.value;
43
+ }
44
+ return result;
45
+ },
46
+ return(value) {
47
+ return generator.return(value);
48
+ },
49
+ throw(error) {
50
+ return generator.throw(error);
51
+ }
52
+ };
53
+ return asyncGeneratorWithLastValue2;
54
+ }
55
+ // Annotate the CommonJS export names for ESM import in node:
56
+ 0 && (module.exports = {
57
+ asyncGeneratorWithLastValue
58
+ });
59
+ //# sourceMappingURL=iter-fest.asyncGeneratorWithLastValue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/asyncGeneratorWithLastValue.ts"],"sourcesContent":["const STILL_ITERATING = Symbol();\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AsyncGeneratorWithLastValue<T = unknown, TReturn = any, TNext = unknown> = AsyncGenerator<\n T,\n TReturn,\n TNext\n> & {\n lastValue(): TReturn;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function asyncGeneratorWithLastValue<T = unknown, TReturn = any, TNext = unknown>(\n generator: AsyncGenerator<T, TReturn, TNext>\n): AsyncGeneratorWithLastValue<T, TReturn, TNext> {\n let lastValue: typeof STILL_ITERATING | TReturn = STILL_ITERATING;\n\n const asyncGeneratorWithLastValue = {\n [Symbol.asyncIterator]() {\n return asyncGeneratorWithLastValue;\n },\n lastValue(): TReturn {\n if (lastValue === STILL_ITERATING) {\n throw new Error('Iteration has not complete yet, cannot get last value.');\n }\n\n return lastValue;\n },\n async next(next: TNext) {\n const result = await generator.next(next);\n\n if (result.done) {\n lastValue = result.value;\n }\n\n return result;\n },\n return(value: TReturn) {\n return generator.return(value);\n },\n throw(error: unknown) {\n return generator.throw(error);\n }\n };\n\n return asyncGeneratorWithLastValue;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAM,kBAAkB,OAAO;AAYxB,SAAS,4BACd,WACgD;AAChD,MAAI,YAA8C;AAElD,QAAMA,+BAA8B;AAAA,IAClC,CAAC,OAAO,aAAa,IAAI;AACvB,aAAOA;AAAA,IACT;AAAA,IACA,YAAqB;AACnB,UAAI,cAAc,iBAAiB;AACjC,cAAM,IAAI,MAAM,wDAAwD;AAAA,MAC1E;AAEA,aAAO;AAAA,IACT;AAAA,IACA,MAAM,KAAK,MAAa;AACtB,YAAM,SAAS,MAAM,UAAU,KAAK,IAAI;AAExC,UAAI,OAAO,MAAM;AACf,oBAAY,OAAO;AAAA,MACrB;AAEA,aAAO;AAAA,IACT;AAAA,IACA,OAAO,OAAgB;AACrB,aAAO,UAAU,OAAO,KAAK;AAAA,IAC/B;AAAA,IACA,MAAM,OAAgB;AACpB,aAAO,UAAU,MAAM,KAAK;AAAA,IAC9B;AAAA,EACF;AAEA,SAAOA;AACT;","names":["asyncGeneratorWithLastValue"]}
@@ -0,0 +1,7 @@
1
+ import {
2
+ asyncGeneratorWithLastValue
3
+ } from "./chunk-ANRVAYLW.mjs";
4
+ export {
5
+ asyncGeneratorWithLastValue
6
+ };
7
+ //# sourceMappingURL=iter-fest.asyncGeneratorWithLastValue.mjs.map
@@ -0,0 +1,3 @@
1
+ declare function asyncIteratorToAsyncIterable<T>(asyncIterator: AsyncIterator<T>): AsyncIterableIterator<T>;
2
+
3
+ export { asyncIteratorToAsyncIterable };
@@ -0,0 +1,3 @@
1
+ declare function asyncIteratorToAsyncIterable<T>(asyncIterator: AsyncIterator<T>): AsyncIterableIterator<T>;
2
+
3
+ export { asyncIteratorToAsyncIterable };
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/asyncIteratorToAsyncIterable.ts
21
+ var asyncIteratorToAsyncIterable_exports = {};
22
+ __export(asyncIteratorToAsyncIterable_exports, {
23
+ asyncIteratorToAsyncIterable: () => asyncIteratorToAsyncIterable
24
+ });
25
+ module.exports = __toCommonJS(asyncIteratorToAsyncIterable_exports);
26
+ function asyncIteratorToAsyncIterable(asyncIterator) {
27
+ const asyncIterableIterator = {
28
+ [Symbol.asyncIterator]: () => asyncIterableIterator,
29
+ next: asyncIterator.next.bind(asyncIterator),
30
+ ...asyncIterator.return ? { return: asyncIterator.return.bind(asyncIterator) } : {},
31
+ ...asyncIterator.throw ? { throw: asyncIterator.throw.bind(asyncIterator) } : {}
32
+ };
33
+ return asyncIterableIterator;
34
+ }
35
+ // Annotate the CommonJS export names for ESM import in node:
36
+ 0 && (module.exports = {
37
+ asyncIteratorToAsyncIterable
38
+ });
39
+ //# sourceMappingURL=iter-fest.asyncIteratorToAsyncIterable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/asyncIteratorToAsyncIterable.ts"],"sourcesContent":["export function asyncIteratorToAsyncIterable<T>(asyncIterator: AsyncIterator<T>): AsyncIterableIterator<T> {\n const asyncIterableIterator: AsyncIterableIterator<T> = {\n [Symbol.asyncIterator]: () => asyncIterableIterator,\n next: asyncIterator.next.bind(asyncIterator),\n ...(asyncIterator.return ? { return: asyncIterator.return.bind(asyncIterator) } : {}),\n ...(asyncIterator.throw ? { throw: asyncIterator.throw.bind(asyncIterator) } : {})\n };\n\n return asyncIterableIterator;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,SAAS,6BAAgC,eAA2D;AACzG,QAAM,wBAAkD;AAAA,IACtD,CAAC,OAAO,aAAa,GAAG,MAAM;AAAA,IAC9B,MAAM,cAAc,KAAK,KAAK,aAAa;AAAA,IAC3C,GAAI,cAAc,SAAS,EAAE,QAAQ,cAAc,OAAO,KAAK,aAAa,EAAE,IAAI,CAAC;AAAA,IACnF,GAAI,cAAc,QAAQ,EAAE,OAAO,cAAc,MAAM,KAAK,aAAa,EAAE,IAAI,CAAC;AAAA,EAClF;AAEA,SAAO;AACT;","names":[]}
@@ -0,0 +1,7 @@
1
+ import {
2
+ asyncIteratorToAsyncIterable
3
+ } from "./chunk-P4OSZLEH.mjs";
4
+ export {
5
+ asyncIteratorToAsyncIterable
6
+ };
7
+ //# sourceMappingURL=iter-fest.asyncIteratorToAsyncIterable.mjs.map