1 2 3/* 4 sometimes jsonparse changes numbers slightly. 5*/ 6 7var r = Math.random() 8 , Parser = require('jsonparse') 9 , p = new Parser() 10 , assert = require('assert') 11 , times = 20 12 , bufferFrom = Buffer.from && Buffer.from !== Uint8Array.from 13 , str 14 15while (times --) { 16 17 assert.equal(JSON.parse(JSON.stringify(r)), r, 'core JSON') 18 19 p.onValue = function (v) { 20 console.error('parsed', v) 21 assert.equal(v,r) 22 } 23 console.error('correct', r) 24 str = JSON.stringify([r]) 25 p.write (bufferFrom ? Buffer.from(str) : new Buffer(str)) 26 27 28 29} 30