Simple email application for Android. Original source code: https://framagit.org/dystopia-project/simple-email
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1023 B

  1. var JSONStream = require('../')
  2. , stream = require('stream')
  3. , it = require('it-is')
  4. var output = [ [], [] ]
  5. var parser1 = JSONStream.parse(['docs', /./])
  6. parser1.on('data', function(data) {
  7. output[0].push(data)
  8. })
  9. var parser2 = JSONStream.parse(['docs', /./])
  10. parser2.on('data', function(data) {
  11. output[1].push(data)
  12. })
  13. var pending = 2
  14. function onend () {
  15. if (--pending > 0) return
  16. it(output).deepEqual([
  17. [], [{hello: 'world'}]
  18. ])
  19. console.error('PASSED')
  20. }
  21. parser1.on('end', onend)
  22. parser2.on('end', onend)
  23. function makeReadableStream() {
  24. var readStream = new stream.Stream()
  25. readStream.readable = true
  26. readStream.write = function (data) { this.emit('data', data) }
  27. readStream.end = function (data) { this.emit('end') }
  28. return readStream
  29. }
  30. var emptyArray = makeReadableStream()
  31. emptyArray.pipe(parser1)
  32. emptyArray.write('{"docs":[]}')
  33. emptyArray.end()
  34. var objectArray = makeReadableStream()
  35. objectArray.pipe(parser2)
  36. objectArray.write('{"docs":[{"hello":"world"}]}')
  37. objectArray.end()