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

https://github.com/decompil3d/from2-error

Create a stream that immediately emits the specified Error. Sugary wrapper around from2.
https://github.com/decompil3d/from2-error

Last synced: over 1 year ago
JSON representation

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

Awesome Lists containing this project

README

          

![CI](https://github.com/decompil3d/from2-error/workflows/CI/badge.svg) [![Coverage Status](https://coveralls.io/repos/github/decompil3d/from2-error/badge.svg?branch=master)](https://coveralls.io/github/decompil3d/from2-error?branch=master)

[![NPM](https://nodei.co/npm/from2-error.png?downloads=true&stars=true)](https://nodei.co/npm/from2-error/)

# 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

```js
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

```sh
npm test
```

## License
[MIT](LICENSE)