UNPKG

highland-callback

Version:

Call a node callback with an optional error after stream completes.

21 lines (16 loc) 358 B
var _ = require('highland'); module.exports = function highlandCallback(callback) { function consumer(error, value, push, next) { if (error) { push(null, _.nil); return callback(error); } if (value === _.nil) { callback(); return push(null, value); } push(null, value); next(); } return consumer; };