1.0.1 • Published 4 years ago
@jacobbubu/pull-abortable v1.0.1
@jacobbubu/pull-abortable
Rewriting the pull-abortable with TypeScript.
pull-abortable
a pull-stream that may be aborted from the outside.
why rewriting?
- Familiarity with the original author's intent
- Strong type declarations for colleagues to understand and migrate to other programming languages
example
import * as pull from 'pull-stream'
import Abortable from '@jacobbubu/pull-abortable'
const abortable = Abortable()
pull(
source,
abortable,
sink
)
//at any time you can abort the pipeline,
//the source will be cleaned up, and any
//error will be passed to the sink next time it reads.
atAnyTime(function () {
abortable.abort()
})
// abort the stream and end with an error
abortable.abort(new Error('example'))
License
MIT