rxjs-stream
nodejs streams for rxjs 7
Last updated 3 years ago by jason-dent .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install rxjs-stream 
SYNC missed versions from official npm registry.

rxjs-stream

This is a simple library for converting to and from NodeJS stream and RxJS 7.

This was created to fill the gap left by rx-node, which only works with rxjs 4.

Installation

npm install --save rxjs rxjs-stream

Usage

Writing to a stream.

import { rxToStream } from 'rxjs-stream';

let data = 'This is a bit of text to have some fun with';
let src = Rx.Observable.from(data.split(' '));
rxToStream(src).pipe(process.stdout);

Writing objects to a stream

To write objects, you must pass in the ReadableOptions with objectMode to be true: { objectMode: true }

import { rxToStream } from 'rxjs-stream';

let data = 'This is a bit of text to have some fun with';
let wordObj = data.split(' ').map((text) => ({ text }));
let src = Rx.Observable.from(wordObj);
let stream = rxToStream(src, { objectMode: true });

Read from a stream

import { rxToStream, streamToStringRx } from 'rxjs-stream';

// Read stdin and make it upper case then send it to stdout
let ob = streamToStringRx(process.stdin).map((text) => text.toUpperCase());

rxToStream(ob).pipe(process.stdout);

Performance

It is recommended to buffer observable values before sending them to the stream. Node streams work better with fewer calls of a large amount of data than with many calls with a small amount of data.

Example:

import * as loremIpsum from 'lorem-ipsum';
import { rxToStream } from 'rxjs-stream';

let book = loremIpsum({ count: 1000, format: 'plain', units: 'paragraphs' });
let words = Rx.Observable.from(book.split(/\b/));
let wordsBuffered = words.bufferCount(1000).map((words) => words.join(''));
let stream = rxToStream(wordsBuffered);

stream.pipe(process.stdout);

Compatibility

This library is tested with Node 12 and above.

rx-stream RxJS Node
4.x 7.x >=12
3.x 6.x >=10

Current Tags

  • 5.0.0                                ...           latest (3 years ago)

19 Versions

  • 5.0.0                                ...           3 years ago
  • 4.0.2                                ...           3 years ago
  • 4.0.1                                ...           3 years ago
  • 3.3.0                                ...           3 years ago
  • 3.2.1                                ...           5 years ago
  • 3.1.1                                ...           5 years ago
  • 3.1.0                                ...           5 years ago
  • 3.0.2                                ...           6 years ago
  • 3.0.1                                ...           6 years ago
  • 3.0.0                                ...           6 years ago
  • 2.0.3                                ...           7 years ago
  • 2.0.2                                ...           7 years ago
  • 2.0.0                                ...           7 years ago
  • 1.3.0                                ...           7 years ago
  • 1.1.0                                ...           7 years ago
  • 1.0.4                                ...           8 years ago
  • 1.0.3                                ...           8 years ago
  • 1.0.1                                ...           8 years ago
  • 1.0.0                                ...           8 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (24)

Copyright 2013 - present © cnpmjs.org | Home |