1 |
|
2 | var fs = require ('fs')
|
3 | , join = require('path').join
|
4 | , file = join(__dirname, 'fixtures','all_npm.json')
|
5 | , JSONStream = require('../')
|
6 | , it = require('it-is').style('colour')
|
7 |
|
8 | function randomObj () {
|
9 | return (
|
10 | Math.random () < 0.4
|
11 | ? {hello: 'eonuhckmqjk',
|
12 | whatever: 236515,
|
13 | lies: true,
|
14 | nothing: [null],
|
15 |
|
16 | }
|
17 | : ['AOREC', 'reoubaor', {ouec: 62642}, [[[], {}, 53]]]
|
18 | )
|
19 | }
|
20 |
|
21 | var expected = []
|
22 | , stringify = JSONStream.stringify()
|
23 | , es = require('event-stream')
|
24 | , stringified = ''
|
25 | , called = 0
|
26 | , count = 10
|
27 | , ended = false
|
28 |
|
29 | while (count --)
|
30 | expected.push(randomObj())
|
31 |
|
32 | es.connect(
|
33 | es.readArray(expected),
|
34 | stringify,
|
35 | JSONStream.parse([/./]),
|
36 | es.writeArray(function (err, lines) {
|
37 |
|
38 | it(lines).has(expected)
|
39 | console.error('PASSED')
|
40 | })
|
41 | )
|