UNPKG

enterprise-basics

Version:

A utility library for enterprise applications. It streamlines common business tasks by providing functions to process delimited and Excel files, generate professional PDFs, and handle email communications with attachments.

27 lines (26 loc) 1.07 kB
/** * Creates a delimited file (CSV) from an array of data objects. * * @param {any[]} data - Array of objects to be converted to CSV format * @param {',' | ';' | '|'} [delimiter=','] - Character to use as delimiter between fields * @param {string} [dateFormat='mm/dd/yyyy'] - Format to use for date fields * @param {Object} [columnFormats] - Optional column format specifications * * @returns {Promise<Uint8Array | string>} Returns either: * - Uint8Array containing the CSV file bytes * - Error message string if data array is empty * * @throws {Error} If data validation fails or CSV creation encounters an error * * @example * const data = [ * { name: 'John', date: new Date() }, * { name: 'Jane', date: '2024-01-01' } * ]; * const csvBytes = await createDelimitedFileBytes(data, ',', 'mm/dd/yyyy'); */ export declare function createDelimitedFileBytes(data: any[], delimiter?: ',' | ';' | '|', dateFormat?: string, columnFormats?: { [key: string]: { type: 'text' | 'date' | 'number'; }; }): Promise<Uint8Array | string>;