warp-pipes [beta]
Stream util library for nodejs.
Description
Provide transformers and some utility class to extends node stream funcionality.
- Transformers: Chunk, DropWhile, Filter, Flatten, Map, TakeWhile
- Utility: fork, pipe, split and all transforms
Installation
yarn add warp-pipes
Quickstart
import { Chunk, Map, ReadableWrap } from 'warp-pipes';
import { WritableMock } from 'stream-mock';
const opts = { objectMode: true };
const setAdult = chunk => Object.assign({}, chunk, { adult: true });
const unsetAdult = chunk => Object.assign({}, chunk, { adult: false });
const sink = ReadableWrap.wrap(readable)
.dropWhile(chunk => chunk.name === undefined, opts)
.filter(chunk => chunk.name.startsWith('A'), opts)
.split(
[
{
stream: new Map(setAdult, opts),
condition: chunk => chunk.age >= 18
},
{
stream: new Map(unsetAdult, opts),
condition: chunk => chunk.age < 18
}
],
opts
)
.pipe([
new Chunk(10, opts),
new Chunk(5, opts)
])
.merge()
.pipe(new WritableMock(opts));
sink.on('finish', () => console.log(sink.data));
Caveheats
warp-pipes is currently on beta stage. Here are some caveheats :
- Test coverage is not high enough for streams in buffer mode
- API is not definitive (that's why the API doc is in WIP state)
- No benchamarks.
Road map
- Improve test coverage
- Add more transformers
- Add performance tests
- Add docs
Contributing
Feel free to open any bug, feature, or pull request. When making a pr, just remember to cover your code with unit tests. And please follow the code style through tslint
(but we can discuss about tslint rules).