doubledot2.js 754 B

123456789101112131415161718192021222324252627282930
  1. var fs = require ('fs')
  2. , join = require('path').join
  3. , file = join(__dirname, 'fixtures','depth.json')
  4. , JSONStream = require('../')
  5. , it = require('it-is')
  6. var expected = JSON.parse(fs.readFileSync(file))
  7. , parser = JSONStream.parse(['docs', {recurse: true}, 'value'])
  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. var expectedValues = [0, [1], {"a": 2}, "3", 4]
  21. it(called).equal(expectedValues.length)
  22. for (var i = 0 ; i < 5 ; i++)
  23. it(parsed[i]).deepEqual(expectedValues[i])
  24. console.error('PASSED')
  25. })