Skip to content

Instantly share code, notes, and snippets.

@Raynos Raynos/pump.js Secret
Last active Dec 15, 2015

Embed
What would you like to do?
function fastPump(source, onChunk, onError, onFinish) {
function onRead(err, chunk) {
if (err === true) {
return onFinish()
} else if (err) {
onError(err)
} else {
onChunk(chunk)
}
source.read(onRead)
}
source.read(onRead)
}
var s = StreamThing()
s.read(function callback(err, chunk) {
// read from the stream
if (err === true) {
// end of stream
} else if (err) {
// OOPS. err
} else {
// got a chunk
}
})
// close the damned thing.
s.abort(function errorListener(err) {
if (err) {
// Something went wrong with abort
} else {
// successful abort
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.