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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | 21x 21x 21x 6x 6x 6x 3x 3x 6x 6x 21x 21x 21x 21x 21x 21x 21x 21x 3x 2x 2x 2x 3x 21x 21x 21x 6x 6x 6x 6x 2x 2x 2x 6x 6x 6x 6x 6x 9x 9x 9x 9x 6x 6x 6x 21x 21x 21x 3x 3x 21x 21x 21x | const Streamz = require('streamz'); const util = require('util'); function Split(symbol) { if (!(this instanceof Streamz)) return new Split(symbol); Streamz.call(this); this.symbol = symbol || '\n'; } util.inherits(Split,Streamz); Split.prototype.buffer = ''; Split.prototype.__line = 0; Split.prototype._push = function() { if (this.buffer) { this.buffer.__line = this.__line++; this.push(this.buffer); } delete this.buffer; }; Split.prototype._fn = function(d) { if (d instanceof Buffer || typeof d !== 'object') d = { text: d.toString('utf8') }; if (!this.buffer) { this.buffer = Object.create(d); this.buffer.text = ''; } const buffer = (this.buffer.text += d.text).split(this.symbol); buffer.slice(0,buffer.length-1) .forEach(d => { const obj = Object.create(this.buffer); obj.text = d; obj.__line = this.__line++; this.push(obj); },this); this.buffer.text = buffer[buffer.length-1]; }; Split.prototype._flush = function(cb) { this._push(); setImmediate( () => Streamz.prototype._flush(cb)); }; module.exports = Split; |