Source Location: packages/core/src/source.ts#L653
Signature
1 | function fromArray<T>(array: ArrayLike<T>): Source<T> |
Creates a Source from the given array/array-like. The values of the array will be synchronously emitted by the created source upon each subscription.
Parameters
Parameter | Type | Description |
---|
array |
| The array/array-like to iterate over. |
Returns
Type | Description |
---|
| The created source. |
Example Usage
1 | pipe(fromArray([1, 2, 3, 4]), subscribe(Sink(console.log))); |
2 | // Logs: |
3 | // Push(1), Push(2), Push(3), Push(4) |
4 | // End |
Example Usage
1 | pipe( |
2 | fromArray({ length: 5, 0: 'foo', 3: 'bar' }), |
3 | subscribe(Sink(console.log)) |
4 | ) |
5 | // Logs: |
6 | // Push('foo'), Push(undefined), Push(undefined), Push('bar'), |
7 | // Push(undefined) |
8 | // End |
See Also