You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* fix(throwerror): fix throwerror.ts file name
* fix(exports): fix missing .js extensions in includes and ignoreelements
* chore(dependencies): update dependencies
* fix(exports): make top-level exports match the directory names
* fix lint
* add node v22.x to CI matrix
* remove esm from the build
* don't redirect stderr to /dev/null
Copy file name to clipboardexpand all lines: docs/asynciterable/converting.md
+9-9
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ Very often we have an existing data structure that we wish to convert to an asyn
17
17
The `as` method converts directly to an async-iterable, whereas with `from` method allows us to modify the collection as it is created, mimicking the the [`Array.from`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from) method.
18
18
19
19
```typescript
20
-
import { as, from } from'ix/Ix.asynciterable';
20
+
import { as, from } from'ix/asynciterable';
21
21
22
22
// As with Array and Set
23
23
const result1 =as([1, 2, 3]); // From array
@@ -52,7 +52,7 @@ IxJS also gives seamless support for Observables, for those that implement the `
52
52
53
53
```typescript
54
54
import { observableOf } from'rxjs';
55
-
import { as } from'ix/Ix.asynciterable';
55
+
import { as } from'ix/asynciterable';
56
56
57
57
const source =observableOf(1, 2, 3);
58
58
const results =as(source);
@@ -67,7 +67,7 @@ for await (const item of results) {
67
67
Streams and AsyncIterables go hand in hand as a pull to push model. DOM Streams are a newer concept, bringing streaming capabilities into the browser, and with IxJS, we can then convert those DOM streams into AsyncIterables using the `fromDOMStream` method.
Copy file name to clipboardexpand all lines: docs/asynciterable/creating.md
+9-9
Original file line number
Diff line number
Diff line change
@@ -49,7 +49,7 @@ let value, done;
49
49
Very rarely will we ever need to create these async-iterables by hand, however, if you need a collection that you can add to as well as iterate, we have the `AsyncSink` class. This class serves as a basis for some of our operators such as binding to events and DOM and Node.js streams.
50
50
51
51
```typescript
52
-
import { AsyncSink } from'ix/Ix.asynciterable';
52
+
import { AsyncSink } from'ix/asynciterable';
53
53
54
54
const sink =newAsyncSink();
55
55
sink.write(1);
@@ -75,7 +75,7 @@ let value, done;
75
75
Now that we know the basics, we can take the async-iterable from above and create an AsyncIterable from the source using the `create` method. This takes in a function which takes in an optional `AbortSignal` for cancellation, and you return the the `[Symbol.asyncIterator]` method implementation. It's up to you whether to cancel based upon the incoming `AbortSignal`, whether to throw an `AbortError` or not.
76
76
77
77
```typescript
78
-
import { create } from'ix/Ix.asynciterable';
78
+
import { create } from'ix/asynciterable';
79
79
80
80
const source = {
81
81
data: [1, 2, 3],
@@ -104,7 +104,7 @@ for await (const item of results) {
104
104
Understanding the basics gets us so far, but we want to be able to easily create async-iterable sequences, for example, from known values. To do this, we have the `of` factory function which takes any number of arguments and converts those arguments into an async-iterable sequence. This implementation mimicks that of [`Array.of`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of)
105
105
106
106
```typescript
107
-
import { of } from'ix/Ix.asynciterable';
107
+
import { of } from'ix/asynciterable';
108
108
109
109
const source =of(1, 2, 3, 4, 5);
110
110
@@ -118,7 +118,7 @@ for await (const item of source) {
118
118
There may be cases when you want to return an empty sequence, when iterated will always say it is complete. For that, we have the `empty` method.
There may also be cases where you never want the sequence to return. In the case of `never`, it can be used in places like `race` where the other sequence will always win.
Another way we can create async-iterable sequences is with a range. For example, if we want 10 numbers starting at 1, we can use the `range` factory method to call `range(1, 10)`.
149
149
150
150
```typescript
151
-
import { range } from'ix/Ix.asynciterable';
151
+
import { range } from'ix/asynciterable';
152
152
153
153
const source =range(1, 10);
154
154
@@ -174,7 +174,7 @@ for (
174
174
The `generate` method has the same parameters as this for loop, as in our example here.
175
175
176
176
```typescript
177
-
import { generate } from'ix/Ix.asynciterable';
177
+
import { generate } from'ix/asynciterable';
178
178
179
179
const source =generate(
180
180
0, // Initial State
@@ -191,7 +191,7 @@ for await (const item of source) {
191
191
In addition to the `generate` method, we have the `generateTime` which adds a time element to the sequence to delay in milliseconds between results.
192
192
193
193
```typescript
194
-
import { generate } from'ix/Ix.asynciterable';
194
+
import { generate } from'ix/asynciterable';
195
195
196
196
const source =generate(
197
197
0, // Initial State
@@ -211,7 +211,7 @@ for await (const item of source) {
211
211
There are many factory functions that carry over from RxJS over to IxJS including `interval` where we can yield a value at a specified interval. For example, we can loop through a sequence, yielding a value every 1 second.
Copy file name to clipboardexpand all lines: docs/readme.md
+9-9
Original file line number
Diff line number
Diff line change
@@ -7,8 +7,8 @@ The Interactive Extensions for JavaScript (IxJS) is a set of methods on top of `
7
7
Starting in ES6, the [`Symbol.iterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/iterator) method was introduced to allow for iteration over collections such as `Array`, `Map`, `Set` and even ``Generator`. IxJS introduces a number of creation factories and operators that operate on these `Iterable` collections lazily. Each factory can be imported from `'ix/iterable'` and operators from `'ix/iterable/operators'` such as the following creating an iterable via `of` and then transforming each item using the `map` operator. You can then iterate over the resulting collection using [`for ... of`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of) syntax, or the use of the `forEach` method.
8
8
9
9
```typescript
10
-
import { of } from'ix/Ix.iterable';
11
-
import { map } from'ix/Ix.iterable.operators';
10
+
import { of } from'ix/iterable';
11
+
import { map } from'ix/iterable/operators';
12
12
13
13
const source =of(1, 2, 3, 4, 5);
14
14
const result =source.pipe(
@@ -23,7 +23,7 @@ for (const item of result) {
23
23
Alternatively, you can program using dot-notation where we add methods to the `IterableX` object so we can program in a fluent style. We can bring in only the factories operators we need, therefore not needing to bring in the entire library with all its operators. The factories can be brought in via `'ix/add/iterable/<name>'` and operators via `'ix/add/iterable-operators/<name>'`, where `name` is replaced with the factory or operator of your choice.
@@ -66,11 +66,11 @@ That's only the beginning with IxJS and each section below covers more in detail
66
66
67
67
## AsyncIterable
68
68
69
-
In ES2018, the concept of asynchronous iteration was introduced, which allowed the same kind of iteration we had in ES6, but for asynchronous sequences using the [`Symbol.asyncIterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator) method for things such as asynchronous generators. IxJS here introduces a whole set of factories and operators on async iterables to serve as a standard class library, covering the same operators as `Iterable`, but also adding in asynchronous operations such as `race`, but also time based operations as well. Each factory such as `from`, an `of` can be imported via `'ix/Ix.asynciterable'` as well as operators such as `map` and `filter` can be imported via `'ix/Ix.asynciterable.operators'`. Once created, uou can then iterate over the resulting collection using [`for await ... of`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of) syntax, or the use of the `forEach` method.
69
+
In ES2018, the concept of asynchronous iteration was introduced, which allowed the same kind of iteration we had in ES6, but for asynchronous sequences using the [`Symbol.asyncIterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator) method for things such as asynchronous generators. IxJS here introduces a whole set of factories and operators on async iterables to serve as a standard class library, covering the same operators as `Iterable`, but also adding in asynchronous operations such as `race`, but also time based operations as well. Each factory such as `from`, an `of` can be imported via `'ix/asynciterable'` as well as operators such as `map` and `filter` can be imported via `'ix/asynciterable/operators'`. Once created, uou can then iterate over the resulting collection using [`for await ... of`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of) syntax, or the use of the `forEach` method.
@@ -92,8 +92,8 @@ for await (const item of results) {
92
92
The [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) for the web brought in a new way to think about getting data using Promises instead of the legacy `XMLHttpRequest` API. With this also brought in the idea of cancellation via the [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) and [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal), also known as the Abort API. IxJS also supports this with a number of async aggregate operations such as `first`, `last` accepting an `AbortSignal` but also introducing `AbortSignal` support to pass through the entire chain. This section gives a very brief introduction for support but is documented later on below.
@@ -123,7 +123,7 @@ for await (const item of result) {
123
123
If you prefer the fluent style of method chaining, IxJS also supports this for async-iterables via the `AsyncIterableX` object. Then you can add the factories or operators of your choosing without bringing in the entire library. The factories can be brought in via `'ix/add/asynciterable/<name>'` and operators via `'ix/add/asynciterable-operators/<name>'`, where `name` is replaced with the factory or operator of your choice.
0 commit comments