/
eapostnova
/
2026-1--study--mathmod
Обзор
Документация
Войти
/
eapostnova
/
2026-1--study--mathmod
Код
Запросы
0
Задачи
Пакеты
0
Релизы
6
Аналитика
Безопасность
develop
node_modules/JSONStream/test/stringify.js
40 строк
949 B
Елизавета Постнова
feat(lab): lab04
24 мар 2026, 02:59
Верифицирован
24 мар 2026, 02:59
7783508
Код
Авторство
О чём код?
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(JSON.parse(lines.join(''))).deepEqual(expected) console.error('PASSED') }) )