from2-error

1.0.2 • Public • Published

CI Coverage Status

NPM

from2-error

Create a stream that immediately emits the specified Error. Sugary wrapper around from2.

Useful when you want to create a Stream for unit testing your error handlers.

Example

const from = require('from-error');
const through = require('through2');

from(new Error('Test error'))
  .on('error', err => {
    // Handle the error here
  })
  .on('data', () => {
    // This will never run
  })
  .on('end', () => {
    // This will never run
  })
  .on('close', () => {
    // This will emit when the stream is done
  });

Testing

npm test

License

MIT

Package Sidebar

Install

npm i from2-error

Weekly Downloads

3

Version

1.0.2

License

MIT

Unpacked Size

7.32 kB

Total Files

8

Last publish

Collaborators

  • decompil3d