Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80529 views
1
var test = require('tape')
2
var JSONStream = require('../')
3
var testData = '{"rows":[{"hello":"world"}, {"foo": "bar"}]}'
4
5
test('basic parsing', function (t) {
6
t.plan(2)
7
var parsed = JSONStream.parse("rows.*")
8
var parsedKeys = {}
9
parsed.on('data', function(match) {
10
parsedKeys[Object.keys(match)[0]] = true
11
})
12
parsed.on('end', function() {
13
t.equal(!!parsedKeys['hello'], true)
14
t.equal(!!parsedKeys['foo'], true)
15
})
16
parsed.write(testData)
17
parsed.end()
18
})
19