2.0.2 • Published 6 years ago

functional-streams v2.0.2

Weekly downloads
4
License
ISC
Repository
github
Last release
6 years ago

Functional Streams

CircleCI

Provides four native Node streams that mirror the behaviour of basic FP array manipulations. As they extend directly from Node native streams, they can be piped and emit events as you are used to. No runtime dependencies, typescript definitions included.

const FS = require('functional-streams');

Map

const mapStream = new FS.Map((n) => n + 2);

Filter

const filterStream = new FS.Filter((n) => n % 2 === 0);

Reduce

Provides a then method so this can be used in a promise-like fashion to get the end result.

const reduceStream = new FS.Reduce((sum, n) => sum + n, 0);

reduceStream.write(0);
reduceStream.write(1);
reduceStream.write(2);
reduceStream.write(3);
reduceStream.end(4);

reduceStream.then((result) => {
	console.log(result); // 10
});

Batch

const batchStream = new FS.Batch(3);

batchStream.write(0);
batchStream.write(1);
batchStream.write(2);
batchStream.write(3);
batchStream.end(4);

batchStream.read(); // [0, 1, 2];
batchStream.read(); // [3, 4];
2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.0.11

6 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago