CSVTransform for Node.js


Callback API

The callback API transform all the records and buffers the results into a single dataset which is passed to a user provided function. As a consequence, the resulting dataset must fit into memory. It must be used only when the input source is not too big.

The signature is const stream = transform(records, [options], handler, [callback]).


In the callback example, the user function shift the cells of every records.

import { transform } from 'stream-transform';
import assert from 'node:assert';

], function(record){
  return record;
}, function(err, output){
  assert.deepEqual(output, [
    [ '2', '3', '4', '1' ],
    [ 'b', 'c', 'd', 'a' ]

This example is available with the command node samples/api.callback.js.


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