iter-fest 0.1.1-main.edf2470 → 0.1.1-main.f54555b

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 CHANGED
@@ -16,38 +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
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
- ```
33
-
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).
35
-
36
19
  ## Conversions
37
20
 
38
- | From | To | Function signature |
39
- | ----------------------------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
40
- | `Iterator` | `IterableIterator` | [`iteratorToIterable<T>(iterator: Iterator<T>): IterableIterator<T>`](#converting-an-iterator-to-iterable) |
41
- | `Observable` | `ReadableStream` | [`observableSubscribeAsReadable<T>(observable: Observable<T>): ReadableStream<T>`](#converting-an-observable-to-readablestream) |
42
- | `ReadableStreamDefaultReader` | `AsyncIterableIterator` | [`readerValues`<T>(reader: ReadableStreamDefaultReader<T>): AsyncIterableIterator<T>`](#iterating-readablestreamdefaultreader) |
43
- | `AsyncIterable` | `Observable` | [`observableFromAsync<T>(iterable: AsyncIterable<T>): Observable<T>`](#converting-an-asynciterable-to-observable) |
44
- | `AsyncIterable`/`Iterable` | `ReadableStream` | [`iterableGetReadable<T>(iterable: AsyncIterable<T> \| Iterable<T>): ReadableStream<T>`](#converting-an-asynciterableiterable-to-readablestream) |
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>`](#converting-a-readablestreamdefaultreader-to-asynciterableiterator) |
27
+ | `AsyncIterable` | `Observable` | [`observableFromAsync<T>(iterable: AsyncIterable<T>): Observable<T>`](#converting-an-asynciterable-to-observable) |
28
+ | `AsyncIterable`/`Iterable` | `ReadableStream` | [`readableStreamFrom<T>(anyIterable: AsyncIterable<T> \| Iterable<T>): ReadableStream<T>`](#converting-an-asynciterableiterable-to-readablestream) |
45
29
 
46
30
  To convert `Observable` to `AsyncIterableIterator`, [use `ReadableStream` as intermediate format](#converting-an-observable-to-asynciterableiterator).
47
31
 
48
32
  ### Converting an iterator to iterable
49
33
 
50
- `iteratorToIterable` 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.
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.
51
35
 
52
36
  ```ts
53
37
  const iterate = (): Iterator<number> => {
@@ -59,7 +43,7 @@ const iterate = (): Iterator<number> => {
59
43
  return { value };
60
44
  }
61
45
 
62
- return { done: true, value: undefined };
46
+ return { done: true, value: undefined } satisfies IteratorResult<number>;
63
47
  }
64
48
  };
65
49
  };
@@ -69,28 +53,31 @@ for (const value of iteratorToIterable(iterate())) {
69
53
  }
70
54
  ```
71
55
 
72
- Note: calling `[Symbol.iterator]` will not refresh the iteration.
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.
73
57
 
74
58
  ### Converting an `Observable` to `AsyncIterableIterator`
75
59
 
76
- `ReadableStream` can be used to when converting an `Observable` to `AsyncIterableIterator`.
60
+ `ReadableStream` can be used as an intermediate format when converting an `Observable` to `AsyncIterableIterator`.
77
61
 
78
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.
79
63
 
80
64
  ```ts
81
65
  const observable = Observable.from([1, 2, 3]);
82
66
  const readable = observableSubscribeAsReadable(observable);
67
+ const iterable = readerValues(readable.getReader());
83
68
 
84
- for await (const value of readerValues(readable.getReader())) {
69
+ for await (const value of iterable) {
85
70
  console.log(value); // Prints "1", "2", "3".
86
71
  }
87
72
  ```
88
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
+
89
76
  ### Converting an `AsyncIterable` to `Observable`
90
77
 
91
78
  `Observable.from` converts `Iterable` into `Observable`. However, it does not convert `AsyncIterable`.
92
79
 
93
- `observableFromAsync` will convert `AsyncIterable` into `Observable`.
80
+ `observableFromAsync` will convert `AsyncIterable` into `Observable`. It will try to restart the iteration by calling `[Symbol.asyncIterator]()`.
94
81
 
95
82
  ```ts
96
83
  async function* generate() {
@@ -105,7 +92,11 @@ const next = value => console.log(value);
105
92
  observable.subscribe({ next }); // Prints "1", "2", "3".
106
93
  ```
107
94
 
108
- ## Converting an `Observable` to `ReadableStream`
95
+ Note: `observableFromAsync` will call `[Symbol.asyncIterator]()` initially to restart the iteration where possible.
96
+
97
+ Note: It is not recommended to convert `AsyncGenerator` to an `Observable`. `AsyncGenerator` has more functionalities and `Observable` does not support many of them.
98
+
99
+ ### Converting an `Observable` to `ReadableStream`
109
100
 
110
101
  `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.
111
102
 
@@ -114,12 +105,11 @@ Note: `Observable` is push-based and it does not support flow control. When conv
114
105
  ```ts
115
106
  const observable = Observable.from([1, 2, 3]);
116
107
  const readable = observableSubscribeAsReadable(observable);
117
- const reader = readable.getReader();
118
108
 
119
109
  readable.pipeTo(stream.writable); // Will write 1, 2, 3.
120
110
  ```
121
111
 
122
- ### Iterating `ReadableStreamDefaultReader`
112
+ ### Converting a `ReadableStreamDefaultReader` to `AsyncIterableIterator`
123
113
 
124
114
  `readerValues` will convert default reader of `ReadableStream` into an `AsyncIterableIterator` to use in for-loop.
125
115
 
@@ -135,20 +125,28 @@ const readableStream = new ReadableStream({
135
125
  }
136
126
  });
137
127
 
138
- for await (const value of readerValues(readableStream.getReader())) {
128
+ const iterable = readerValues(readableStream.getReader());
129
+
130
+ for await (const value of iterable) {
139
131
  console.log(value); // Prints "1", "2", "3".
140
132
  }
141
133
  ```
142
134
 
143
- ## Converting an `AsyncIterable`/`Iterable` to `ReadableStream`
135
+ Note: `[Symbol.asyncIterator]()` will not restart the reader and read from start of the stream. Reader is not restartable and streams are not seekable.
136
+
137
+ ### Converting an `AsyncIterable`/`Iterable` to `ReadableStream`
138
+
139
+ > Notes: this feature is part of [Streams Standard](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/from_static).
144
140
 
145
141
  ```ts
146
142
  const iterable = [1, 2, 3].values();
147
- const readable = iterableGetReadable(iterable);
143
+ const readable = readableStreamFrom(iterable);
148
144
 
149
145
  readable.pipeTo(stream.writable); // Will write 1, 2, 3.
150
146
  ```
151
147
 
148
+ Note: `readableStreamFrom()` will call `[Symbol.iterator]()` initially to restart the iteration where possible.
149
+
152
150
  ## Others
153
151
 
154
152
  ### Typed `Observable`
@@ -157,9 +155,9 @@ readable.pipeTo(stream.writable); // Will write 1, 2, 3.
157
155
 
158
156
  ### Producer-consumer queue
159
157
 
160
- `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.
158
+ `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.
161
159
 
162
- Compare to pull-based queue, a push-based queue is easier 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.
160
+ 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.
163
161
 
164
162
  For a full-featured producer-consumer queue that supports flow control, use `ReadableStream` instead.
165
163
 
@@ -195,11 +193,11 @@ The `generatorWithLastValue()` and `asyncGeneratorWithLastValue()` helps bridge
195
193
  ```ts
196
194
  const generator = generatorWithLastValue(
197
195
  (function* () {
198
- yield 1;
199
- yield 2;
200
- yield 3;
196
+ yield 1; // { done: false, value: 1 }
197
+ yield 2; // { done: false, value: 2 }
198
+ yield 3; // { done: false, value: 3 }
201
199
 
202
- return 'end';
200
+ return 'end'; // { done: true, value: 'end' }
203
201
  })()
204
202
  );
205
203
 
@@ -222,6 +220,23 @@ const generator = generatorWithLastValue(
222
220
  );
223
221
  ```
224
222
 
223
+ ## `Array.prototype` ports
224
+
225
+ We ported majority of functions from `Array.prototype.*` to `iterable*`.
226
+
227
+ ```ts
228
+ import { iterableIncludes, iterableReduce } from 'iter-fest'; // Via default exports.
229
+ import { iterableSome } from 'iter-fest/iterableSome'; // Via named exports.
230
+
231
+ const iterable: Iterable<number> = [1, 2, 3, 4, 5].values();
232
+
233
+ console.log(iterableIncludes(iterable, 3)); // Prints "true".
234
+ console.log(iterableReduce(iterable, (sum, value) => sum + value, 0)); // Prints "15".
235
+ console.log(iterableSome(iterable, value => value % 2)); // Prints "true".
236
+ ```
237
+
238
+ 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).
239
+
225
240
  ## Behaviors
226
241
 
227
242
  ### How this compares to the TC39 proposals?
@@ -270,18 +285,21 @@ Generator has more functionalities than iterator and array. It is not recommende
270
285
  - Generator can define the return value
271
286
  - `return { done: true, value: 'the very last value' }`
272
287
  - Iterating generator using for-loop will not get any values from `{ done: true }`
288
+ - The `generatorWithLastValue()` will help capturing and retrieving the last return value
273
289
  - Generator can receive feedback values from its iterator
274
290
  - `generator.next('something')`, the feedback can be assigned to variable via `const feedback = yield;`
275
291
  - For-loop cannot send feedbacks to generator
276
292
 
277
293
  ### When should I use `Iterable`, `IterableIterator` and `Iterator`?
278
294
 
279
- 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`.
295
+ 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.
280
296
 
281
297
  ```ts
282
- function transform<T>(iterable: Iterable<T>): IterableIterator<T>;
298
+ function myFunction<T>(input: Iterable<T>): IterableIterator<T>;
283
299
  ```
284
300
 
301
+ `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.
302
+
285
303
  ### What is on the roadmap?
286
304
 
287
305
  We are planning to bring iterables and its siblings together, including:
@@ -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":[]}
@@ -1,9 +1,9 @@
1
- // src/iterableGetReadable.ts
1
+ // src/readableStreamFrom.ts
2
2
  function isIterable(iterable) {
3
3
  return !!(iterable && typeof iterable === "object" && Symbol.iterator in iterable);
4
4
  }
5
- function iterableGetReadable(iterable) {
6
- const iterator = isIterable(iterable) ? iterable[Symbol.iterator]() : iterable[Symbol.asyncIterator]();
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
- iterableGetReadable
20
+ readableStreamFrom
21
21
  };
22
- //# sourceMappingURL=chunk-MOBXUTO5.mjs.map
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,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
@@ -2,6 +2,7 @@ export { CompleteFunction, ErrorFunction, NextFunction, Observable, Observer, St
2
2
  export { PushAsyncIterableIterator } from './iter-fest.pushAsyncIterableIterator.mjs';
3
3
  export { SymbolObservable } from './iter-fest.symbolObservable.mjs';
4
4
  export { AsyncGeneratorWithLastValue, asyncGeneratorWithLastValue } from './iter-fest.asyncGeneratorWithLastValue.mjs';
5
+ export { asyncIteratorToAsyncIterable } from './iter-fest.asyncIteratorToAsyncIterable.mjs';
5
6
  export { GeneratorWithLastValue, generatorWithLastValue } from './iter-fest.generatorWithLastValue.mjs';
6
7
  export { iterableAt } from './iter-fest.iterableAt.mjs';
7
8
  export { iterableConcat } from './iter-fest.iterableConcat.mjs';
@@ -13,7 +14,6 @@ export { iterableFindIndex } from './iter-fest.iterableFindIndex.mjs';
13
14
  export { iterableFindLast } from './iter-fest.iterableFindLast.mjs';
14
15
  export { iterableFindLastIndex } from './iter-fest.iterableFindLastIndex.mjs';
15
16
  export { iterableForEach } from './iter-fest.iterableForEach.mjs';
16
- export { iterableGetReadable } from './iter-fest.iterableGetReadable.mjs';
17
17
  export { iterableIncludes } from './iter-fest.iterableIncludes.mjs';
18
18
  export { iterableIndexOf } from './iter-fest.iterableIndexOf.mjs';
19
19
  export { iterableJoin } from './iter-fest.iterableJoin.mjs';
@@ -27,5 +27,6 @@ export { iterableToString } from './iter-fest.iterableToString.mjs';
27
27
  export { iteratorToIterable } from './iter-fest.iteratorToIterable.mjs';
28
28
  export { observableFromAsync } from './iter-fest.observableFromAsync.mjs';
29
29
  export { observableSubscribeAsReadable } from './iter-fest.observableSubscribeAsReadable.mjs';
30
+ export { readableStreamFrom } from './iter-fest.readableStreamFrom.mjs';
30
31
  export { readerValues } from './iter-fest.readerValues.mjs';
31
32
  import 'core-js-pure/full/observable';
@@ -2,6 +2,7 @@ export { CompleteFunction, ErrorFunction, NextFunction, Observable, Observer, St
2
2
  export { PushAsyncIterableIterator } from './iter-fest.pushAsyncIterableIterator.js';
3
3
  export { SymbolObservable } from './iter-fest.symbolObservable.js';
4
4
  export { AsyncGeneratorWithLastValue, asyncGeneratorWithLastValue } from './iter-fest.asyncGeneratorWithLastValue.js';
5
+ export { asyncIteratorToAsyncIterable } from './iter-fest.asyncIteratorToAsyncIterable.js';
5
6
  export { GeneratorWithLastValue, generatorWithLastValue } from './iter-fest.generatorWithLastValue.js';
6
7
  export { iterableAt } from './iter-fest.iterableAt.js';
7
8
  export { iterableConcat } from './iter-fest.iterableConcat.js';
@@ -13,7 +14,6 @@ export { iterableFindIndex } from './iter-fest.iterableFindIndex.js';
13
14
  export { iterableFindLast } from './iter-fest.iterableFindLast.js';
14
15
  export { iterableFindLastIndex } from './iter-fest.iterableFindLastIndex.js';
15
16
  export { iterableForEach } from './iter-fest.iterableForEach.js';
16
- export { iterableGetReadable } from './iter-fest.iterableGetReadable.js';
17
17
  export { iterableIncludes } from './iter-fest.iterableIncludes.js';
18
18
  export { iterableIndexOf } from './iter-fest.iterableIndexOf.js';
19
19
  export { iterableJoin } from './iter-fest.iterableJoin.js';
@@ -27,5 +27,6 @@ export { iterableToString } from './iter-fest.iterableToString.js';
27
27
  export { iteratorToIterable } from './iter-fest.iteratorToIterable.js';
28
28
  export { observableFromAsync } from './iter-fest.observableFromAsync.js';
29
29
  export { observableSubscribeAsReadable } from './iter-fest.observableSubscribeAsReadable.js';
30
+ export { readableStreamFrom } from './iter-fest.readableStreamFrom.js';
30
31
  export { readerValues } from './iter-fest.readerValues.js';
31
32
  import 'core-js-pure/full/observable';
package/dist/iter-fest.js CHANGED
@@ -34,6 +34,7 @@ __export(src_exports, {
34
34
  PushAsyncIterableIterator: () => PushAsyncIterableIterator,
35
35
  SymbolObservable: () => SymbolObservable,
36
36
  asyncGeneratorWithLastValue: () => asyncGeneratorWithLastValue,
37
+ asyncIteratorToAsyncIterable: () => asyncIteratorToAsyncIterable,
37
38
  generatorWithLastValue: () => generatorWithLastValue,
38
39
  iterableAt: () => iterableAt,
39
40
  iterableConcat: () => iterableConcat,
@@ -45,7 +46,6 @@ __export(src_exports, {
45
46
  iterableFindLast: () => iterableFindLast,
46
47
  iterableFindLastIndex: () => iterableFindLastIndex,
47
48
  iterableForEach: () => iterableForEach,
48
- iterableGetReadable: () => iterableGetReadable,
49
49
  iterableIncludes: () => iterableIncludes,
50
50
  iterableIndexOf: () => iterableIndexOf,
51
51
  iterableJoin: () => iterableJoin,
@@ -59,6 +59,7 @@ __export(src_exports, {
59
59
  iteratorToIterable: () => iteratorToIterable,
60
60
  observableFromAsync: () => observableFromAsync,
61
61
  observableSubscribeAsReadable: () => observableSubscribeAsReadable,
62
+ readableStreamFrom: () => readableStreamFrom,
62
63
  readerValues: () => readerValues
63
64
  });
64
65
  module.exports = __toCommonJS(src_exports);
@@ -155,6 +156,17 @@ function asyncGeneratorWithLastValue(generator) {
155
156
  return asyncGeneratorWithLastValue2;
156
157
  }
157
158
 
159
+ // src/asyncIteratorToAsyncIterable.ts
160
+ function asyncIteratorToAsyncIterable(asyncIterator) {
161
+ const asyncIterableIterator = {
162
+ [Symbol.asyncIterator]: () => asyncIterableIterator,
163
+ next: asyncIterator.next.bind(asyncIterator),
164
+ ...asyncIterator.return ? { return: asyncIterator.return.bind(asyncIterator) } : {},
165
+ ...asyncIterator.throw ? { throw: asyncIterator.throw.bind(asyncIterator) } : {}
166
+ };
167
+ return asyncIterableIterator;
168
+ }
169
+
158
170
  // src/generatorWithLastValue.ts
159
171
  var STILL_ITERATING2 = Symbol();
160
172
  function generatorWithLastValue(generator) {
@@ -337,24 +349,6 @@ function iterableForEach(iterable, callbackfn, thisArg) {
337
349
  }
338
350
  }
339
351
 
340
- // src/iterableGetReadable.ts
341
- function isIterable(iterable) {
342
- return !!(iterable && typeof iterable === "object" && Symbol.iterator in iterable);
343
- }
344
- function iterableGetReadable(iterable) {
345
- const iterator = isIterable(iterable) ? iterable[Symbol.iterator]() : iterable[Symbol.asyncIterator]();
346
- return new ReadableStream({
347
- async pull(controller) {
348
- const result = await iterator.next();
349
- if (result.done) {
350
- controller.close();
351
- } else {
352
- controller.enqueue(result.value);
353
- }
354
- }
355
- });
356
- }
357
-
358
352
  // src/iterableIncludes.ts
359
353
  function iterableIncludes(iterable, searchElement, fromIndex = 0) {
360
354
  let index = 0;
@@ -568,6 +562,24 @@ function observableSubscribeAsReadable(observable) {
568
562
  });
569
563
  }
570
564
 
565
+ // src/readableStreamFrom.ts
566
+ function isIterable(iterable) {
567
+ return !!(iterable && typeof iterable === "object" && Symbol.iterator in iterable);
568
+ }
569
+ function readableStreamFrom(anyIterable) {
570
+ const iterator = isIterable(anyIterable) ? anyIterable[Symbol.iterator]() : anyIterable[Symbol.asyncIterator]();
571
+ return new ReadableStream({
572
+ async pull(controller) {
573
+ const result = await iterator.next();
574
+ if (result.done) {
575
+ controller.close();
576
+ } else {
577
+ controller.enqueue(result.value);
578
+ }
579
+ }
580
+ });
581
+ }
582
+
571
583
  // src/readerValues.ts
572
584
  function readerValues(reader) {
573
585
  const iterable = {
@@ -594,6 +606,7 @@ function readerValues(reader) {
594
606
  PushAsyncIterableIterator,
595
607
  SymbolObservable,
596
608
  asyncGeneratorWithLastValue,
609
+ asyncIteratorToAsyncIterable,
597
610
  generatorWithLastValue,
598
611
  iterableAt,
599
612
  iterableConcat,
@@ -605,7 +618,6 @@ function readerValues(reader) {
605
618
  iterableFindLast,
606
619
  iterableFindLastIndex,
607
620
  iterableForEach,
608
- iterableGetReadable,
609
621
  iterableIncludes,
610
622
  iterableIndexOf,
611
623
  iterableJoin,
@@ -619,6 +631,7 @@ function readerValues(reader) {
619
631
  iteratorToIterable,
620
632
  observableFromAsync,
621
633
  observableSubscribeAsReadable,
634
+ readableStreamFrom,
622
635
  readerValues
623
636
  });
624
637
  //# sourceMappingURL=iter-fest.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/Observable.ts","../src/SymbolObservable.ts","../src/private/withResolvers.ts","../src/PushAsyncIterableIterator.ts","../src/asyncGeneratorWithLastValue.ts","../src/generatorWithLastValue.ts","../src/private/toIntegerOrInfinity.ts","../src/iterableAt.ts","../src/iterableConcat.ts","../src/iterableEntries.ts","../src/iterableEvery.ts","../src/iterableFilter.ts","../src/iterableFind.ts","../src/iterableFindIndex.ts","../src/iterableFindLast.ts","../src/iterableFindLastIndex.ts","../src/iterableForEach.ts","../src/iterableGetReadable.ts","../src/iterableIncludes.ts","../src/iterableIndexOf.ts","../src/iterableJoin.ts","../src/iterableKeys.ts","../src/iterableMap.ts","../src/iterableReduce.ts","../src/iterableSlice.ts","../src/iterableSome.ts","../src/iterableToSpliced.ts","../src/iterableToString.ts","../src/iteratorToIterable.ts","../src/observableFromAsync.ts","../src/observableSubscribeAsReadable.ts","../src/readerValues.ts"],"sourcesContent":["export * from './Observable';\nexport * from './PushAsyncIterableIterator';\nexport * from './SymbolObservable';\nexport * from './asyncGeneratorWithLastValue';\nexport * from './generatorWithLastValue';\nexport * from './iterableAt';\nexport * from './iterableConcat';\nexport * from './iterableEntries';\nexport * from './iterableEvery';\nexport * from './iterableFilter';\nexport * from './iterableFind';\nexport * from './iterableFindIndex';\nexport * from './iterableFindLast';\nexport * from './iterableFindLastIndex';\nexport * from './iterableForEach';\nexport * from './iterableGetReadable';\nexport * from './iterableIncludes';\nexport * from './iterableIndexOf';\nexport * from './iterableJoin';\nexport * from './iterableKeys';\nexport * from './iterableMap';\nexport * from './iterableReduce';\nexport * from './iterableSlice';\nexport * from './iterableSome';\nexport * from './iterableToSpliced';\nexport * from './iterableToString';\nexport * from './iteratorToIterable';\nexport * from './observableFromAsync';\nexport * from './observableSubscribeAsReadable';\nexport * from './readerValues';\n","// @ts-expect-error core-js is not typed.\nimport CoreJSObservable from 'core-js-pure/full/observable';\n\nimport { SymbolObservable } from './SymbolObservable';\n\nexport interface SubscriptionObserver<T> {\n /** Sends the next value in the sequence */\n next(value: T): void;\n\n /** Sends the sequence error */\n error(errorValue: unknown): void;\n\n /** Sends the completion notification */\n complete(): void;\n\n /** A boolean value indicating whether the subscription is closed */\n get closed(): boolean;\n}\n\nexport interface Subscription {\n /** Cancels the subscription */\n unsubscribe(): void;\n\n /** A boolean value indicating whether the subscription is closed */\n get closed(): boolean;\n}\n\nexport type SubscriberFunction<T> = (observer: SubscriptionObserver<T>) => (() => void) | Subscription | void;\n\nexport type CompleteFunction = () => void;\nexport type ErrorFunction = (errorValue: unknown) => void;\nexport type NextFunction<T> = (value: T) => void;\nexport type StartFunction = (subscription: Subscription) => void;\n\nexport interface Observer<T> {\n /** Receives a completion notification */\n complete?(): void;\n\n /** Receives the sequence error */\n error?(errorValue: unknown): void;\n\n /** Receives the next value in the sequence */\n next?(value: T): void;\n\n /** Receives the subscription object when `subscribe` is called */\n start?(subscription: Subscription): void;\n}\n\nexport class Observable<T> extends CoreJSObservable {\n constructor(subscriber: SubscriberFunction<T>) {\n super(subscriber);\n }\n\n /** Subscribes to the sequence with an observer */\n subscribe(observer: Observer<T>): Subscription;\n\n /** Subscribes to the sequence with callbacks */\n subscribe(\n onNext: NextFunction<T>,\n onError?: ErrorFunction | undefined,\n onComplete?: CompleteFunction | undefined\n ): Subscription;\n\n subscribe(\n observerOrOnNext: Observer<T> | NextFunction<T>,\n onError?: ErrorFunction | undefined,\n onComplete?: CompleteFunction | undefined\n ): Subscription {\n return super.subscribe(observerOrOnNext, onError, onComplete);\n }\n\n /** Returns itself */\n [SymbolObservable](): Observable<T> {\n return this;\n }\n\n /** Converts items to an Observable */\n static of<T>(...items: T[]): Observable<T> {\n return CoreJSObservable.of(...items);\n }\n\n /** Converts an iterable to an Observable */\n static from<T>(iterable: Iterable<T>): Observable<T>;\n\n /** Converts an observable to an Observable */\n static from<T>(observable: Observable<T>): Observable<T>;\n\n static from<T>(iterableOrObservable: Iterable<T> | Observable<T>): Observable<T> {\n return CoreJSObservable.from(iterableOrObservable);\n }\n}\n","// @ts-expect-error core-js is not typed.\nimport CoreJSSymbolObservable from 'core-js-pure/features/symbol/observable';\n\nconst SymbolObservable: unique symbol = CoreJSSymbolObservable;\n\nexport { SymbolObservable };\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","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","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","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","export default function toIntegerOrInfinity(value: number): number {\n if (value === Infinity || value === -Infinity) {\n return value;\n }\n\n return ~~value;\n}\n","import toIntegerOrInfinity from './private/toIntegerOrInfinity';\n\n/**\n * Returns the item located at the specified index.\n *\n * @param index The zero-based index of the desired code unit. A negative index will count back from the last item.\n */\nexport function iterableAt<T>(iterable: Iterable<T>, index: number): T | undefined {\n let currentIndex = 0;\n\n index = toIntegerOrInfinity(index);\n\n if (!isFinite(index)) {\n return;\n }\n\n if (index < 0) {\n throw new TypeError('index cannot be a negative finite number');\n }\n\n for (const value of iterable) {\n if (currentIndex++ === index) {\n return value;\n }\n }\n\n return undefined;\n}\n","/**\n * Combines two or more iterables.\n * This method returns a new iterable without modifying any existing iterables.\n *\n * @param items Additional iterables and/or items to add to the end of the iterable.\n */\nexport function iterableConcat<T>(iterable: Iterable<T>, ...items: Iterable<T>[]): IterableIterator<T>;\n\n/**\n * Combines two or more iterables.\n * This method returns a new iterable without modifying any existing iterables.\n *\n * @param items Additional iterables and/or items to add to the end of the iterable.\n */\nexport function iterableConcat<T>(iterable: Iterable<T>, ...items: (T | Iterable<T>)[]): IterableIterator<T>;\n\nexport function* iterableConcat<T>(iterable: Iterable<T>, ...items: (T | Iterable<T>)[]): IterableIterator<T> {\n yield* iterable;\n\n for (const item of items) {\n if (item && typeof item === 'object' && Symbol.iterator in item) {\n yield* item;\n } else {\n yield item;\n }\n }\n}\n","/**\n * Returns an iterable of key, value pairs for every entry in the iterable\n */\nexport function* iterableEntries<T>(iterable: Iterable<T>): IterableIterator<[number, T]> {\n let index = 0;\n\n for (const value of iterable) {\n yield [index++, value];\n }\n}\n","/**\n * Determines whether all the members of an iterable 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 iterable until the predicate returns a value\n * which is coercible to the Boolean value false, or until the end of the iterable.\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 */\nexport function iterableEvery<T, S extends T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, iterable: Iterable<T>) => value is S,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: any\n): iterable is S[];\n\n/**\n * Determines whether all the members of an iterable 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 iterable until the predicate returns a value\n * which is coercible to the Boolean value false, or until the end of the iterable.\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 */\nexport function iterableEvery<T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, iterable: Iterable<T>) => unknown,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: any\n): boolean;\n\nexport function iterableEvery<T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, iterable: Iterable<T>) => unknown,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg: any = undefined\n): boolean {\n let index = 0;\n\n if (typeof predicate !== 'function') {\n throw new TypeError(`${predicate} is not a function`);\n }\n\n const boundPredicate = predicate.bind(thisArg);\n\n for (const value of iterable) {\n if (!boundPredicate(value, index++, iterable)) {\n return false;\n }\n }\n\n return true;\n}\n","/**\n * Returns the elements of an iterable 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 iterable.\n * @param thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.\n */\nexport function iterableFilter<T, S extends T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, iterable: Iterable<T>) => value is S,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: unknown\n): IterableIterator<S>;\n\n/**\n * Returns the elements of an iterable 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 iterable.\n * @param thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.\n */\nexport function iterableFilter<T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, iterable: Iterable<T>) => unknown,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: any\n): IterableIterator<T>;\n\nexport function* iterableFilter<T, S extends T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, iterable: Iterable<T>) => unknown,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: unknown\n): IterableIterator<S> {\n let index = 0;\n\n if (typeof predicate !== 'function') {\n throw new TypeError(`${predicate} is not a function`);\n }\n\n const boundPredicate = predicate.bind(thisArg);\n\n for (const value of iterable) {\n if (boundPredicate(value, index++, iterable)) {\n yield value as S;\n }\n }\n}\n","/**\n * Returns the value of the first element in the iterable where predicate is true, and undefined\n * otherwise.\n *\n * @param predicate find calls predicate once for each element of the iterable, 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 * @param thisArg If provided, it will be used as the this value for each invocation of\n * predicate. If it is not provided, undefined is used instead.\n */\nexport function iterableFind<T, S extends T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, obj: Iterable<T>) => value is S,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: any\n): S | undefined;\n\nexport function iterableFind<T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, obj: Iterable<T>) => unknown,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: any\n): T | undefined;\n\nexport function iterableFind<T, S extends T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, obj: Iterable<T>) => unknown,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: any\n): S | undefined {\n let index = 0;\n\n if (typeof predicate !== 'function') {\n throw new TypeError(`${predicate} is not a function`);\n }\n\n const boundPredicate = predicate.bind(thisArg);\n\n for (const value of iterable) {\n if (boundPredicate(value, index++, iterable)) {\n return value as S;\n }\n }\n\n return undefined;\n}\n","/**\n * Returns the index of the first element in the iterable where predicate is true, and -1\n * otherwise.\n *\n * @param predicate find calls predicate once for each element of the iterable, in ascending\n * order, until it finds one where predicate returns true. If such an element is found,\n * findIndex immediately returns that element index. Otherwise, findIndex returns -1.\n *\n * @param thisArg If provided, it will be used as the this value for each invocation of\n * predicate. If it is not provided, undefined is used instead.\n */\nexport function iterableFindIndex<T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, obj: Iterable<T>) => unknown,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: any\n): number {\n let index = 0;\n\n if (typeof predicate !== 'function') {\n throw new TypeError(`${predicate} is not a function`);\n }\n\n const boundPredicate = predicate.bind(thisArg);\n\n for (const value of iterable) {\n if (boundPredicate(value, index, iterable)) {\n return index;\n }\n\n index++;\n }\n\n return -1;\n}\n","/**\n * Returns the value of the last element in the iterable where predicate is true, and undefined\n * otherwise.\n *\n * @param predicate findLast calls predicate once for each element of the iterable, in descending\n * order, until it finds one where predicate returns true. If such an element is found, findLast\n * immediately returns that element value. Otherwise, findLast returns undefined.\n *\n * @param thisArg If provided, it will be used as the this value for each invocation of\n * predicate. If it is not provided, undefined is used instead.\n */\nexport function iterableFindLast<T, S extends T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, iterable: Iterable<T>) => value is S,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: any\n): S | undefined;\n\nexport function iterableFindLast<T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, iterable: Iterable<T>) => unknown,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: any\n): T | undefined;\n\nexport function iterableFindLast<T, S extends T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, iterable: Iterable<T>) => unknown,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: any\n): S | undefined {\n let index = 0;\n let last: S | undefined;\n\n if (typeof predicate !== 'function') {\n throw new TypeError(`${predicate} is not a function`);\n }\n\n const boundPredicate = predicate.bind(thisArg);\n\n for (const value of iterable) {\n if (boundPredicate(value, index++, iterable)) {\n last = value as S;\n }\n }\n\n return last;\n}\n","/**\n * Returns the index of the last element in the iterable where predicate is true, and -1\n * otherwise.\n *\n * @param predicate findLastIndex calls predicate once for each element of the iterable, in descending\n * order, until it finds one where predicate returns true. If such an element is found,\n * findLastIndex immediately returns that element index. Otherwise, findLastIndex returns -1.\n *\n * @param thisArg If provided, it will be used as the this value for each invocation of\n * predicate. If it is not provided, undefined is used instead.\n */\nexport function iterableFindLastIndex<T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, iterable: Iterable<T>) => unknown,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: any\n): number {\n let index = 0;\n let lastIndex: number = -1;\n\n if (typeof predicate !== 'function') {\n throw new TypeError(`${predicate} is not a function`);\n }\n\n const boundPredicate = predicate.bind(thisArg);\n\n for (const value of iterable) {\n if (boundPredicate(value, index, iterable)) {\n lastIndex = index;\n }\n\n index++;\n }\n\n return lastIndex;\n}\n","/**\n * Performs the specified action for each element in an iterable.\n *\n * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the iterable.\n *\n * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.\n */\nexport function iterableForEach<T>(\n iterable: Iterable<T>,\n callbackfn: (value: T, index: number, iterable: Iterable<T>) => void,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: any\n): void {\n let index = 0;\n\n if (typeof callbackfn !== 'function') {\n throw new TypeError(`${callbackfn} is not a function`);\n }\n\n const boundCallbackfn = callbackfn.bind(thisArg);\n\n for (const value of iterable) {\n boundCallbackfn(value, index++, iterable);\n }\n}\n","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","import toIntegerOrInfinity from './private/toIntegerOrInfinity';\n\n/**\n * Determines whether an iterable includes a certain element, returning true or false as appropriate.\n *\n * @param searchElement The element to search for.\n * @param fromIndex The position in this iterable at which to begin searching for searchElement.\n */\nexport function iterableIncludes<T>(iterable: Iterable<T>, searchElement: T, fromIndex: number = 0): boolean {\n let index = 0;\n\n fromIndex = toIntegerOrInfinity(fromIndex);\n\n if (fromIndex !== Infinity) {\n fromIndex = fromIndex === -Infinity ? 0 : fromIndex;\n\n if (fromIndex < 0) {\n // TODO: Support negative fromIndex.\n throw new TypeError('fromIndex cannot be a negative finite number');\n }\n\n for (const item of iterable) {\n if (index++ >= fromIndex && Object.is(item, searchElement)) {\n return true;\n }\n }\n }\n\n return false;\n}\n","import toIntegerOrInfinity from './private/toIntegerOrInfinity';\n\n/**\n * Returns the index of the first occurrence of a value in an iterable, or -1 if it is not present.\n *\n * @param searchElement The value to locate in the iterable.\n * @param fromIndex The iterable index at which to begin the search. If fromIndex is omitted, the search starts at index 0.\n */\nexport function iterableIndexOf<T>(iterable: Iterable<T>, searchElement: T, fromIndex: number = 0): number {\n let index = 0;\n\n fromIndex = toIntegerOrInfinity(fromIndex);\n\n if (fromIndex !== Infinity) {\n fromIndex = fromIndex === -Infinity ? 0 : fromIndex;\n\n if (fromIndex < 0) {\n // TODO: Support negative fromIndex.\n throw new TypeError('fromIndex cannot be a negative finite number');\n }\n\n for (const item of iterable) {\n if (index >= fromIndex && Object.is(item, searchElement)) {\n return index;\n }\n\n index++;\n }\n }\n\n return -1;\n}\n","/**\n * Adds all the elements of an iterable into a string, separated by the specified separator string.\n *\n * @param separator A string used to separate one element of the iterable from the next in the resulting string. If omitted, the iterable elements are separated with a comma.\n */\nexport function iterableJoin<T>(iterable: Iterable<T>, separator: string = ','): string {\n let index = 0;\n let result = '';\n\n for (const item of iterable) {\n if (index) {\n result += separator;\n }\n\n if (typeof item !== 'undefined' && item !== null) {\n result += item;\n }\n\n index++;\n }\n\n return result;\n}\n","/**\n * Returns an iterable of keys in the iterable\n */\nexport function* iterableKeys<T>(iterable: Iterable<T>): IterableIterator<number> {\n let index = 0;\n\n for (const _ of iterable) {\n yield index++;\n }\n}\n","/**\n * Calls a defined callback function on each element of an array, and returns an array that contains the results.\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 * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.\n */\nexport function* iterableMap<T, U>(\n iterable: Iterable<T>,\n callbackfn: (value: T, index: number, array: Iterable<T>) => U,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: any\n): IterableIterator<U> {\n let index = 0;\n\n if (typeof callbackfn !== 'function') {\n throw new TypeError(`${callbackfn} is not a function`);\n }\n\n for (const value of iterable) {\n yield callbackfn.call(thisArg, value, index++, iterable);\n }\n}\n","/**\n * Calls the specified callback function for all the elements in an iterable. 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 iterable.\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 iterable value.\n */\nexport function iterableReduce<T>(\n iterable: Iterable<T>,\n callbackfn: (previousValue: T, currentValue: T, currentIndex: number, iterable: Iterable<T>) => T\n): T;\n\nexport function iterableReduce<T>(\n iterable: Iterable<T>,\n callbackfn: (previousValue: T, currentValue: T, currentIndex: number, iterable: Iterable<T>) => T,\n initialValue: T\n): T;\n\n/**\n * Calls the specified callback function for all the elements in an iterable. 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 iterable.\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\nexport function iterableReduce<T, U>(\n iterable: Iterable<T>,\n callbackfn: (previousValue: U, currentValue: T, currentIndex: number, iterable: Iterable<T>) => U,\n initialValue: U\n): U;\n\nexport function iterableReduce<T, U = undefined>(\n iterable: Iterable<T>,\n callbackfn: (previousValue: U | undefined, currentValue: T, currentIndex: number, iterable: Iterable<T>) => U,\n initialValue?: U\n): U | undefined {\n let index = 0;\n let previousValue: U | undefined = initialValue;\n\n if (typeof callbackfn !== 'function') {\n throw new TypeError(`${callbackfn} is not a function`);\n }\n\n for (const currentValue of iterable) {\n previousValue = callbackfn(previousValue, currentValue, index++, iterable);\n }\n\n return previousValue;\n}\n","import toIntegerOrInfinity from './private/toIntegerOrInfinity';\n\n/**\n * Returns a copy of a section of an iterable.\n * For both start and end, a negative index can be used to indicate an offset from the end of the iterable.\n * For example, -2 refers to the second to last element of the iterable.\n *\n * @param start The beginning index of the specified portion of the iterable.\n * If start is undefined, then the slice begins at index 0.\n *\n * @param end The end index of the specified portion of the iterable. This is exclusive of the element at the index 'end'.\n * If end is undefined, then the slice extends to the end of the iterable.\n */\nexport function* iterableSlice<T>(iterable: Iterable<T>, start: number = 0, end: number = Infinity): Iterable<T> {\n let index = 0;\n\n start = toIntegerOrInfinity(start);\n start = start === -Infinity ? 0 : start;\n end = toIntegerOrInfinity(end);\n end = end === -Infinity ? 0 : end;\n\n if (start < 0) {\n throw new TypeError('start cannot be a negative finite number');\n }\n\n if (end < 0) {\n throw new TypeError('end cannot be a negative finite number');\n }\n\n if (start === Infinity) {\n return;\n }\n\n for (const item of iterable) {\n if (index >= start && index < end) {\n yield item;\n }\n\n index++;\n\n if (index > end) {\n break;\n }\n }\n}\n","/**\n * Determines whether the specified callback function returns true for any element of an iterable.\n *\n * @param predicate\n * 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 * @param thisArg\n * An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.\n */\nexport function iterableSome<T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, iterable: Iterable<T>) => unknown,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg: any = undefined\n): boolean {\n let index = 0;\n\n if (typeof predicate !== 'function') {\n throw new TypeError(`${predicate} is not a function`);\n }\n\n const boundPredicate = predicate.bind(thisArg);\n\n for (const value of iterable) {\n if (boundPredicate(value, index++, iterable)) {\n return true;\n }\n }\n\n return false;\n}\n","import toIntegerOrInfinity from './private/toIntegerOrInfinity';\n\n/**\n * Copies an array and removes elements and, if necessary, inserts new elements in their place. Returns the copied array.\n * @param start The zero-based location in the array from which to start removing elements.\n * @param deleteCount The number of elements to remove.\n * @param items Elements to insert into the copied array in place of the deleted elements.\n * @returns The copied array.\n */\nexport function iterableToSpliced<T>(\n iterable: Iterable<T>,\n start?: number | undefined,\n deleteCount?: number | undefined,\n ...items: T[]\n): Iterable<T>;\n\n/**\n * Copies an array and removes elements while returning the remaining elements.\n * @param start The zero-based location in the array from which to start removing elements.\n * @param deleteCount The number of elements to remove.\n * @returns A copy of the original array with the remaining elements.\n */\nexport function iterableToSpliced<T>(\n iterable: Iterable<T>,\n start?: number | undefined,\n deleteCount?: number | undefined\n): Iterable<T>;\n\nexport function* iterableToSpliced<T>(\n iterable: Iterable<T>,\n start: number = 0,\n deleteCount: number = 0,\n ...items: T[]\n): Iterable<T> {\n let index = 0;\n\n start = toIntegerOrInfinity(start);\n start = start === -Infinity ? 0 : start;\n\n if (start < 0) {\n throw new TypeError('start cannot be a negative finite number');\n }\n\n let inserted = false;\n\n for (const item of iterable) {\n if (index + 1 > start && !inserted) {\n yield* items;\n inserted = true;\n }\n\n if (index < start || index >= start + deleteCount) {\n yield item;\n }\n\n index++;\n }\n\n if (!inserted) {\n yield* items;\n }\n}\n","import { iterableJoin } from './iterableJoin';\n\n/**\n * Returns a string representation of an iterable.\n */\nexport function iterableToString<T>(iterable: Iterable<T>): string {\n return iterableJoin(iterable);\n}\n","export function iteratorToIterable<T>(iterator: Iterator<T>): IterableIterator<T> {\n const iterableIterator: IterableIterator<T> = {\n [Symbol.iterator]: () => iterableIterator,\n next: iterator.next.bind(iterator),\n ...(iterator.return ? { return: iterator.return.bind(iterator) } : {}),\n ...(iterator.throw ? { throw: iterator.throw.bind(iterator) } : {})\n };\n\n return iterableIterator;\n}\n","import { Observable } from './Observable';\n\nexport function observableFromAsync<T>(iterable: AsyncIterable<T>): Observable<T> {\n return new Observable(subscriber => {\n let closed = false;\n\n (async function () {\n try {\n for await (const value of iterable) {\n if (closed) {\n break;\n }\n\n subscriber.next(value);\n }\n\n subscriber.complete();\n } catch (error) {\n subscriber.error(error);\n }\n })();\n\n return () => {\n closed = true;\n };\n });\n}\n","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","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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,IAAAA,qBAA6B;;;ACA7B,wBAAmC;AAEnC,IAAM,mBAAkC,kBAAAC;;;AD6CjC,IAAM,aAAN,cAA4B,mBAAAC,QAAiB;AAAA,EAClD,YAAY,YAAmC;AAC7C,UAAM,UAAU;AAAA,EAClB;AAAA,EAYA,UACE,kBACA,SACA,YACc;AACd,WAAO,MAAM,UAAU,kBAAkB,SAAS,UAAU;AAAA,EAC9D;AAAA;AAAA,EAGA,CAAC,gBAAgB,IAAmB;AAClC,WAAO;AAAA,EACT;AAAA;AAAA,EAGA,OAAO,MAAS,OAA2B;AACzC,WAAO,mBAAAA,QAAiB,GAAG,GAAG,KAAK;AAAA,EACrC;AAAA,EAQA,OAAO,KAAQ,sBAAkE;AAC/E,WAAO,mBAAAA,QAAiB,KAAK,oBAAoB;AAAA,EACnD;AACF;;;AEzFA,4BAAuC;AAExB,SAAR,gBAA6D;AAClE,aAAO,sBAAAC,SAA2B;AACpC;;;ACHA,IAAM,QAAQ,OAAO,OAAO;AAErB,IAAM,4BAAN,M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AAA,IACX;AAAA,EACF,CAAC;AACH;;;ACxBO,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;;;ACvBO,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":["import_observable","CoreJSSymbolObservable","CoreJSObservable","coreJSPromiseWithResolvers","asyncGeneratorWithLastValue","STILL_ITERATING","generatorWithLastValue"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/Observable.ts","../src/SymbolObservable.ts","../src/private/withResolvers.ts","../src/PushAsyncIterableIterator.ts","../src/asyncGeneratorWithLastValue.ts","../src/asyncIteratorToAsyncIterable.ts","../src/generatorWithLastValue.ts","../src/private/toIntegerOrInfinity.ts","../src/iterableAt.ts","../src/iterableConcat.ts","../src/iterableEntries.ts","../src/iterableEvery.ts","../src/iterableFilter.ts","../src/iterableFind.ts","../src/iterableFindIndex.ts","../src/iterableFindLast.ts","../src/iterableFindLastIndex.ts","../src/iterableForEach.ts","../src/iterableIncludes.ts","../src/iterableIndexOf.ts","../src/iterableJoin.ts","../src/iterableKeys.ts","../src/iterableMap.ts","../src/iterableReduce.ts","../src/iterableSlice.ts","../src/iterableSome.ts","../src/iterableToSpliced.ts","../src/iterableToString.ts","../src/iteratorToIterable.ts","../src/observableFromAsync.ts","../src/observableSubscribeAsReadable.ts","../src/readableStreamFrom.ts","../src/readerValues.ts"],"sourcesContent":["export * from './Observable';\nexport * from './PushAsyncIterableIterator';\nexport * from './SymbolObservable';\nexport * from './asyncGeneratorWithLastValue';\nexport * from './asyncIteratorToAsyncIterable';\nexport * from './generatorWithLastValue';\nexport * from './iterableAt';\nexport * from './iterableConcat';\nexport * from './iterableEntries';\nexport * from './iterableEvery';\nexport * from './iterableFilter';\nexport * from './iterableFind';\nexport * from './iterableFindIndex';\nexport * from './iterableFindLast';\nexport * from './iterableFindLastIndex';\nexport * from './iterableForEach';\nexport * from './iterableIncludes';\nexport * from './iterableIndexOf';\nexport * from './iterableJoin';\nexport * from './iterableKeys';\nexport * from './iterableMap';\nexport * from './iterableReduce';\nexport * from './iterableSlice';\nexport * from './iterableSome';\nexport * from './iterableToSpliced';\nexport * from './iterableToString';\nexport * from './iteratorToIterable';\nexport * from './observableFromAsync';\nexport * from './observableSubscribeAsReadable';\nexport * from './readableStreamFrom';\nexport * from './readerValues';\n","// @ts-expect-error core-js is not typed.\nimport CoreJSObservable from 'core-js-pure/full/observable';\n\nimport { SymbolObservable } from './SymbolObservable';\n\nexport interface SubscriptionObserver<T> {\n /** Sends the next value in the sequence */\n next(value: T): void;\n\n /** Sends the sequence error */\n error(errorValue: unknown): void;\n\n /** Sends the completion notification */\n complete(): void;\n\n /** A boolean value indicating whether the subscription is closed */\n get closed(): boolean;\n}\n\nexport interface Subscription {\n /** Cancels the subscription */\n unsubscribe(): void;\n\n /** A boolean value indicating whether the subscription is closed */\n get closed(): boolean;\n}\n\nexport type SubscriberFunction<T> = (observer: SubscriptionObserver<T>) => (() => void) | Subscription | void;\n\nexport type CompleteFunction = () => void;\nexport type ErrorFunction = (errorValue: unknown) => void;\nexport type NextFunction<T> = (value: T) => void;\nexport type StartFunction = (subscription: Subscription) => void;\n\nexport interface Observer<T> {\n /** Receives a completion notification */\n complete?(): void;\n\n /** Receives the sequence error */\n error?(errorValue: unknown): void;\n\n /** Receives the next value in the sequence */\n next?(value: T): void;\n\n /** Receives the subscription object when `subscribe` is called */\n start?(subscription: Subscription): void;\n}\n\nexport class Observable<T> extends CoreJSObservable {\n constructor(subscriber: SubscriberFunction<T>) {\n super(subscriber);\n }\n\n /** Subscribes to the sequence with an observer */\n subscribe(observer: Observer<T>): Subscription;\n\n /** Subscribes to the sequence with callbacks */\n subscribe(\n onNext: NextFunction<T>,\n onError?: ErrorFunction | undefined,\n onComplete?: CompleteFunction | undefined\n ): Subscription;\n\n subscribe(\n observerOrOnNext: Observer<T> | NextFunction<T>,\n onError?: ErrorFunction | undefined,\n onComplete?: CompleteFunction | undefined\n ): Subscription {\n return super.subscribe(observerOrOnNext, onError, onComplete);\n }\n\n /** Returns itself */\n [SymbolObservable](): Observable<T> {\n return this;\n }\n\n /** Converts items to an Observable */\n static of<T>(...items: T[]): Observable<T> {\n return CoreJSObservable.of(...items);\n }\n\n /** Converts an iterable to an Observable */\n static from<T>(iterable: Iterable<T>): Observable<T>;\n\n /** Converts an observable to an Observable */\n static from<T>(observable: Observable<T>): Observable<T>;\n\n static from<T>(iterableOrObservable: Iterable<T> | Observable<T>): Observable<T> {\n return CoreJSObservable.from(iterableOrObservable);\n }\n}\n","// @ts-expect-error core-js is not typed.\nimport CoreJSSymbolObservable from 'core-js-pure/features/symbol/observable';\n\nconst SymbolObservable: unique symbol = CoreJSSymbolObservable;\n\nexport { SymbolObservable };\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","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","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","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","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","export default function toIntegerOrInfinity(value: number): number {\n if (value === Infinity || value === -Infinity) {\n return value;\n }\n\n return ~~value;\n}\n","import toIntegerOrInfinity from './private/toIntegerOrInfinity';\n\n/**\n * Returns the item located at the specified index.\n *\n * @param index The zero-based index of the desired code unit. A negative index will count back from the last item.\n */\nexport function iterableAt<T>(iterable: Iterable<T>, index: number): T | undefined {\n let currentIndex = 0;\n\n index = toIntegerOrInfinity(index);\n\n if (!isFinite(index)) {\n return;\n }\n\n if (index < 0) {\n throw new TypeError('index cannot be a negative finite number');\n }\n\n for (const value of iterable) {\n if (currentIndex++ === index) {\n return value;\n }\n }\n\n return undefined;\n}\n","/**\n * Combines two or more iterables.\n * This method returns a new iterable without modifying any existing iterables.\n *\n * @param items Additional iterables and/or items to add to the end of the iterable.\n */\nexport function iterableConcat<T>(iterable: Iterable<T>, ...items: Iterable<T>[]): IterableIterator<T>;\n\n/**\n * Combines two or more iterables.\n * This method returns a new iterable without modifying any existing iterables.\n *\n * @param items Additional iterables and/or items to add to the end of the iterable.\n */\nexport function iterableConcat<T>(iterable: Iterable<T>, ...items: (T | Iterable<T>)[]): IterableIterator<T>;\n\nexport function* iterableConcat<T>(iterable: Iterable<T>, ...items: (T | Iterable<T>)[]): IterableIterator<T> {\n yield* iterable;\n\n for (const item of items) {\n if (item && typeof item === 'object' && Symbol.iterator in item) {\n yield* item;\n } else {\n yield item;\n }\n }\n}\n","/**\n * Returns an iterable of key, value pairs for every entry in the iterable\n */\nexport function* iterableEntries<T>(iterable: Iterable<T>): IterableIterator<[number, T]> {\n let index = 0;\n\n for (const value of iterable) {\n yield [index++, value];\n }\n}\n","/**\n * Determines whether all the members of an iterable 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 iterable until the predicate returns a value\n * which is coercible to the Boolean value false, or until the end of the iterable.\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 */\nexport function iterableEvery<T, S extends T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, iterable: Iterable<T>) => value is S,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: any\n): iterable is S[];\n\n/**\n * Determines whether all the members of an iterable 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 iterable until the predicate returns a value\n * which is coercible to the Boolean value false, or until the end of the iterable.\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 */\nexport function iterableEvery<T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, iterable: Iterable<T>) => unknown,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: any\n): boolean;\n\nexport function iterableEvery<T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, iterable: Iterable<T>) => unknown,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg: any = undefined\n): boolean {\n let index = 0;\n\n if (typeof predicate !== 'function') {\n throw new TypeError(`${predicate} is not a function`);\n }\n\n const boundPredicate = predicate.bind(thisArg);\n\n for (const value of iterable) {\n if (!boundPredicate(value, index++, iterable)) {\n return false;\n }\n }\n\n return true;\n}\n","/**\n * Returns the elements of an iterable 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 iterable.\n * @param thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.\n */\nexport function iterableFilter<T, S extends T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, iterable: Iterable<T>) => value is S,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: unknown\n): IterableIterator<S>;\n\n/**\n * Returns the elements of an iterable 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 iterable.\n * @param thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.\n */\nexport function iterableFilter<T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, iterable: Iterable<T>) => unknown,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: any\n): IterableIterator<T>;\n\nexport function* iterableFilter<T, S extends T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, iterable: Iterable<T>) => unknown,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: unknown\n): IterableIterator<S> {\n let index = 0;\n\n if (typeof predicate !== 'function') {\n throw new TypeError(`${predicate} is not a function`);\n }\n\n const boundPredicate = predicate.bind(thisArg);\n\n for (const value of iterable) {\n if (boundPredicate(value, index++, iterable)) {\n yield value as S;\n }\n }\n}\n","/**\n * Returns the value of the first element in the iterable where predicate is true, and undefined\n * otherwise.\n *\n * @param predicate find calls predicate once for each element of the iterable, 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 * @param thisArg If provided, it will be used as the this value for each invocation of\n * predicate. If it is not provided, undefined is used instead.\n */\nexport function iterableFind<T, S extends T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, obj: Iterable<T>) => value is S,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: any\n): S | undefined;\n\nexport function iterableFind<T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, obj: Iterable<T>) => unknown,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: any\n): T | undefined;\n\nexport function iterableFind<T, S extends T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, obj: Iterable<T>) => unknown,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: any\n): S | undefined {\n let index = 0;\n\n if (typeof predicate !== 'function') {\n throw new TypeError(`${predicate} is not a function`);\n }\n\n const boundPredicate = predicate.bind(thisArg);\n\n for (const value of iterable) {\n if (boundPredicate(value, index++, iterable)) {\n return value as S;\n }\n }\n\n return undefined;\n}\n","/**\n * Returns the index of the first element in the iterable where predicate is true, and -1\n * otherwise.\n *\n * @param predicate find calls predicate once for each element of the iterable, in ascending\n * order, until it finds one where predicate returns true. If such an element is found,\n * findIndex immediately returns that element index. Otherwise, findIndex returns -1.\n *\n * @param thisArg If provided, it will be used as the this value for each invocation of\n * predicate. If it is not provided, undefined is used instead.\n */\nexport function iterableFindIndex<T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, obj: Iterable<T>) => unknown,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: any\n): number {\n let index = 0;\n\n if (typeof predicate !== 'function') {\n throw new TypeError(`${predicate} is not a function`);\n }\n\n const boundPredicate = predicate.bind(thisArg);\n\n for (const value of iterable) {\n if (boundPredicate(value, index, iterable)) {\n return index;\n }\n\n index++;\n }\n\n return -1;\n}\n","/**\n * Returns the value of the last element in the iterable where predicate is true, and undefined\n * otherwise.\n *\n * @param predicate findLast calls predicate once for each element of the iterable, in descending\n * order, until it finds one where predicate returns true. If such an element is found, findLast\n * immediately returns that element value. Otherwise, findLast returns undefined.\n *\n * @param thisArg If provided, it will be used as the this value for each invocation of\n * predicate. If it is not provided, undefined is used instead.\n */\nexport function iterableFindLast<T, S extends T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, iterable: Iterable<T>) => value is S,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: any\n): S | undefined;\n\nexport function iterableFindLast<T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, iterable: Iterable<T>) => unknown,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: any\n): T | undefined;\n\nexport function iterableFindLast<T, S extends T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, iterable: Iterable<T>) => unknown,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: any\n): S | undefined {\n let index = 0;\n let last: S | undefined;\n\n if (typeof predicate !== 'function') {\n throw new TypeError(`${predicate} is not a function`);\n }\n\n const boundPredicate = predicate.bind(thisArg);\n\n for (const value of iterable) {\n if (boundPredicate(value, index++, iterable)) {\n last = value as S;\n }\n }\n\n return last;\n}\n","/**\n * Returns the index of the last element in the iterable where predicate is true, and -1\n * otherwise.\n *\n * @param predicate findLastIndex calls predicate once for each element of the iterable, in descending\n * order, until it finds one where predicate returns true. If such an element is found,\n * findLastIndex immediately returns that element index. Otherwise, findLastIndex returns -1.\n *\n * @param thisArg If provided, it will be used as the this value for each invocation of\n * predicate. If it is not provided, undefined is used instead.\n */\nexport function iterableFindLastIndex<T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, iterable: Iterable<T>) => unknown,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: any\n): number {\n let index = 0;\n let lastIndex: number = -1;\n\n if (typeof predicate !== 'function') {\n throw new TypeError(`${predicate} is not a function`);\n }\n\n const boundPredicate = predicate.bind(thisArg);\n\n for (const value of iterable) {\n if (boundPredicate(value, index, iterable)) {\n lastIndex = index;\n }\n\n index++;\n }\n\n return lastIndex;\n}\n","/**\n * Performs the specified action for each element in an iterable.\n *\n * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the iterable.\n *\n * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.\n */\nexport function iterableForEach<T>(\n iterable: Iterable<T>,\n callbackfn: (value: T, index: number, iterable: Iterable<T>) => void,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: any\n): void {\n let index = 0;\n\n if (typeof callbackfn !== 'function') {\n throw new TypeError(`${callbackfn} is not a function`);\n }\n\n const boundCallbackfn = callbackfn.bind(thisArg);\n\n for (const value of iterable) {\n boundCallbackfn(value, index++, iterable);\n }\n}\n","import toIntegerOrInfinity from './private/toIntegerOrInfinity';\n\n/**\n * Determines whether an iterable includes a certain element, returning true or false as appropriate.\n *\n * @param searchElement The element to search for.\n * @param fromIndex The position in this iterable at which to begin searching for searchElement.\n */\nexport function iterableIncludes<T>(iterable: Iterable<T>, searchElement: T, fromIndex: number = 0): boolean {\n let index = 0;\n\n fromIndex = toIntegerOrInfinity(fromIndex);\n\n if (fromIndex !== Infinity) {\n fromIndex = fromIndex === -Infinity ? 0 : fromIndex;\n\n if (fromIndex < 0) {\n // TODO: Support negative fromIndex.\n throw new TypeError('fromIndex cannot be a negative finite number');\n }\n\n for (const item of iterable) {\n if (index++ >= fromIndex && Object.is(item, searchElement)) {\n return true;\n }\n }\n }\n\n return false;\n}\n","import toIntegerOrInfinity from './private/toIntegerOrInfinity';\n\n/**\n * Returns the index of the first occurrence of a value in an iterable, or -1 if it is not present.\n *\n * @param searchElement The value to locate in the iterable.\n * @param fromIndex The iterable index at which to begin the search. If fromIndex is omitted, the search starts at index 0.\n */\nexport function iterableIndexOf<T>(iterable: Iterable<T>, searchElement: T, fromIndex: number = 0): number {\n let index = 0;\n\n fromIndex = toIntegerOrInfinity(fromIndex);\n\n if (fromIndex !== Infinity) {\n fromIndex = fromIndex === -Infinity ? 0 : fromIndex;\n\n if (fromIndex < 0) {\n // TODO: Support negative fromIndex.\n throw new TypeError('fromIndex cannot be a negative finite number');\n }\n\n for (const item of iterable) {\n if (index >= fromIndex && Object.is(item, searchElement)) {\n return index;\n }\n\n index++;\n }\n }\n\n return -1;\n}\n","/**\n * Adds all the elements of an iterable into a string, separated by the specified separator string.\n *\n * @param separator A string used to separate one element of the iterable from the next in the resulting string. If omitted, the iterable elements are separated with a comma.\n */\nexport function iterableJoin<T>(iterable: Iterable<T>, separator: string = ','): string {\n let index = 0;\n let result = '';\n\n for (const item of iterable) {\n if (index) {\n result += separator;\n }\n\n if (typeof item !== 'undefined' && item !== null) {\n result += item;\n }\n\n index++;\n }\n\n return result;\n}\n","/**\n * Returns an iterable of keys in the iterable\n */\nexport function* iterableKeys<T>(iterable: Iterable<T>): IterableIterator<number> {\n let index = 0;\n\n for (const _ of iterable) {\n yield index++;\n }\n}\n","/**\n * Calls a defined callback function on each element of an array, and returns an array that contains the results.\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 * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.\n */\nexport function* iterableMap<T, U>(\n iterable: Iterable<T>,\n callbackfn: (value: T, index: number, array: Iterable<T>) => U,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: any\n): IterableIterator<U> {\n let index = 0;\n\n if (typeof callbackfn !== 'function') {\n throw new TypeError(`${callbackfn} is not a function`);\n }\n\n for (const value of iterable) {\n yield callbackfn.call(thisArg, value, index++, iterable);\n }\n}\n","/**\n * Calls the specified callback function for all the elements in an iterable. 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 iterable.\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 iterable value.\n */\nexport function iterableReduce<T>(\n iterable: Iterable<T>,\n callbackfn: (previousValue: T, currentValue: T, currentIndex: number, iterable: Iterable<T>) => T\n): T;\n\nexport function iterableReduce<T>(\n iterable: Iterable<T>,\n callbackfn: (previousValue: T, currentValue: T, currentIndex: number, iterable: Iterable<T>) => T,\n initialValue: T\n): T;\n\n/**\n * Calls the specified callback function for all the elements in an iterable. 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 iterable.\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\nexport function iterableReduce<T, U>(\n iterable: Iterable<T>,\n callbackfn: (previousValue: U, currentValue: T, currentIndex: number, iterable: Iterable<T>) => U,\n initialValue: U\n): U;\n\nexport function iterableReduce<T, U = undefined>(\n iterable: Iterable<T>,\n callbackfn: (previousValue: U | undefined, currentValue: T, currentIndex: number, iterable: Iterable<T>) => U,\n initialValue?: U\n): U | undefined {\n let index = 0;\n let previousValue: U | undefined = initialValue;\n\n if (typeof callbackfn !== 'function') {\n throw new TypeError(`${callbackfn} is not a function`);\n }\n\n for (const currentValue of iterable) {\n previousValue = callbackfn(previousValue, currentValue, index++, iterable);\n }\n\n return previousValue;\n}\n","import toIntegerOrInfinity from './private/toIntegerOrInfinity';\n\n/**\n * Returns a copy of a section of an iterable.\n * For both start and end, a negative index can be used to indicate an offset from the end of the iterable.\n * For example, -2 refers to the second to last element of the iterable.\n *\n * @param start The beginning index of the specified portion of the iterable.\n * If start is undefined, then the slice begins at index 0.\n *\n * @param end The end index of the specified portion of the iterable. This is exclusive of the element at the index 'end'.\n * If end is undefined, then the slice extends to the end of the iterable.\n */\nexport function* iterableSlice<T>(iterable: Iterable<T>, start: number = 0, end: number = Infinity): Iterable<T> {\n let index = 0;\n\n start = toIntegerOrInfinity(start);\n start = start === -Infinity ? 0 : start;\n end = toIntegerOrInfinity(end);\n end = end === -Infinity ? 0 : end;\n\n if (start < 0) {\n throw new TypeError('start cannot be a negative finite number');\n }\n\n if (end < 0) {\n throw new TypeError('end cannot be a negative finite number');\n }\n\n if (start === Infinity) {\n return;\n }\n\n for (const item of iterable) {\n if (index >= start && index < end) {\n yield item;\n }\n\n index++;\n\n if (index > end) {\n break;\n }\n }\n}\n","/**\n * Determines whether the specified callback function returns true for any element of an iterable.\n *\n * @param predicate\n * 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 * @param thisArg\n * An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.\n */\nexport function iterableSome<T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, iterable: Iterable<T>) => unknown,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg: any = undefined\n): boolean {\n let index = 0;\n\n if (typeof predicate !== 'function') {\n throw new TypeError(`${predicate} is not a function`);\n }\n\n const boundPredicate = predicate.bind(thisArg);\n\n for (const value of iterable) {\n if (boundPredicate(value, index++, iterable)) {\n return true;\n }\n }\n\n return false;\n}\n","import toIntegerOrInfinity from './private/toIntegerOrInfinity';\n\n/**\n * Copies an array and removes elements and, if necessary, inserts new elements in their place. Returns the copied array.\n * @param start The zero-based location in the array from which to start removing elements.\n * @param deleteCount The number of elements to remove.\n * @param items Elements to insert into the copied array in place of the deleted elements.\n * @returns The copied array.\n */\nexport function iterableToSpliced<T>(\n iterable: Iterable<T>,\n start?: number | undefined,\n deleteCount?: number | undefined,\n ...items: T[]\n): Iterable<T>;\n\n/**\n * Copies an array and removes elements while returning the remaining elements.\n * @param start The zero-based location in the array from which to start removing elements.\n * @param deleteCount The number of elements to remove.\n * @returns A copy of the original array with the remaining elements.\n */\nexport function iterableToSpliced<T>(\n iterable: Iterable<T>,\n start?: number | undefined,\n deleteCount?: number | undefined\n): Iterable<T>;\n\nexport function* iterableToSpliced<T>(\n iterable: Iterable<T>,\n start: number = 0,\n deleteCount: number = 0,\n ...items: T[]\n): Iterable<T> {\n let index = 0;\n\n start = toIntegerOrInfinity(start);\n start = start === -Infinity ? 0 : start;\n\n if (start < 0) {\n throw new TypeError('start cannot be a negative finite number');\n }\n\n let inserted = false;\n\n for (const item of iterable) {\n if (index + 1 > start && !inserted) {\n yield* items;\n inserted = true;\n }\n\n if (index < start || index >= start + deleteCount) {\n yield item;\n }\n\n index++;\n }\n\n if (!inserted) {\n yield* items;\n }\n}\n","import { iterableJoin } from './iterableJoin';\n\n/**\n * Returns a string representation of an iterable.\n */\nexport function iterableToString<T>(iterable: Iterable<T>): string {\n return iterableJoin(iterable);\n}\n","export function iteratorToIterable<T>(iterator: Iterator<T>): IterableIterator<T> {\n const iterableIterator: IterableIterator<T> = {\n [Symbol.iterator]: () => iterableIterator,\n next: iterator.next.bind(iterator),\n ...(iterator.return ? { return: iterator.return.bind(iterator) } : {}),\n ...(iterator.throw ? { throw: iterator.throw.bind(iterator) } : {})\n };\n\n return iterableIterator;\n}\n","import { Observable } from './Observable';\n\nexport function observableFromAsync<T>(iterable: AsyncIterable<T>): Observable<T> {\n return new Observable(subscriber => {\n let closed = false;\n\n (async function () {\n try {\n for await (const value of iterable) {\n if (closed) {\n break;\n }\n\n subscriber.next(value);\n }\n\n subscriber.complete();\n } catch (error) {\n subscriber.error(error);\n }\n })();\n\n return () => {\n closed = true;\n };\n });\n}\n","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","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","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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,IAAAA,qBAA6B;;;ACA7B,wBAAmC;AAEnC,IAAM,mBAAkC,kBAAAC;;;AD6CjC,IAAM,aAAN,cAA4B,mBAAAC,QAAiB;AAAA,EAClD,YAAY,YAAmC;AAC7C,UAAM,UAAU;AAAA,EAClB;AAAA,EAYA,UACE,kBACA,SACA,YACc;AACd,WAAO,MAAM,UAAU,kBAAkB,SAA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a,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":["import_observable","CoreJSSymbolObservable","CoreJSObservable","coreJSPromiseWithResolvers","asyncGeneratorWithLastValue","STILL_ITERATING","generatorWithLastValue"]}
@@ -13,6 +13,9 @@ import {
13
13
  import {
14
14
  PushAsyncIterableIterator
15
15
  } from "./chunk-O5SQJUKB.mjs";
16
+ import {
17
+ readableStreamFrom
18
+ } from "./chunk-YJSIVBF7.mjs";
16
19
  import {
17
20
  readerValues
18
21
  } from "./chunk-EUVK4YM7.mjs";
@@ -43,6 +46,9 @@ import {
43
46
  import {
44
47
  iterableJoin
45
48
  } from "./chunk-5CHMNKXJ.mjs";
49
+ import {
50
+ iterableFilter
51
+ } from "./chunk-ZUBHGSCW.mjs";
46
52
  import {
47
53
  iterableFind
48
54
  } from "./chunk-MNLOWKTC.mjs";
@@ -58,9 +64,6 @@ import {
58
64
  import {
59
65
  iterableForEach
60
66
  } from "./chunk-JU353VSE.mjs";
61
- import {
62
- iterableGetReadable
63
- } from "./chunk-MOBXUTO5.mjs";
64
67
  import {
65
68
  iterableIncludes
66
69
  } from "./chunk-27NJVC7K.mjs";
@@ -70,6 +73,9 @@ import {
70
73
  import {
71
74
  asyncGeneratorWithLastValue
72
75
  } from "./chunk-ANRVAYLW.mjs";
76
+ import {
77
+ asyncIteratorToAsyncIterable
78
+ } from "./chunk-P4OSZLEH.mjs";
73
79
  import {
74
80
  generatorWithLastValue
75
81
  } from "./chunk-2DE3J4J7.mjs";
@@ -86,14 +92,12 @@ import {
86
92
  import {
87
93
  iterableEvery
88
94
  } from "./chunk-5CRMPYKD.mjs";
89
- import {
90
- iterableFilter
91
- } from "./chunk-ZUBHGSCW.mjs";
92
95
  export {
93
96
  Observable,
94
97
  PushAsyncIterableIterator,
95
98
  SymbolObservable,
96
99
  asyncGeneratorWithLastValue,
100
+ asyncIteratorToAsyncIterable,
97
101
  generatorWithLastValue,
98
102
  iterableAt,
99
103
  iterableConcat,
@@ -105,7 +109,6 @@ export {
105
109
  iterableFindLast,
106
110
  iterableFindLastIndex,
107
111
  iterableForEach,
108
- iterableGetReadable,
109
112
  iterableIncludes,
110
113
  iterableIndexOf,
111
114
  iterableJoin,
@@ -119,6 +122,7 @@ export {
119
122
  iteratorToIterable,
120
123
  observableFromAsync,
121
124
  observableSubscribeAsReadable,
125
+ readableStreamFrom,
122
126
  readerValues
123
127
  };
124
128
  //# sourceMappingURL=iter-fest.mjs.map
@@ -0,0 +1,3 @@
1
+ declare function readableStreamFrom<T>(anyIterable: AsyncIterable<T> | Iterable<T>): ReadableStream<T>;
2
+
3
+ export { readableStreamFrom };
@@ -0,0 +1,3 @@
1
+ declare function readableStreamFrom<T>(anyIterable: AsyncIterable<T> | Iterable<T>): ReadableStream<T>;
2
+
3
+ export { readableStreamFrom };
@@ -17,17 +17,17 @@ var __copyProps = (to, from, except, desc) => {
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
- // src/iterableGetReadable.ts
21
- var iterableGetReadable_exports = {};
22
- __export(iterableGetReadable_exports, {
23
- iterableGetReadable: () => iterableGetReadable
20
+ // src/readableStreamFrom.ts
21
+ var readableStreamFrom_exports = {};
22
+ __export(readableStreamFrom_exports, {
23
+ readableStreamFrom: () => readableStreamFrom
24
24
  });
25
- module.exports = __toCommonJS(iterableGetReadable_exports);
25
+ module.exports = __toCommonJS(readableStreamFrom_exports);
26
26
  function isIterable(iterable) {
27
27
  return !!(iterable && typeof iterable === "object" && Symbol.iterator in iterable);
28
28
  }
29
- function iterableGetReadable(iterable) {
30
- const iterator = isIterable(iterable) ? iterable[Symbol.iterator]() : iterable[Symbol.asyncIterator]();
29
+ function readableStreamFrom(anyIterable) {
30
+ const iterator = isIterable(anyIterable) ? anyIterable[Symbol.iterator]() : anyIterable[Symbol.asyncIterator]();
31
31
  return new ReadableStream({
32
32
  async pull(controller) {
33
33
  const result = await iterator.next();
@@ -41,6 +41,6 @@ function iterableGetReadable(iterable) {
41
41
  }
42
42
  // Annotate the CommonJS export names for ESM import in node:
43
43
  0 && (module.exports = {
44
- iterableGetReadable
44
+ readableStreamFrom
45
45
  });
46
- //# sourceMappingURL=iter-fest.iterableGetReadable.js.map
46
+ //# sourceMappingURL=iter-fest.readableStreamFrom.js.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;AAAA;AAAA;AAAA;AAAA;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,7 @@
1
+ import {
2
+ readableStreamFrom
3
+ } from "./chunk-YJSIVBF7.mjs";
4
+ export {
5
+ readableStreamFrom
6
+ };
7
+ //# sourceMappingURL=iter-fest.readableStreamFrom.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iter-fest",
3
- "version": "0.1.1-main.edf2470",
3
+ "version": "0.1.1-main.f54555b",
4
4
  "description": "A collection of utilities for iterations.",
5
5
  "files": [
6
6
  "./dist/"
@@ -16,6 +16,16 @@
16
16
  "default": "./dist/iter-fest.asyncGeneratorWithLastValue.js"
17
17
  }
18
18
  },
19
+ "./asyncIteratorToAsyncIterable": {
20
+ "import": {
21
+ "types": "./dist/iter-fest.asyncIteratorToAsyncIterable.d.mts",
22
+ "default": "./dist/iter-fest.asyncIteratorToAsyncIterable.mjs"
23
+ },
24
+ "require": {
25
+ "types": "./dist/iter-fest.asyncIteratorToAsyncIterable.d.ts",
26
+ "default": "./dist/iter-fest.asyncIteratorToAsyncIterable.js"
27
+ }
28
+ },
19
29
  "./generatorWithLastValue": {
20
30
  "import": {
21
31
  "types": "./dist/iter-fest.generatorWithLastValue.d.mts",
@@ -126,16 +136,6 @@
126
136
  "default": "./dist/iter-fest.iterableForEach.js"
127
137
  }
128
138
  },
129
- "./iterableGetReadable": {
130
- "import": {
131
- "types": "./dist/iter-fest.iterableGetReadable.d.mts",
132
- "default": "./dist/iter-fest.iterableGetReadable.mjs"
133
- },
134
- "require": {
135
- "types": "./dist/iter-fest.iterableGetReadable.d.ts",
136
- "default": "./dist/iter-fest.iterableGetReadable.js"
137
- }
138
- },
139
139
  "./iterableIncludes": {
140
140
  "import": {
141
141
  "types": "./dist/iter-fest.iterableIncludes.d.mts",
@@ -286,6 +286,16 @@
286
286
  "default": "./dist/iter-fest.pushAsyncIterableIterator.js"
287
287
  }
288
288
  },
289
+ "./readableStreamFrom": {
290
+ "import": {
291
+ "types": "./dist/iter-fest.readableStreamFrom.d.mts",
292
+ "default": "./dist/iter-fest.readableStreamFrom.mjs"
293
+ },
294
+ "require": {
295
+ "types": "./dist/iter-fest.readableStreamFrom.d.ts",
296
+ "default": "./dist/iter-fest.readableStreamFrom.js"
297
+ }
298
+ },
289
299
  "./readerValues": {
290
300
  "import": {
291
301
  "types": "./dist/iter-fest.readerValues.d.mts",
@@ -368,6 +378,6 @@
368
378
  "typescript": "^5.4.5"
369
379
  },
370
380
  "dependencies": {
371
- "iter-fest": "^0.1.1-main.edf2470"
381
+ "iter-fest": "^0.1.1-main.f54555b"
372
382
  }
373
383
  }
@@ -1 +0,0 @@
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,3 +0,0 @@
1
- declare function iterableGetReadable<T>(iterable: AsyncIterable<T> | Iterable<T>): ReadableStream<T>;
2
-
3
- export { iterableGetReadable };
@@ -1,3 +0,0 @@
1
- declare function iterableGetReadable<T>(iterable: AsyncIterable<T> | Iterable<T>): ReadableStream<T>;
2
-
3
- export { iterableGetReadable };
@@ -1 +0,0 @@
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;AAAA;AAAA;AAAA;AAAA;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,7 +0,0 @@
1
- import {
2
- iterableGetReadable
3
- } from "./chunk-MOBXUTO5.mjs";
4
- export {
5
- iterableGetReadable
6
- };
7
- //# sourceMappingURL=iter-fest.iterableGetReadable.mjs.map