Star

Created With

logo

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).

linkInstallation

1npm i rxline


linkUsage

Typical usage of RxLine looks like this:

  1. You define a line, i.e. a collection/stream of objects (called its content),
  2. You define some (sync or async) transformations on the objects of the line (called its transform),
  3. You request the line to be processed, i.e. its transform to be applied on its content.
1import { line } from 'rxline';

2

3line([1, 2, 3, 4]) // --> define the line

4 .pipe(x => x * 2, // --> add a transform

5 x => x + 11) // --> expand the transform

6 .collect(console.log); // --> process and collect the results.

7

8// Result:

9// [13, 15, 17, 19]

1import { concurrently } from 'rxline';

2import { files, mapContent, readFile, writeFile, pathMatch } from 'rxline/fs';

3

4files('./src') // --> define the line

5 .pick(pathMatch(/\.js$/)) // --> filter its content

6 .pipe(readFile()) // --> read the content of the file

7 .pipe(mapContent( // --> map the content of the file

8 (content, path) => // --> define the transform

9 `/** @file ${path} **/\n` + content // --> add a comment of the file's path on top of it

10 ))

11 .pipe(writeFile()) // --> write the file to filesystem

12 .process(concurrently); // --> process the line

13

14// Result:

15// adds a first line `/** @file module/filename.js **/` to each javascript file in `./src`

InstallationUsage

Home

Basicschevron_right
In Depthchevron_right