easy-transform-stream
Create a transform stream using await instead of callbacks
Last updated 3 years ago by sindresorhus .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install easy-transform-stream 
SYNC missed versions from official npm registry.

easy-transform-stream

Create a transform stream using await instead of callbacks

The built-in stream.Transform constructor forces you to deal with a callback interface. It's much nicer to just be able to await and return a value.

This package can be thought of as a modern version of through2.

Install

npm install easy-transform-stream

Usage

import transformStream from 'easy-transform-stream';

const stream = transformStream(async chunk => {
	const newChunk = await modifyChunk(chunk);
	return newChunk;
});

API

easyTransformStream(transformer, flusher?)

easyTransformStream(options, transformer, flusher?)

transformer(chunk, encoding, stream)

Type: Async function

Receives each chunk and is expected to return a transformed chunk.

flusher(stream)

Type: Async generator function

Yield additional chunks at the end of the stream.

options

Type: object

Same as the options for stream.Transform, except for transform and flush.

Related

  • get-stream - Get a stream as a string, buffer, or array

Current Tags

  • 1.0.1                                ...           latest (3 years ago)

3 Versions

  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           4 years ago
  • 0.1.0                                ...           5 years ago
Maintainers (1)
Downloads
Total 9
Today 1
This Week 2
This Month 7
Last Day 1
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (5)

© 2010 - cnpmjs.org x YWFE | Home | YWFE