From 10339b5f01fc61905513b62f2061b2883decad85 Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Sat, 8 Feb 2025 21:18:27 -0800 Subject: [PATCH] Simplify ReadableStream constructor --- test/utils.js | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/test/utils.js b/test/utils.js index 8473916..deadbd4 100644 --- a/test/utils.js +++ b/test/utils.js @@ -191,23 +191,12 @@ function getPseudoRandomValues(typedArray, seed) { */ export function createRandomCSV(rows, columns, seed) { const chunks = (function* () { - while (rows) { + while (rows--) { const data = new Uint32Array(columns); getPseudoRandomValues(data, seed); seed = data[columns - 1]; - rows--; - yield Array.from(data); + yield JSON.stringify(Array.from(data)); } })(); - return new ReadableStream({ - pull(controller) { - const { value, done } = chunks.next(); - if (done) { - controller.close(); - } - else { - controller.enqueue(JSON.stringify(value)); - } - } - }); + return ReadableStream.from(chunks); } \ No newline at end of file -- 2.47.3