CSVTransform for Node.js


Callback API

Table of Contents

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 '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.