rxline
v0.9.4
Published
rxjs-based task pipelines
Downloads
163
Maintainers
Readme
RxLine
A Javascript task pipeline library built on top of RxJS. It helps you manage complex (possibly async) operations on collections (or streams) of entities. A common example is performing a series of tasks on a list of files (compiling sass to css or markdown to html).
npm i rxline
Usage
Super basic example:
import { line } from 'rxline';
line([1, 2, 3, 4])
.pipe(x => x * 2)
.pick(x => x > 3)
.collect(console.log);
More real-life example:
import { concurrently } from 'rxline';
import { files, pathMatch,
readFile, writeFile,
mapExt, mapContent, mapRoot } from 'rxline/fs';
files('.') // --> all files in current directory (and sub-directories)
.pick(pathMatch(/\.js$/)) // --> pick javascript files
.peek(f => console.log('-->' + f.path)) // --> log each file path
.pipe(readFile(), // --> read contents of the file
mapContent(c => ({ lines: c.split('\n').length })), // --> map its content to an object with number of lines in it
mapContent(c => JSON.stringify(c, null, 2)), // --> also stringify the json object
mapExt(() => '.json'), // --> change extension to `.json`
mapRoot(() => '.meta'), // --> change root directory to `.meta`
writeFile()) // --> write the files
.process(concurrently); // --> all in parallel.
👉Checkout the Wiki for more details.
Why?
Because Gulp felt too opaque for me. I needed to be more in control.