# rxjs-stream

> nodejs streams for rxjs 7

Latest version **5.0.0** (published 2022-06-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install rxjs-stream
pnpm add rxjs-stream
yarn add rxjs-stream
bun add rxjs-stream
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 5.0.0 |
| Published | 2022-06-07 |
| First published | 2017-02-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=14 |
| Dependencies | 1 |
| Unpacked size | 13.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 111 |
| Author | Jason Dent |
| Maintainers | jason-dent |
| Keywords | rxjs, node, stream |

## Links

- npm: https://www.npmjs.com/package/rxjs-stream
- Repository: https://github.com/Jason3S/rx-stream
- Homepage: https://github.com/Jason3S/rx-stream#readme
- Issues: https://github.com/Jason3S/rx-stream/issues
- npm.io page: https://npm.io/package/rxjs-stream

## Dependencies (1)

- [@types/fs-extra](https://npm.io/package/@types/fs-extra.md) ^9.0.13

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 5.0.0 (latest) — 2022-06-07
- 4.0.2 — 2021-12-13
- 4.0.1 — 2021-12-13
- 3.3.0 — 2021-07-18
- 3.2.1 — 2020-03-21
- 3.1.1 — 2020-01-06
- 3.1.0 — 2019-10-24
- 3.0.2 — 2019-05-14
- 3.0.1 — 2018-09-16
- 3.0.0 — 2018-08-25
- 2.0.3 — 2018-04-28
- 2.0.2 — 2018-04-27
- 2.0.0 — 2018-04-27
- 1.3.0 — 2018-04-27
- 1.1.0 — 2017-12-29
- … 4 more at https://npm.io/package/rxjs-stream/versions

## README

# rxjs-stream

This is a simple library for converting to and from NodeJS stream and [RxJS](https://rxjs.dev/) 7.

This was created to fill the gap left by [rx-node](https://www.npmjs.com/package/rx-node),
which only works with rxjs 4.

## Installation

```sh
npm install --save rxjs rxjs-stream
```

## Usage

### Writing to a stream.

```typescript
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 }`

```typescript
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

```typescript
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:

```typescript
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 |

---
_Source: https://npm.io/package/rxjs-stream · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
