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 4x 4x 4x 2x 4x 4x 21x 21x 21x 21x 7x 7x 21x 21x 21x 2x 2x 2x 2x 3x 2x 2x 2x 2x 21x 21x 21x | const Streamz = require('streamz'); const util = require('util'); function KeepOpen(timeout) { if (!(this instanceof Streamz)) return new KeepOpen(timeout); Streamz.call(this, { autoDestroy: false }); this.timeout = timeout || 1000; } util.inherits(KeepOpen,Streamz); KeepOpen.prototype._fn = function() { this.last = new Date(); return Streamz.prototype._fn.apply(this,arguments); }; KeepOpen.prototype.end = function(d) { if (d !== null && d !== undefined) this.write(d); let timer = setInterval(() => { if (new Date() - this.last > this.timeout) { clearInterval(timer); Streamz.prototype.end.call(this); } },this.timeout); }; module.exports = KeepOpen; |