CSVStringify for Node.js

IssuesGitHub

Callback API

The signature is stringify(records, [options], callback).

The callback example receives an array and a callback function. The input is serialised into a string unless an error occurred.

import assert from 'node:assert';
import { stringify } from 'csv-stringify';

stringify([
  [ '1', '2', '3', '4' ],
  [ 'a', 'b', 'c', 'd' ]
], function(err, output){
  assert.equal(output, '1,2,3,4\na,b,c,d\n');
});

Run this example with the command node samples/api.callback.js.

About

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