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.
- Host: GitHub
- URL: https://github.com/decompil3d/from2-error
- Owner: decompil3d
- License: mit
- Created: 2017-03-20T19:21:58.000Z (over 9 years ago)
- Default Branch: main
- Last Pushed: 2022-01-25T18:39:05.000Z (over 4 years ago)
- Last Synced: 2025-01-30T16:20:00.953Z (over 1 year ago)
- Language: JavaScript
- Size: 99.6 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
 [](https://coveralls.io/github/decompil3d/from2-error?branch=master)
[](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)