-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Eugene Ghanizadeh edited this page Feb 22, 2020
·
14 revisions
RxLine 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
Typical usage of RxLine looks like this:
- You define a line, i.e. a collection/stream of objects (called its content),
- You define some (sync or async) transformations on the objects of the line (called its transform),
- You request the line to be processed, i.e. its transform to be applied on its content.
import { line } from 'rxline';
line([1, 2, 3, 4]) // --> define the line
.pipe(x => x * 2, // --> add a transform
x => x + 11) // --> expand the transform
.collect(console.log); // --> process and collect the results.
// Result:
// [13, 15, 17, 19]
import { concurrently } from 'rxline';
import { files, mapContent, readFile, writeFile, pathMatch } from 'rxline/fs';
files('./src') // --> define the line
.pick(pathMatch(/\.js$/)) // --> filter its content
.pipe(readFile()) //
.pipe(mapContent( //
(content, path) => // --> define the transform
`/** @file ${path} **/\n` + content //
)) //
.pipe(writeFile()) //
.process(concurrently); // --> process the line
// Result:
// adds a first line `/** @file module/filename.js **/` to each javascript file in `./src`
Checkout these wiki entries for more detailed usage guides:
🚧
- This Wiki is still under construction, so you might find some more in-depth information missing.
- This project is relatively new. Though it should generally be fine, if you want to use it in super-sensitive production environments, I would recommend waiting until the test coverage (and the version number) goes up a notch.