• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1var JSONStream = require('../')
2
3var data = [
4  {ID: 1, optional: null},
5  {ID: 2, optional: null},
6  {ID: 3, optional: 20},
7  {ID: 4, optional: null},
8  {ID: 5, optional: 'hello'},
9  {ID: 6, optional: null}
10]
11
12
13var test = require('tape')
14
15test ('null properties', function (t) {
16  var actual = []
17  var stream =
18
19  JSONStream.parse('*.optional')
20    .on('data', function (v) { actual.push(v) })
21    .on('end', function () {
22      t.deepEqual(actual, [20, 'hello'])
23      t.end()
24    })
25
26  stream.write(JSON.stringify(data, null, 2))
27  stream.end()
28})
29