From f3d255b8b50749e901068064b10cd6858ea6b173 Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Fri, 12 Sep 2025 22:24:48 -0700 Subject: [PATCH] Delete unnecessary utility function --- test/core.test.js | 6 ++++-- test/utils.js | 27 --------------------------- 2 files changed, 4 insertions(+), 29 deletions(-) diff --git a/test/core.test.js b/test/core.test.js index f2efd95..fb7a4af 100644 --- a/test/core.test.js +++ b/test/core.test.js @@ -1,12 +1,14 @@ import { suite, test } from 'node:test'; import { ok, deepStrictEqual, throws, rejects } from 'node:assert/strict'; +import { createWriteStream } from 'node:fs'; import { unlink, readFile } from 'node:fs/promises'; import { normalize, basename, resolve } from 'node:path'; import { setTimeout } from 'node:timers/promises'; import { pathToFileURL } from 'node:url'; +import { Writable } from 'node:stream'; import { ReadableStream, DecompressionStream, CompressionStream, TextDecoderStream } from 'node:stream/web'; -import { csvStreamEqualWritable, createCSVMockStream, createTempFile, createWritableFileStream, setGzipOSByteToUnknown } from './utils.js'; +import { csvStreamEqualWritable, createCSVMockStream, createTempFile, setGzipOSByteToUnknown } from './utils.js'; import { parsePathLike, createFileStream, CSVReader, CSVTransformer, CSVWriter } from '../src/core.js'; suite('CSVWriter.arrayToCSVString', { concurrency: true }, () => { @@ -741,7 +743,7 @@ suite('CSVWriter', { concurrency: true }, () => { await new CSVReader(input) .pipeThrough(new CSVWriter()) .pipeThrough(new CompressionStream('gzip')) - .pipeTo(createWritableFileStream(temp)); + .pipeTo(Writable.toWeb(createWriteStream(temp))); await setGzipOSByteToUnknown(temp); // Allows this test to work across platforms const expected = await readFile(output); const actual = await readFile(temp); diff --git a/test/utils.js b/test/utils.js index 2745924..02ec5b6 100644 --- a/test/utils.js +++ b/test/utils.js @@ -212,33 +212,6 @@ export function createRandomCSV(rows, columns, seed) { return ReadableStream.from(chunks); } -/** - * Creates a writable file stream for a local file. - * - * @see {@link https://streams.spec.whatwg.org/#example-ws-backpressure} - * @param {PathLike} path A `string`, `Buffer`, or `URL` representing a path to a local file. - * @returns {WritableStream>} - */ -export function createWritableFileStream(path) { - /** @type {FileHandle} */ - let handle; - - return new WritableStream({ - async start() { - handle = await open(path, 'w'); - }, - async write(chunk) { - await handle.write(chunk, 0, chunk.length); - }, - async close() { - await handle.close(); - }, - async abort() { - await handle.close(); - } - }); -} - /** * Sets the "OS" (filesystem) header byte of a given gzip file to `255` ("Unknown"). This function * is useful to strip a gzip file of platform-specific metadata. -- 2.47.3