CSV Stringify options
All options are optional. All the options from the Node.js Writable Stream API and the Node.js Readable Stream API are supported and passed as is.
Available options
bom(boolean)
Since version 5.4.0
Prepend the byte order mark (BOM) to the output stream.cast
Since version 1.1.0
Defines custom cast for certain data types; wasformattersuntil version 4.3.1.bigintCustom function to transform bigint values.booleanCustom function to transform boolean values.dateCustom function to transform date values.numberCustom function to transform number values.objectCustom function to transform object literals.stringCustom function to transform string values.
columns(array|object)
Since version 0.0.1
Influence the generation of records at the field level.delimiter(string)
Since version 0.0.1
Set the field delimiter, one or multiple characters, defaults to a comma.eof(boolean)
Since version 0.0.2
Append the value of therecord_delimiteroption after the last record, default totrue.escape(string|Buffer)
Since version 0.0.1
Single character used for escaping; only apply to characters matching thequoteand theescapeoptions default to".escape_formulas(boolean)
Since version 6.3.0
Escape values that start with=,+,-,@,\t, or\rwith'and defend against CSV injection attacks.header(boolean)
Since version 0.0.1
Display the column names on the first line if the columns option is provided or discovered.quote(string|Buffer|boolean)
Since version 0.0.1
The quote characters surrounding a field, defaults to the"(double quotation marks), an empty quote value will preserve the original field, whether it contains quotation marks or not.quoted(boolean)
Since version 0.0.1
Boolean, default to false, quote all the non-empty fields even if not required.quoted_empty(boolean)
Since version 5.1.0
Quote empty strings and overridesquoted_stringon empty strings when defined; default isfalse.quoted_match(String|RegExp)
Since version 5.1.0
Quote all fields matching a regular expression; default isfalse.quoted_string(boolean)
Since version 5.1.0
Quote all fields of type string even if not required; default isfalse.record_delimiter(string|Buffer)
Since version 0.0.1
String used to delimit record rows or a special value; special values are 'auto', 'unix', 'mac', 'windows', 'ascii', 'unicode'; defaults to 'auto' (discovered in source or 'unix' if no source is specified); wasrowDelimiteruntil version 4.3.1.
Choose your style
The code uses snake case as the conventional style for function and variable names. In snake case, all letters are lowercase and underscores separate words. It is however accepted to provide options in camel case. Thus, record_delimiter and recordDelimiter are equivalent when initialising a new instance of stringify. The option will be converted into snake case and exposed as such. For example, in case you need to access the record_delimiter option, use generate().options.record_delimiter and not generate().options.recordDelimiter. Choose the case which best fit your coding style.