Skip to content

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

License

Notifications You must be signed in to change notification settings

decompil3d/from2-error

Repository files navigation

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

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published