/**
 * CSV class - Node.js Version
 *
 * Extends browser CSV class with file system support.
 */
import fs from "fs";
import { fileExists } from "../../utils/utils.js";
import { CSV as CSVBrowser } from "./csv.browser.js";
class CSV extends CSVBrowser {
    async readFile(filename, options) {
        if (!(await fileExists(filename))) {
            throw new Error(`File not found: ${filename}`);
        }
        const readStream = fs.createReadStream(filename, {
            encoding: "utf8",
            highWaterMark: options?.highWaterMark ?? 64 * 1024
        });
        return this.read(readStream, options);
    }
    async writeFile(filename, options) {
        const writeStream = fs.createWriteStream(filename, {
            encoding: (options?.encoding ?? "utf8"),
            highWaterMark: options?.highWaterMark ?? 64 * 1024
        });
        return this.write(writeStream, options);
    }
}
export { CSV };
export { CsvParserStream, CsvFormatterStream } from "./csv-stream.js";
