Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | 21x 21x 21x 21x 21x 8x 8x 8x 8x 8x 7x 7x 8x 8x 8x 8x 8x 1x 1x 1x 1x 1x 8x 8x 8x 8x 8x 21x | const duplexer3 = require('duplexer3'); const Streamz = require('streamz'); const toStream = require('./tostream'); module.exports = function(fn) { const inStream = Streamz(); const outStream = Streamz(); if (fn.length > 1) fn(inStream,outStream); else toStream(fn(inStream)).pipe(outStream); const stream = duplexer3({objectMode: true},inStream,outStream); // Mirror error and promise behaviour from streamz stream.on('error',e => { if (stream._events.error.length < 2) { const pipes = stream._readableState.pipes; if (pipes) [].concat(pipes).forEach(child => child.emit('error',e)); else throw e; } }); stream.promise = Streamz.prototype.promise; return stream; }; |