browser.js 482 B

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