]> git.ardis.lu - csvio/commitdiff
Delete unnecessary utility function
authorArdis Lu <ardisglu@gmail.com>
Sat, 13 Sep 2025 05:24:48 +0000 (22:24 -0700)
committerArdis Lu <ardisglu@gmail.com>
Sat, 13 Sep 2025 05:24:48 +0000 (22:24 -0700)
test/core.test.js
test/utils.js

index f2efd9558d8a75d739f5731ba819bd13ed0d0f37..fb7a4af37d26683265155041b02d7a1be8534e09 100644 (file)
@@ -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);
index 27459247dc5cc4e4f61b3cdefd37b6375e3e3e4a..02ec5b63e40590d6b8c4376a8c575c6b4a15d508 100644 (file)
@@ -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<Uint8Array<ArrayBuffer>>}
- */
-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.
This page took 0.038027 seconds and 4 git commands to generate.