CSVStringify for Node.js

IssuesGitHub

Option eof

The eof option append the value of the record_delimiter option after the last record. It is enabled by default.

Default behavior

By default, the eof option is enabled. Not defining its value is equivelent set seting eof as true:

import assert from "assert";
import { stringify } from "csv-stringify/sync";

const data = stringify([
  ["a", "b"],
  ["c", "d"],
]);
assert.deepStrictEqual(data, "a,b\nc,d\n");

Disabling the behavior

Set the eof value to false to not append extra characters after the last record:

import assert from "assert";
import { stringify } from "csv-stringify/sync";

const data = stringify(
  [
    ["a", "b"],
    ["c", "d"],
  ],
  {
    eof: false,
  }
);
assert.deepStrictEqual(data, "a,b\nc,d");

About

The Node.js CSV project is an open source product hosted on GitHub and developed by Adaltas.