Skip to content

Function: formatToCsv()

formatToCsv<T>(array, schema): string

Format an array to CSV string

Type Parameters

Type Parameter
T extends TCsvSchema

Parameters

ParameterTypeDescription
arrayStaticDecode<T>[]An array of data
schemaTOutput schema mapping of each row

Returns

string

A CSV string

Throws

If fail to format the array

Example

ts
const output = formatAsCsv([{ id: 1, name: 'a' }], schema);

Defined in

src/formatter/format-to-csv.ts:22

Released under the MIT License.