File: test2.js

package info (click to toggle)
node-jsonstream 1.3.5-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 596 kB
  • sloc: javascript: 991; makefile: 5
file content (29 lines) | stat: -rw-r--r-- 556 bytes parent folder | download | duplicates (4)
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


var fs = require ('fs')
  , join = require('path').join
  , file = join(__dirname, '..','package.json')
  , JSONStream = require('../')
  , it = require('it-is')

var expected = JSON.parse(fs.readFileSync(file))
  , parser = JSONStream.parse([])
  , called = 0
  , ended = false
  , parsed = []

fs.createReadStream(file).pipe(parser)
  
parser.on('data', function (data) {
  called ++
  it(data).deepEqual(expected)
})

parser.on('end', function () {
  ended = true
})

process.on('exit', function () {
  it(called).equal(1)
  console.error('PASSED')
})