Skip to content
This repository has been archived by the owner on Dec 16, 2020. It is now read-only.

Latest commit

 

History

History
46 lines (33 loc) · 598 Bytes

Creators.md

File metadata and controls

46 lines (33 loc) · 598 Bytes

Creators

Creators create a new stream.

from

Create a stream from an iterable, async iterable, stream, any, or a promise for one of the previous.

import {from} from 'pure-stream';

const getString = () => Promise.resolve('hello');

from(getString())
.each(console.log)
.done();

// Output:
// h
// e
// l
// l
// o

References:
from

passthrough

Create a simple passthrough stream.

import {passthrough} from 'pure-stream';

const stream = passthrough()
.write(1)
.write(2)
.each(console.log)
.done();

// Output:
// 1
// 2
// 3