"use strict";
/**
 * CSV class - Node.js Version
 *
 * Extends browser CSV class with file system support.
 */
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CsvFormatterStream = exports.CsvParserStream = exports.CSV = void 0;
const fs_1 = __importDefault(require("fs"));
const utils_1 = require("../../utils/utils.js");
const csv_browser_1 = require("./csv.browser.js");
class CSV extends csv_browser_1.CSV {
    async readFile(filename, options) {
        if (!(await (0, utils_1.fileExists)(filename))) {
            throw new Error(`File not found: ${filename}`);
        }
        const readStream = fs_1.default.createReadStream(filename, {
            encoding: "utf8",
            highWaterMark: options?.highWaterMark ?? 64 * 1024
        });
        return this.read(readStream, options);
    }
    async writeFile(filename, options) {
        const writeStream = fs_1.default.createWriteStream(filename, {
            encoding: (options?.encoding || "utf8"),
            highWaterMark: options?.highWaterMark ?? 64 * 1024
        });
        return this.write(writeStream, options);
    }
}
exports.CSV = CSV;
var csv_stream_1 = require("./csv-stream.js");
Object.defineProperty(exports, "CsvParserStream", { enumerable: true, get: function () { return csv_stream_1.CsvParserStream; } });
Object.defineProperty(exports, "CsvFormatterStream", { enumerable: true, get: function () { return csv_stream_1.CsvFormatterStream; } });
