summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/JSONStream/test/two-ways.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/JSONStream/test/two-ways.js')
-rw-r--r--deps/npm/node_modules/JSONStream/test/two-ways.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/deps/npm/node_modules/JSONStream/test/two-ways.js b/deps/npm/node_modules/JSONStream/test/two-ways.js
new file mode 100644
index 0000000000..a74dfba36e
--- /dev/null
+++ b/deps/npm/node_modules/JSONStream/test/two-ways.js
@@ -0,0 +1,41 @@
+
+var fs = require ('fs')
+ , join = require('path').join
+ , file = join(__dirname, 'fixtures','all_npm.json')
+ , JSONStream = require('../')
+ , it = require('it-is').style('colour')
+
+ function randomObj () {
+ return (
+ Math.random () < 0.4
+ ? {hello: 'eonuhckmqjk',
+ whatever: 236515,
+ lies: true,
+ nothing: [null],
+// stuff: [Math.random(),Math.random(),Math.random()]
+ }
+ : ['AOREC', 'reoubaor', {ouec: 62642}, [[[], {}, 53]]]
+ )
+ }
+
+var expected = []
+ , stringify = JSONStream.stringify()
+ , es = require('event-stream')
+ , stringified = ''
+ , called = 0
+ , count = 10
+ , ended = false
+
+while (count --)
+ expected.push(randomObj())
+
+ es.connect(
+ es.readArray(expected),
+ stringify,
+ JSONStream.parse([/./]),
+ es.writeArray(function (err, lines) {
+
+ it(lines).has(expected)
+ console.error('PASSED')
+ })
+ )