iter-fest 0.1.1-main.cc53108 → 0.1.1-main.cd8f1a7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/README.md +57 -31
  2. package/dist/chunk-72AEHTPQ.mjs +38 -0
  3. package/dist/chunk-72AEHTPQ.mjs.map +1 -0
  4. package/dist/{chunk-KYMTQJIJ.mjs → chunk-DC2ZV7KQ.mjs} +1 -1
  5. package/dist/chunk-DC2ZV7KQ.mjs.map +1 -0
  6. package/dist/{chunk-TQCZXEK7.mjs → chunk-JVR6BUJA.mjs} +1 -1
  7. package/dist/chunk-JVR6BUJA.mjs.map +1 -0
  8. package/dist/chunk-NLXKATXE.mjs +10 -0
  9. package/dist/chunk-NLXKATXE.mjs.map +1 -0
  10. package/dist/{chunk-EUVK4YM7.mjs → chunk-RVIERPEV.mjs} +6 -5
  11. package/dist/chunk-RVIERPEV.mjs.map +1 -0
  12. package/dist/{chunk-YLERARWI.mjs → chunk-S2LECQKY.mjs} +1 -1
  13. package/dist/chunk-S2LECQKY.mjs.map +1 -0
  14. package/dist/iter-fest.asyncIteratorFrom.d.mts +10 -0
  15. package/dist/iter-fest.asyncIteratorFrom.d.ts +10 -0
  16. package/dist/iter-fest.asyncIteratorFrom.js +44 -0
  17. package/dist/iter-fest.asyncIteratorFrom.js.map +1 -0
  18. package/dist/iter-fest.asyncIteratorFrom.mjs +7 -0
  19. package/dist/iter-fest.asyncIteratorToArray.d.mts +1 -4
  20. package/dist/iter-fest.asyncIteratorToArray.d.ts +1 -4
  21. package/dist/iter-fest.asyncIteratorToArray.js.map +1 -1
  22. package/dist/iter-fest.asyncIteratorToArray.mjs +1 -1
  23. package/dist/iter-fest.d.mts +3 -1
  24. package/dist/iter-fest.d.ts +3 -1
  25. package/dist/iter-fest.iteratorFrom.d.mts +1 -3
  26. package/dist/iter-fest.iteratorFrom.d.ts +1 -3
  27. package/dist/iter-fest.iteratorFrom.js.map +1 -1
  28. package/dist/iter-fest.iteratorFrom.mjs +1 -1
  29. package/dist/iter-fest.iteratorToArray.d.mts +1 -4
  30. package/dist/iter-fest.iteratorToArray.d.ts +1 -4
  31. package/dist/iter-fest.iteratorToArray.js.map +1 -1
  32. package/dist/iter-fest.iteratorToArray.mjs +1 -1
  33. package/dist/iter-fest.js +67 -29
  34. package/dist/iter-fest.js.map +1 -1
  35. package/dist/iter-fest.mjs +29 -21
  36. package/dist/iter-fest.observableValues.d.mts +7 -0
  37. package/dist/iter-fest.observableValues.d.ts +7 -0
  38. package/dist/iter-fest.observableValues.js +102 -0
  39. package/dist/iter-fest.observableValues.js.map +1 -0
  40. package/dist/iter-fest.observableValues.mjs +9 -0
  41. package/dist/iter-fest.observableValues.mjs.map +1 -0
  42. package/dist/iter-fest.readableStreamValues.d.mts +3 -0
  43. package/dist/iter-fest.readableStreamValues.d.ts +3 -0
  44. package/dist/{iter-fest.readerValues.js → iter-fest.readableStreamValues.js} +10 -9
  45. package/dist/iter-fest.readableStreamValues.js.map +1 -0
  46. package/dist/iter-fest.readableStreamValues.mjs +7 -0
  47. package/dist/iter-fest.readableStreamValues.mjs.map +1 -0
  48. package/package.json +27 -7
  49. package/dist/chunk-EUVK4YM7.mjs.map +0 -1
  50. package/dist/chunk-KYMTQJIJ.mjs.map +0 -1
  51. package/dist/chunk-TQCZXEK7.mjs.map +0 -1
  52. package/dist/chunk-YLERARWI.mjs.map +0 -1
  53. package/dist/iter-fest.readerValues.d.mts +0 -3
  54. package/dist/iter-fest.readerValues.d.ts +0 -3
  55. package/dist/iter-fest.readerValues.js.map +0 -1
  56. package/dist/iter-fest.readerValues.mjs +0 -7
  57. /package/dist/{iter-fest.readerValues.mjs.map → iter-fest.asyncIteratorFrom.mjs.map} +0 -0
package/README.md CHANGED
@@ -18,19 +18,24 @@ npm install iter-fest
18
18
 
19
19
  ## Conversions
20
20
 
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) |
29
-
30
- To convert `Observable` to `AsyncIterableIterator`, [use `ReadableStream` as intermediate format](#converting-an-observable-to-asynciterableiterator).
21
+ | From | To | Function |
22
+ | -------------------------- | ----------------------- | ------------------------------------------------------------------------------- |
23
+ | `Iterator` | `IterableIterator` | [`iteratorToIterable`](#converting-an-iterator-to-iterable) |
24
+ | `AsyncIterator` | `AsyncIterableIterator` | [`asyncIteratorToAsyncIterable`](#converting-an-iterator-to-iterable) |
25
+ | `Observable` | `ReadableStream` | [`observableSubscribeAsReadable`](#converting-an-observable-to-readablestream) |
26
+ | `ReadableStream` | `AsyncIterableIterator` | [`readableStreamValues`](#converting-a-readablestream-to-asynciterableiterator) |
27
+ | `AsyncIterable` | `Observable` | [`observableFromAsync`](#converting-an-asynciterable-to-observable) |
28
+ | `AsyncIterable`/`Iterable` | `ReadableStream` | [`readableStreamFrom`](#converting-an-asynciterableiterable-to-readablestream) |
29
+ | `Observable` | `AsyncIterableIterator` | [`observableValues`](#converting-an-observable-to-asynciterableiterator) |
31
30
 
32
31
  ### Converting an iterator to iterable
33
32
 
33
+ ```ts
34
+ function iteratorToIterable<T>(iterator: Iterator<T>): IterableIterator<T>
35
+
36
+ function asyncIteratorToAsyncIterable<T>(asyncIterator: AsyncIterator<T>): AsyncIterableIterator<T>
37
+ ```
38
+
34
39
  `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.
35
40
 
36
41
  ```ts
@@ -55,26 +60,12 @@ for (const value of iteratorToIterable(iterate())) {
55
60
 
56
61
  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.
57
62
 
58
- ### Converting an `Observable` to `AsyncIterableIterator`
59
-
60
- `ReadableStream` can be used as an intermediate format when converting an `Observable` to `AsyncIterableIterator`.
61
-
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.
63
+ ### Converting an `AsyncIterable` to `Observable`
63
64
 
64
65
  ```ts
65
- const observable = Observable.from([1, 2, 3]);
66
- const readable = observableSubscribeAsReadable(observable);
67
- const iterable = readerValues(readable.getReader());
68
-
69
- for await (const value of iterable) {
70
- console.log(value); // Prints "1", "2", "3".
71
- }
66
+ function observableFromAsync<T>(iterable: AsyncIterable<T>): Observable<T>
72
67
  ```
73
68
 
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
-
76
- ### Converting an `AsyncIterable` to `Observable`
77
-
78
69
  `Observable.from` converts `Iterable` into `Observable`. However, it does not convert `AsyncIterable`.
79
70
 
80
71
  `observableFromAsync` will convert `AsyncIterable` into `Observable`. It will try to restart the iteration by calling `[Symbol.asyncIterator]()`.
@@ -98,6 +89,10 @@ Note: It is not recommended to convert `AsyncGenerator` to an `Observable`. `Asy
98
89
 
99
90
  ### Converting an `Observable` to `ReadableStream`
100
91
 
92
+ ```ts
93
+ function observableSubscribeAsReadable<T>(observable: Observable<T>): ReadableStream<T>
94
+ ```
95
+
101
96
  `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.
102
97
 
103
98
  Note: `Observable` is push-based and it does not support flow control. When converting to `ReadableStream`, the internal buffer could build up quickly.
@@ -109,12 +104,16 @@ const readable = observableSubscribeAsReadable(observable);
109
104
  readable.pipeTo(stream.writable); // Will write 1, 2, 3.
110
105
  ```
111
106
 
112
- ### Converting a `ReadableStreamDefaultReader` to `AsyncIterableIterator`
107
+ ### Converting a `ReadableStream` to `AsyncIterableIterator`
108
+
109
+ ```ts
110
+ function readableStreamValues`<T>(readable: ReadableStream<T>): AsyncIterableIterator<T>
111
+ ```
113
112
 
114
- `readerValues` will convert default reader of `ReadableStream` into an `AsyncIterableIterator` to use in for-loop.
113
+ `readableStreamValues` allow iteration of `ReadableStream` as an `AsyncIterableIterator`.
115
114
 
116
115
  ```ts
117
- const readableStream = new ReadableStream({
116
+ const readable = new ReadableStream({
118
117
  start(controller) {
119
118
  controller.enqueue(1);
120
119
  controller.enqueue(2);
@@ -125,17 +124,23 @@ const readableStream = new ReadableStream({
125
124
  }
126
125
  });
127
126
 
128
- const iterable = readerValues(readableStream.getReader());
127
+ const iterable = readableStreamValues(readable);
129
128
 
130
129
  for await (const value of iterable) {
131
130
  console.log(value); // Prints "1", "2", "3".
132
131
  }
133
132
  ```
134
133
 
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.
134
+ Note: The stream will be locked as soon as the iterable is created. When using iterating outside of for-loop, make sure to call `AsyncIterator.return` when the iteration is done to release the lock on the stream.
135
+
136
+ Note: `[Symbol.asyncIterator]()` will not restart the stream.
136
137
 
137
138
  ### Converting an `AsyncIterable`/`Iterable` to `ReadableStream`
138
139
 
140
+ ```ts
141
+ function readableStreamFrom<T>(anyIterable: AsyncIterable<T> | Iterable<T>): ReadableStream<T>
142
+ ```
143
+
139
144
  > Notes: this feature is part of [Streams Standard](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/from_static).
140
145
 
141
146
  ```ts
@@ -147,6 +152,27 @@ readable.pipeTo(stream.writable); // Will write 1, 2, 3.
147
152
 
148
153
  Note: `readableStreamFrom()` will call `[Symbol.iterator]()` initially to restart the iteration where possible.
149
154
 
155
+ ### Converting an `Observable` to `AsyncIterableIterator`
156
+
157
+ ```ts
158
+ function observableValues<T>(observable: Observable<T>): AsyncIterableIterator<T>
159
+ ```
160
+
161
+ `Observable` can be converted to `AsyncIterableIterator` for easier consumption.
162
+
163
+ ```ts
164
+ const observable = Observable.from([1, 2, 3]);
165
+ const iterable = observableValues(readable);
166
+
167
+ for await (const value of iterable) {
168
+ console.log(value); // Prints "1", "2", "3".
169
+ }
170
+ ```
171
+
172
+ Note: `Observable` is push-based and it does not support flow control. When converting to `AsyncIterableIterator`, the internal buffer could build up quickly.
173
+
174
+ Note: when the observable throw an exception via `observer.error()`, it will become rejection of `AsyncIterator.next()`. The exception will be hoisted back to the caller.
175
+
150
176
  ## Others
151
177
 
152
178
  ### Typed `Observable`
@@ -0,0 +1,38 @@
1
+ import {
2
+ readableStreamValues
3
+ } from "./chunk-RVIERPEV.mjs";
4
+ import {
5
+ observableSubscribeAsReadable
6
+ } from "./chunk-EIIP7YWB.mjs";
7
+
8
+ // src/observableValues.ts
9
+ function observableValues(observable) {
10
+ const readable = observableSubscribeAsReadable(observable);
11
+ const iterable = readableStreamValues(readable);
12
+ const cancellableIterable = {
13
+ [Symbol.asyncIterator]() {
14
+ return cancellableIterable;
15
+ },
16
+ next() {
17
+ return iterable.next();
18
+ },
19
+ return() {
20
+ var _a;
21
+ try {
22
+ return ((_a = iterable.return) == null ? void 0 : _a.call(iterable)) ?? Promise.resolve({ done: true, value: void 0 });
23
+ } finally {
24
+ readable.cancel();
25
+ }
26
+ },
27
+ throw(error) {
28
+ var _a;
29
+ return ((_a = iterable.throw) == null ? void 0 : _a.call(iterable, error)) ?? Promise.resolve({ done: true, value: void 0 });
30
+ }
31
+ };
32
+ return cancellableIterable;
33
+ }
34
+
35
+ export {
36
+ observableValues
37
+ };
38
+ //# sourceMappingURL=chunk-72AEHTPQ.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/observableValues.ts"],"sourcesContent":["import type { Observable } from './Observable';\nimport { observableSubscribeAsReadable } from './observableSubscribeAsReadable';\nimport { readableStreamValues } from './readableStreamValues';\n\nexport function observableValues<T>(observable: Observable<T>): AsyncIterableIterator<T> {\n const readable = observableSubscribeAsReadable(observable);\n const iterable = readableStreamValues(readable);\n\n const cancellableIterable: AsyncIterableIterator<T> = {\n [Symbol.asyncIterator]() {\n return cancellableIterable;\n },\n next() {\n return iterable.next();\n },\n return() {\n try {\n return iterable.return?.() ?? Promise.resolve({ done: true, value: undefined });\n } finally {\n readable.cancel();\n }\n },\n throw(error) {\n return iterable.throw?.(error) ?? Promise.resolve({ done: true, value: undefined });\n }\n };\n\n return cancellableIterable;\n}\n"],"mappings":";;;;;;;;AAIO,SAAS,iBAAoB,YAAqD;AACvF,QAAM,WAAW,8BAA8B,UAAU;AACzD,QAAM,WAAW,qBAAqB,QAAQ;AAE9C,QAAM,sBAAgD;AAAA,IACpD,CAAC,OAAO,aAAa,IAAI;AACvB,aAAO;AAAA,IACT;AAAA,IACA,OAAO;AACL,aAAO,SAAS,KAAK;AAAA,IACvB;AAAA,IACA,SAAS;AAfb;AAgBM,UAAI;AACF,iBAAO,cAAS,WAAT,sCAAuB,QAAQ,QAAQ,EAAE,MAAM,MAAM,OAAO,OAAU,CAAC;AAAA,MAChF,UAAE;AACA,iBAAS,OAAO;AAAA,MAClB;AAAA,IACF;AAAA,IACA,MAAM,OAAO;AAtBjB;AAuBM,eAAO,cAAS,UAAT,kCAAiB,WAAU,QAAQ,QAAQ,EAAE,MAAM,MAAM,OAAO,OAAU,CAAC;AAAA,IACpF;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
@@ -7,4 +7,4 @@ function iteratorFrom(iteratorLike) {
7
7
  export {
8
8
  iteratorFrom
9
9
  };
10
- //# sourceMappingURL=chunk-KYMTQJIJ.mjs.map
10
+ //# sourceMappingURL=chunk-DC2ZV7KQ.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/iteratorFrom.ts"],"sourcesContent":["// @ts-expect-error core-js-pure is not typed.\nimport from from 'core-js-pure/full/iterator/from';\n\n/**\n * `.from` is a static method (unlike the others listed above) which takes an object as an argument. This method allows wrapping \"iterator-like\" objects with an iterator.\n *\n * @return Returns the object if it is already an iterator, returns a wrapping iterator if the passed object implements a callable @@iterator property.\n *\n * @link https://github.com/tc39/proposal-iterator-helpers/blob/main/README.md\n */\nexport function iteratorFrom<T>(iteratorLike: Pick<Iterator<T>, 'next'>): Iterator<T> {\n return from(iteratorLike);\n}\n"],"mappings":";AACA,OAAO,UAAU;AASV,SAAS,aAAgB,cAAsD;AACpF,SAAO,KAAK,YAAY;AAC1B;","names":[]}
@@ -7,4 +7,4 @@ function asyncIteratorToArray(asyncIteratorLike) {
7
7
  export {
8
8
  asyncIteratorToArray
9
9
  };
10
- //# sourceMappingURL=chunk-TQCZXEK7.mjs.map
10
+ //# sourceMappingURL=chunk-JVR6BUJA.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/asyncIteratorToArray.ts"],"sourcesContent":["// @ts-expect-error core-js-pure is not typed.\nimport toArray from 'core-js-pure/full/async-iterator/to-array';\n\n/**\n * When you have a non-infinite iterator which you wish to transform into an array, you can do so with the builtin toArray method.\n *\n * @return Returns an Array containing the values from the iterator.\n *\n * @link https://github.com/tc39/proposal-iterator-helpers/blob/main/README.md\n */\nexport function asyncIteratorToArray<T>(asyncIteratorLike: Pick<AsyncIterator<T>, 'next'>): Promise<T[]> {\n return toArray(asyncIteratorLike);\n}\n"],"mappings":";AACA,OAAO,aAAa;AASb,SAAS,qBAAwB,mBAAiE;AACvG,SAAO,QAAQ,iBAAiB;AAClC;","names":[]}
@@ -0,0 +1,10 @@
1
+ // src/asyncIteratorFrom.ts
2
+ import from from "core-js-pure/full/async-iterator/from";
3
+ function asyncIteratorFrom(asyncIteratorLike) {
4
+ return from(asyncIteratorLike);
5
+ }
6
+
7
+ export {
8
+ asyncIteratorFrom
9
+ };
10
+ //# sourceMappingURL=chunk-NLXKATXE.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/asyncIteratorFrom.ts"],"sourcesContent":["// @ts-expect-error core-js-pure is not typed.\nimport from from 'core-js-pure/full/async-iterator/from';\n\n/**\n * `.from` is a static method (unlike the others listed above) which takes an object as an argument. This method allows wrapping \"iterator-like\" objects with an iterator.\n *\n * @return Returns the object if it is already an iterator, returns a wrapping iterator if the passed object implements a callable @@iterator property.\n *\n * @link https://github.com/tc39/proposal-iterator-helpers/blob/main/README.md\n */\nexport function asyncIteratorFrom<T>(asyncIteratorLike: Pick<AsyncIterator<T>, 'next'>): AsyncIterator<T> {\n return from(asyncIteratorLike);\n}\n"],"mappings":";AACA,OAAO,UAAU;AASV,SAAS,kBAAqB,mBAAqE;AACxG,SAAO,KAAK,iBAAiB;AAC/B;","names":[]}
@@ -1,5 +1,6 @@
1
- // src/readerValues.ts
2
- function readerValues(reader) {
1
+ // src/readableStreamValues.ts
2
+ function readableStreamValues(readable) {
3
+ const reader = readable.getReader();
3
4
  const iterable = {
4
5
  [Symbol.asyncIterator]() {
5
6
  return iterable;
@@ -12,7 +13,7 @@ function readerValues(reader) {
12
13
  return { value: result.value };
13
14
  },
14
15
  async return() {
15
- reader.cancel();
16
+ reader.releaseLock();
16
17
  return { done: true, value: void 0 };
17
18
  }
18
19
  };
@@ -20,6 +21,6 @@ function readerValues(reader) {
20
21
  }
21
22
 
22
23
  export {
23
- readerValues
24
+ readableStreamValues
24
25
  };
25
- //# sourceMappingURL=chunk-EUVK4YM7.mjs.map
26
+ //# sourceMappingURL=chunk-RVIERPEV.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/readableStreamValues.ts"],"sourcesContent":["export function readableStreamValues<T>(readable: ReadableStream<T>): AsyncIterableIterator<T> {\n const reader = readable.getReader();\n\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 // Break/throw inside for-loop will trigger return().\n reader.releaseLock();\n\n return { done: true, value: undefined };\n }\n };\n\n return iterable;\n}\n"],"mappings":";AAAO,SAAS,qBAAwB,UAAuD;AAC7F,QAAM,SAAS,SAAS,UAAU;AAElC,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,YAAY;AAEnB,aAAO,EAAE,MAAM,MAAM,OAAO,OAAU;AAAA,IACxC;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
@@ -7,4 +7,4 @@ function iteratorToArray(iteratorLike) {
7
7
  export {
8
8
  iteratorToArray
9
9
  };
10
- //# sourceMappingURL=chunk-YLERARWI.mjs.map
10
+ //# sourceMappingURL=chunk-S2LECQKY.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/iteratorToArray.ts"],"sourcesContent":["// @ts-expect-error core-js-pure is not typed.\nimport toArray from 'core-js-pure/full/iterator/to-array';\n\n/**\n * When you have a non-infinite iterator which you wish to transform into an array, you can do so with the builtin toArray method.\n *\n * @return Returns an Array containing the values from the iterator.\n *\n * @link https://github.com/tc39/proposal-iterator-helpers/blob/main/README.md\n */\nexport function iteratorToArray<T>(iteratorLike: Pick<Iterator<T>, 'next'>): T[] {\n return toArray(iteratorLike);\n}\n"],"mappings":";AACA,OAAO,aAAa;AASb,SAAS,gBAAmB,cAA8C;AAC/E,SAAO,QAAQ,YAAY;AAC7B;","names":[]}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * `.from` is a static method (unlike the others listed above) which takes an object as an argument. This method allows wrapping "iterator-like" objects with an iterator.
3
+ *
4
+ * @return Returns the object if it is already an iterator, returns a wrapping iterator if the passed object implements a callable @@iterator property.
5
+ *
6
+ * @link https://github.com/tc39/proposal-iterator-helpers/blob/main/README.md
7
+ */
8
+ declare function asyncIteratorFrom<T>(asyncIteratorLike: Pick<AsyncIterator<T>, 'next'>): AsyncIterator<T>;
9
+
10
+ export { asyncIteratorFrom };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * `.from` is a static method (unlike the others listed above) which takes an object as an argument. This method allows wrapping "iterator-like" objects with an iterator.
3
+ *
4
+ * @return Returns the object if it is already an iterator, returns a wrapping iterator if the passed object implements a callable @@iterator property.
5
+ *
6
+ * @link https://github.com/tc39/proposal-iterator-helpers/blob/main/README.md
7
+ */
8
+ declare function asyncIteratorFrom<T>(asyncIteratorLike: Pick<AsyncIterator<T>, 'next'>): AsyncIterator<T>;
9
+
10
+ export { asyncIteratorFrom };
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from2, except, desc) => {
13
+ if (from2 && typeof from2 === "object" || typeof from2 === "function") {
14
+ for (let key of __getOwnPropNames(from2))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc(from2, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/asyncIteratorFrom.ts
31
+ var asyncIteratorFrom_exports = {};
32
+ __export(asyncIteratorFrom_exports, {
33
+ asyncIteratorFrom: () => asyncIteratorFrom
34
+ });
35
+ module.exports = __toCommonJS(asyncIteratorFrom_exports);
36
+ var import_from = __toESM(require("core-js-pure/full/async-iterator/from"));
37
+ function asyncIteratorFrom(asyncIteratorLike) {
38
+ return (0, import_from.default)(asyncIteratorLike);
39
+ }
40
+ // Annotate the CommonJS export names for ESM import in node:
41
+ 0 && (module.exports = {
42
+ asyncIteratorFrom
43
+ });
44
+ //# sourceMappingURL=iter-fest.asyncIteratorFrom.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/asyncIteratorFrom.ts"],"sourcesContent":["// @ts-expect-error core-js-pure is not typed.\nimport from from 'core-js-pure/full/async-iterator/from';\n\n/**\n * `.from` is a static method (unlike the others listed above) which takes an object as an argument. This method allows wrapping \"iterator-like\" objects with an iterator.\n *\n * @return Returns the object if it is already an iterator, returns a wrapping iterator if the passed object implements a callable @@iterator property.\n *\n * @link https://github.com/tc39/proposal-iterator-helpers/blob/main/README.md\n */\nexport function asyncIteratorFrom<T>(asyncIteratorLike: Pick<AsyncIterator<T>, 'next'>): AsyncIterator<T> {\n return from(asyncIteratorLike);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAiB;AASV,SAAS,kBAAqB,mBAAqE;AACxG,aAAO,YAAAA,SAAK,iBAAiB;AAC/B;","names":["from"]}
@@ -0,0 +1,7 @@
1
+ import {
2
+ asyncIteratorFrom
3
+ } from "./chunk-NLXKATXE.mjs";
4
+ export {
5
+ asyncIteratorFrom
6
+ };
7
+ //# sourceMappingURL=iter-fest.asyncIteratorFrom.mjs.map
@@ -1,13 +1,10 @@
1
- type AsyncIteratorLike<T> = Pick<AsyncIterator<T>, 'next'>;
2
1
  /**
3
2
  * When you have a non-infinite iterator which you wish to transform into an array, you can do so with the builtin toArray method.
4
3
  *
5
- * @param limit
6
- *
7
4
  * @return Returns an Array containing the values from the iterator.
8
5
  *
9
6
  * @link https://github.com/tc39/proposal-iterator-helpers/blob/main/README.md
10
7
  */
11
- declare function asyncIteratorToArray<T>(asyncIteratorLike: AsyncIteratorLike<T>): Promise<T[]>;
8
+ declare function asyncIteratorToArray<T>(asyncIteratorLike: Pick<AsyncIterator<T>, 'next'>): Promise<T[]>;
12
9
 
13
10
  export { asyncIteratorToArray };
@@ -1,13 +1,10 @@
1
- type AsyncIteratorLike<T> = Pick<AsyncIterator<T>, 'next'>;
2
1
  /**
3
2
  * When you have a non-infinite iterator which you wish to transform into an array, you can do so with the builtin toArray method.
4
3
  *
5
- * @param limit
6
- *
7
4
  * @return Returns an Array containing the values from the iterator.
8
5
  *
9
6
  * @link https://github.com/tc39/proposal-iterator-helpers/blob/main/README.md
10
7
  */
11
- declare function asyncIteratorToArray<T>(asyncIteratorLike: AsyncIteratorLike<T>): Promise<T[]>;
8
+ declare function asyncIteratorToArray<T>(asyncIteratorLike: Pick<AsyncIterator<T>, 'next'>): Promise<T[]>;
12
9
 
13
10
  export { asyncIteratorToArray };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/asyncIteratorToArray.ts"],"sourcesContent":["// @ts-expect-error core-js-pure is not typed.\nimport toArray from 'core-js-pure/full/async-iterator/to-array';\n\ntype AsyncIteratorLike<T> = Pick<AsyncIterator<T>, 'next'>;\n\n/**\n * When you have a non-infinite iterator which you wish to transform into an array, you can do so with the builtin toArray method.\n *\n * @param limit\n *\n * @return Returns an Array containing the values from the iterator.\n *\n * @link https://github.com/tc39/proposal-iterator-helpers/blob/main/README.md\n */\nexport function asyncIteratorToArray<T>(asyncIteratorLike: AsyncIteratorLike<T>): Promise<T[]> {\n return toArray(asyncIteratorLike);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAoB;AAab,SAAS,qBAAwB,mBAAuD;AAC7F,aAAO,gBAAAA,SAAQ,iBAAiB;AAClC;","names":["toArray"]}
1
+ {"version":3,"sources":["../src/asyncIteratorToArray.ts"],"sourcesContent":["// @ts-expect-error core-js-pure is not typed.\nimport toArray from 'core-js-pure/full/async-iterator/to-array';\n\n/**\n * When you have a non-infinite iterator which you wish to transform into an array, you can do so with the builtin toArray method.\n *\n * @return Returns an Array containing the values from the iterator.\n *\n * @link https://github.com/tc39/proposal-iterator-helpers/blob/main/README.md\n */\nexport function asyncIteratorToArray<T>(asyncIteratorLike: Pick<AsyncIterator<T>, 'next'>): Promise<T[]> {\n return toArray(asyncIteratorLike);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAoB;AASb,SAAS,qBAAwB,mBAAiE;AACvG,aAAO,gBAAAA,SAAQ,iBAAiB;AAClC;","names":["toArray"]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  asyncIteratorToArray
3
- } from "./chunk-TQCZXEK7.mjs";
3
+ } from "./chunk-JVR6BUJA.mjs";
4
4
  export {
5
5
  asyncIteratorToArray
6
6
  };
@@ -7,6 +7,7 @@ export { asyncIteratorFilter } from './iter-fest.asyncIteratorFilter.mjs';
7
7
  export { asyncIteratorFind } from './iter-fest.asyncIteratorFind.mjs';
8
8
  export { asyncIteratorFlatMap } from './iter-fest.asyncIteratorFlatMap.mjs';
9
9
  export { asyncIteratorForEach } from './iter-fest.asyncIteratorForEach.mjs';
10
+ export { asyncIteratorFrom } from './iter-fest.asyncIteratorFrom.mjs';
10
11
  export { asyncIteratorMap } from './iter-fest.asyncIteratorMap.mjs';
11
12
  export { asyncIteratorReduce } from './iter-fest.asyncIteratorReduce.mjs';
12
13
  export { asyncIteratorSome } from './iter-fest.asyncIteratorSome.mjs';
@@ -44,6 +45,7 @@ export { iteratorToSpliced } from './iter-fest.iteratorToSpliced.mjs';
44
45
  export { iteratorToString } from './iter-fest.iteratorToString.mjs';
45
46
  export { observableFromAsync } from './iter-fest.observableFromAsync.mjs';
46
47
  export { observableSubscribeAsReadable } from './iter-fest.observableSubscribeAsReadable.mjs';
48
+ export { observableValues } from './iter-fest.observableValues.mjs';
47
49
  export { readableStreamFrom } from './iter-fest.readableStreamFrom.mjs';
48
- export { readerValues } from './iter-fest.readerValues.mjs';
50
+ export { readableStreamValues } from './iter-fest.readableStreamValues.mjs';
49
51
  import 'core-js-pure/full/observable';
@@ -7,6 +7,7 @@ export { asyncIteratorFilter } from './iter-fest.asyncIteratorFilter.js';
7
7
  export { asyncIteratorFind } from './iter-fest.asyncIteratorFind.js';
8
8
  export { asyncIteratorFlatMap } from './iter-fest.asyncIteratorFlatMap.js';
9
9
  export { asyncIteratorForEach } from './iter-fest.asyncIteratorForEach.js';
10
+ export { asyncIteratorFrom } from './iter-fest.asyncIteratorFrom.js';
10
11
  export { asyncIteratorMap } from './iter-fest.asyncIteratorMap.js';
11
12
  export { asyncIteratorReduce } from './iter-fest.asyncIteratorReduce.js';
12
13
  export { asyncIteratorSome } from './iter-fest.asyncIteratorSome.js';
@@ -44,6 +45,7 @@ export { iteratorToSpliced } from './iter-fest.iteratorToSpliced.js';
44
45
  export { iteratorToString } from './iter-fest.iteratorToString.js';
45
46
  export { observableFromAsync } from './iter-fest.observableFromAsync.js';
46
47
  export { observableSubscribeAsReadable } from './iter-fest.observableSubscribeAsReadable.js';
48
+ export { observableValues } from './iter-fest.observableValues.js';
47
49
  export { readableStreamFrom } from './iter-fest.readableStreamFrom.js';
48
- export { readerValues } from './iter-fest.readerValues.js';
50
+ export { readableStreamValues } from './iter-fest.readableStreamValues.js';
49
51
  import 'core-js-pure/full/observable';
@@ -1,12 +1,10 @@
1
1
  /**
2
2
  * `.from` is a static method (unlike the others listed above) which takes an object as an argument. This method allows wrapping "iterator-like" objects with an iterator.
3
3
  *
4
- * @param limit
5
- *
6
4
  * @return Returns the object if it is already an iterator, returns a wrapping iterator if the passed object implements a callable @@iterator property.
7
5
  *
8
6
  * @link https://github.com/tc39/proposal-iterator-helpers/blob/main/README.md
9
7
  */
10
- declare function iteratorFrom<T>(iteratorLike: Iterator<T>): Iterator<T>;
8
+ declare function iteratorFrom<T>(iteratorLike: Pick<Iterator<T>, 'next'>): Iterator<T>;
11
9
 
12
10
  export { iteratorFrom };
@@ -1,12 +1,10 @@
1
1
  /**
2
2
  * `.from` is a static method (unlike the others listed above) which takes an object as an argument. This method allows wrapping "iterator-like" objects with an iterator.
3
3
  *
4
- * @param limit
5
- *
6
4
  * @return Returns the object if it is already an iterator, returns a wrapping iterator if the passed object implements a callable @@iterator property.
7
5
  *
8
6
  * @link https://github.com/tc39/proposal-iterator-helpers/blob/main/README.md
9
7
  */
10
- declare function iteratorFrom<T>(iteratorLike: Iterator<T>): Iterator<T>;
8
+ declare function iteratorFrom<T>(iteratorLike: Pick<Iterator<T>, 'next'>): Iterator<T>;
11
9
 
12
10
  export { iteratorFrom };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/iteratorFrom.ts"],"sourcesContent":["// @ts-expect-error core-js-pure is not typed.\nimport from from 'core-js-pure/full/iterator/from';\n\n/**\n * `.from` is a static method (unlike the others listed above) which takes an object as an argument. This method allows wrapping \"iterator-like\" objects with an iterator.\n *\n * @param limit\n *\n * @return Returns the object if it is already an iterator, returns a wrapping iterator if the passed object implements a callable @@iterator property.\n *\n * @link https://github.com/tc39/proposal-iterator-helpers/blob/main/README.md\n */\nexport function iteratorFrom<T>(iteratorLike: Iterator<T>): Iterator<T> {\n return from(iteratorLike);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAiB;AAWV,SAAS,aAAgB,cAAwC;AACtE,aAAO,YAAAA,SAAK,YAAY;AAC1B;","names":["from"]}
1
+ {"version":3,"sources":["../src/iteratorFrom.ts"],"sourcesContent":["// @ts-expect-error core-js-pure is not typed.\nimport from from 'core-js-pure/full/iterator/from';\n\n/**\n * `.from` is a static method (unlike the others listed above) which takes an object as an argument. This method allows wrapping \"iterator-like\" objects with an iterator.\n *\n * @return Returns the object if it is already an iterator, returns a wrapping iterator if the passed object implements a callable @@iterator property.\n *\n * @link https://github.com/tc39/proposal-iterator-helpers/blob/main/README.md\n */\nexport function iteratorFrom<T>(iteratorLike: Pick<Iterator<T>, 'next'>): Iterator<T> {\n return from(iteratorLike);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAiB;AASV,SAAS,aAAgB,cAAsD;AACpF,aAAO,YAAAA,SAAK,YAAY;AAC1B;","names":["from"]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  iteratorFrom
3
- } from "./chunk-KYMTQJIJ.mjs";
3
+ } from "./chunk-DC2ZV7KQ.mjs";
4
4
  export {
5
5
  iteratorFrom
6
6
  };
@@ -1,13 +1,10 @@
1
- type IteratorLike<T> = Pick<Iterator<T>, 'next'>;
2
1
  /**
3
2
  * When you have a non-infinite iterator which you wish to transform into an array, you can do so with the builtin toArray method.
4
3
  *
5
- * @param limit
6
- *
7
4
  * @return Returns an Array containing the values from the iterator.
8
5
  *
9
6
  * @link https://github.com/tc39/proposal-iterator-helpers/blob/main/README.md
10
7
  */
11
- declare function iteratorToArray<T>(iteratorLike: IteratorLike<T>): T[];
8
+ declare function iteratorToArray<T>(iteratorLike: Pick<Iterator<T>, 'next'>): T[];
12
9
 
13
10
  export { iteratorToArray };
@@ -1,13 +1,10 @@
1
- type IteratorLike<T> = Pick<Iterator<T>, 'next'>;
2
1
  /**
3
2
  * When you have a non-infinite iterator which you wish to transform into an array, you can do so with the builtin toArray method.
4
3
  *
5
- * @param limit
6
- *
7
4
  * @return Returns an Array containing the values from the iterator.
8
5
  *
9
6
  * @link https://github.com/tc39/proposal-iterator-helpers/blob/main/README.md
10
7
  */
11
- declare function iteratorToArray<T>(iteratorLike: IteratorLike<T>): T[];
8
+ declare function iteratorToArray<T>(iteratorLike: Pick<Iterator<T>, 'next'>): T[];
12
9
 
13
10
  export { iteratorToArray };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/iteratorToArray.ts"],"sourcesContent":["// @ts-expect-error core-js-pure is not typed.\nimport toArray from 'core-js-pure/full/iterator/to-array';\n\ntype IteratorLike<T> = Pick<Iterator<T>, 'next'>;\n\n/**\n * When you have a non-infinite iterator which you wish to transform into an array, you can do so with the builtin toArray method.\n *\n * @param limit\n *\n * @return Returns an Array containing the values from the iterator.\n *\n * @link https://github.com/tc39/proposal-iterator-helpers/blob/main/README.md\n */\nexport function iteratorToArray<T>(iteratorLike: IteratorLike<T>): T[] {\n return toArray(iteratorLike);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAoB;AAab,SAAS,gBAAmB,cAAoC;AACrE,aAAO,gBAAAA,SAAQ,YAAY;AAC7B;","names":["toArray"]}
1
+ {"version":3,"sources":["../src/iteratorToArray.ts"],"sourcesContent":["// @ts-expect-error core-js-pure is not typed.\nimport toArray from 'core-js-pure/full/iterator/to-array';\n\n/**\n * When you have a non-infinite iterator which you wish to transform into an array, you can do so with the builtin toArray method.\n *\n * @return Returns an Array containing the values from the iterator.\n *\n * @link https://github.com/tc39/proposal-iterator-helpers/blob/main/README.md\n */\nexport function iteratorToArray<T>(iteratorLike: Pick<Iterator<T>, 'next'>): T[] {\n return toArray(iteratorLike);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAoB;AASb,SAAS,gBAAmB,cAA8C;AAC/E,aAAO,gBAAAA,SAAQ,YAAY;AAC7B;","names":["toArray"]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  iteratorToArray
3
- } from "./chunk-YLERARWI.mjs";
3
+ } from "./chunk-S2LECQKY.mjs";
4
4
  export {
5
5
  iteratorToArray
6
6
  };