UNPKG

streamlined

Version:

Collection of helper streams to deal with mapping/transforming object streams

23 lines (17 loc) 403 B
var through2 = require('through2'); function noop() { } module.exports = data; function data(onData, onEnd) { var s = through2.obj(write, end); onData = (typeof onData === 'function') ? onData : noop; onEnd = (typeof onEnd === 'function') ? onEnd : noop; function write(data, enc, cb) { onData(data); this.push(data); cb(); } function end() { onEnd(); } return s; }