Synchronous through2 transforms.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
README.md
UNLICENSE
index.js
package.json
test.js

README.md

through2-sync npm version

Synchronous through2 transforms.

Description

The API is the same as through2 (including the through.obj helper), but the callback function is synchronous.

Example

const Stream = require('stream')
const through = require('through2-sync')

const stream = new Stream.Readable()
stream._read = () => {}

stream
  .pipe(through(
    chunk => chunk.toString().toUpperCase(),
    () => 'last chunk\n'
  ))
  .pipe(process.stdout)

stream.push('hello\n') // HELLO
stream.push('world\n') // WORLD
stream.push(null) // last chunk