Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jliuhtonen/bacon-node-stream

Convert between Bacon.js event streams and Node.js readable streams
https://github.com/jliuhtonen/bacon-node-stream

baconjs frp node-streams nodejs

Last synced: 24 days ago
JSON representation

Convert between Bacon.js event streams and Node.js readable streams

Awesome Lists containing this project

README

        

# bacon-node-stream

Utility for creating [Node.js readable streams](https://nodejs.org/api/stream.html#stream_readable_streams) from [Bacon streams](http://baconjs.github.io/) and vice versa.

## Usage

Install this package and `baconjs`, that is this package's peer dependency.

### API

```typescript
readableToBacon(stream: Readable, options?: ReadableOptions): Bacon.EventStream
```

Creates a new Node.js stream that is exposed as a Bacon event stream and pipes `stream` into it. Use this function for creating a Bacon EventStream from a Readable stream. You must provide the options accordingly, so if `stream` uses object mode, you must also specify it here, and so on.

Note to TypeScript users: `Readable`'s values are not typed, so you must cast or determine the correct type yourself (use `.map()`).

```typescript
baconToReadable(stream: Bacon.EventStream, options?: ReadableOptions): Readable {
```

Wraps a Bacon event stream as a Node.js Readable stream. If the Readable is paused _all values, errors and the possible end event of the stream are buffered until the Readable is resumed_. Remember to provide options if your stream uses the object mode.