"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.csvBuffered = exports.csv = exports.toCsv = exports.buffered = exports.toCsvSync = exports.bufferedSync = exports.toCsvStream = exports.stream = exports.StringWriter = void 0; const json_csv_core_1 = require("@iwsio/json-csv-core"); const exporter = __importStar(require("./exporter.cjs")); const string_writer_cjs_1 = require("./string-writer.cjs"); var string_writer_cjs_2 = require("./string-writer.cjs"); Object.defineProperty(exports, "StringWriter", { enumerable: true, get: function () { return string_writer_cjs_2.StringWriter; } }); /** * Generate a CSV transform for a stream of objects. * @param options Export options * @param callback Optional callback for classic style Node. If null or undefined, returns a promise * @returns If callback provided, return void; otherwise, returns Transform stream */ const stream = (options, callback) => { if (callback == null) return exporter.stream(options); callback(null, exporter.stream(options)); }; exports.stream = stream; /** * Generate a CSV transform for a stream of objects. * @param options Export options * @param callback Optional callback for classic style Node. If null or undefined, returns a promise * @returns If callback provided, return void; otherwise, returns Transform stream */ exports.toCsvStream = exports.stream; /** * Convert array of objects to CSV in a synchronous operation * @param data Array of objects to be transformed * @param options CSV Options * @returns The result CSV string */ exports.bufferedSync = json_csv_core_1.buffered; /** * Convert array of objects to CSV in a synchronous operation * @param data Array of objects to be transformed * @param options CSV Options * @returns The result CSV string */ exports.toCsvSync = exports.bufferedSync; /** * Convert array of objects to CSV * @param data Array of objects to be transformed * @param options CSV Options * @param callback (optional): If provided, calls back with the result error or CSV string * @returns If callback provided, returns void; otherwise, returns a promise of the result CSV string */ const buffered = (data, options, callback) => { if (callback == null) return exporter.buffered(data, options); exporter.buffered(data, options) .then(result => callback(null, result)) .catch(err => callback(err)); }; exports.buffered = buffered; /** * Convert array of objects to CSV * @param data Array of objects to be transformed * @param options CSV Options * @param callback (optional): If provided, calls back with the result error or CSV string * @returns If callback provided, returns void; otherwise, returns a promise of the result CSV string */ exports.toCsv = exports.buffered; /** * @deprecated Please use stream or toCsvStream */ exports.csv = exports.stream; /** * @deprecated Please use buffered or toCsv */ exports.csvBuffered = exports.buffered; module.exports = { buffered: exports.buffered, bufferedSync: exports.bufferedSync, stream: exports.stream, toCsv: exports.toCsv, toCsvSync: exports.toCsvSync, toCsvStream: exports.toCsvStream, StringWriter: string_writer_cjs_1.StringWriter, csv: exports.csv, csvBuffered: exports.csvBuffered }; exports.default = { buffered: exports.buffered, bufferedSync: exports.bufferedSync, stream: exports.stream, toCsv: exports.toCsv, toCsvSync: exports.toCsvSync, toCsvStream: exports.toCsvStream, StringWriter: string_writer_cjs_1.StringWriter, csv: exports.csv, csvBuffered: exports.csvBuffered };