Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80529 views
1
2
3
/*
4
sometimes jsonparse changes numbers slightly.
5
*/
6
7
var r = Math.random()
8
, Parser = require('jsonparse')
9
, p = new Parser()
10
, assert = require('assert')
11
, times = 20
12
while (times --) {
13
14
assert.equal(JSON.parse(JSON.stringify(r)), r, 'core JSON')
15
16
p.onValue = function (v) {
17
console.error('parsed', v)
18
assert.equal(
19
String(v).slice(0,12),
20
String(r).slice(0,12)
21
)
22
}
23
console.error('correct', r)
24
p.write (new Buffer(JSON.stringify([r])))
25
26
27
28
}
29
30