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 54 55 | 28x 28x 28x 28x 28x 5x 5x 5x 5x 5x 5x 5x 5x 9x 7x 7x 9x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 5x 5x 5x 5x 2x 5x 5x 5x 5x 4x 4x 2x 2x 5x 5x 5x 5x 5x 5x 5x 5x 28x 28x | var Stream = require('stream'); var Parse = require('./parse'); var duplexer2 = require('duplexer2'); var BufferStream = require('./BufferStream'); function parseOne(match,opts) { var inStream = Stream.PassThrough({objectMode:true}); var outStream = Stream.PassThrough(); var transform = Stream.Transform({objectMode:true}); var re = match instanceof RegExp ? match : (match && new RegExp(match)); var found; transform._transform = function(entry,e,cb) { if (found || (re && !re.exec(entry.path))) { entry.autodrain(); return cb(); } else { found = true; out.emit('entry',entry); entry.on('error',function(e) { outStream.emit('error',e); }); entry.pipe(outStream) .on('error',function(err) { cb(err); }) .on('finish',function(d) { cb(null,d); }); } }; inStream.pipe(Parse(opts)) .on('error',function(err) { outStream.emit('error',err); }) .pipe(transform) .on('error',Object) // Silence error as its already addressed in transform .on('finish',function() { if (!found) outStream.emit('error',new Error('PATTERN_NOT_FOUND')); else outStream.end(); }); var out = duplexer2(inStream,outStream); out.buffer = function() { return BufferStream(outStream); }; return out; } module.exports = parseOne; |