1 2 3var fs = require ('fs') 4 , join = require('path').join 5 , file = join(__dirname, 'fixtures','all_npm.json') 6 , JSONStream = require('../') 7 , it = require('it-is') 8 9var expected = JSON.parse(fs.readFileSync(file)) 10 , parser = JSONStream.parse(['rows', /\d+/ /*, 'value'*/]) 11 , called = 0 12 , ended = false 13 , parsed = [] 14 15fs.createReadStream(file).pipe(parser) 16 17parser.on('data', function (data) { 18 called ++ 19 it.has({ 20 id: it.typeof('string'), 21 value: {rev: it.typeof('string')}, 22 key:it.typeof('string') 23 }) 24 parsed.push(data) 25}) 26 27parser.on('end', function () { 28 ended = true 29}) 30 31process.on('exit', function () { 32 it(called).equal(expected.rows.length) 33 it(parsed).deepEqual(expected.rows) 34 console.error('PASSED') 35}) 36