doubledot1.js 685 B

1234567891011121314151617181920212223242526272829
  1. var fs = require ('fs')
  2. , join = require('path').join
  3. , file = join(__dirname, 'fixtures','all_npm.json')
  4. , JSONStream = require('../')
  5. , it = require('it-is')
  6. var expected = JSON.parse(fs.readFileSync(file))
  7. , parser = JSONStream.parse('rows..rev')
  8. , called = 0
  9. , ended = false
  10. , parsed = []
  11. fs.createReadStream(file).pipe(parser)
  12. parser.on('data', function (data) {
  13. called ++
  14. parsed.push(data)
  15. })
  16. parser.on('end', function () {
  17. ended = true
  18. })
  19. process.on('exit', function () {
  20. it(called).equal(expected.rows.length)
  21. for (var i = 0 ; i < expected.rows.length ; i++)
  22. it(parsed[i]).deepEqual(expected.rows[i].value.rev)
  23. console.error('PASSED')
  24. })