GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • GitHub
  • Generate
  • Parse
  • Transform
  • Stringify
  • How to contribute
  • GitHub
  • Issue Tracker
  • License
  • Homepage
  • Converter
  • API
  • Stream
  • Callback

This view

  • Original page
  • New address

GeezerVison is showing csv.js.org — CSV Project - Callback

Callback API

Also available in the csv module is the callback API. The all dataset is available in the second callback argument. Thus it will not scale with large dataset. The callback example initialize each CSV function sequentially, with the output of the previous one. Note, for the sake of clarity, the example doesn't deal with error management. It is enough spaghetti code.

// Import the package
import { generate, parse, transform, stringify } from "csv";

// Run the pipeline
generate({ seed: 1, columns: 2, length: 20 }, function (err, data) {
  parse(data, function (err, data) {
    transform(
      data,
      function (data) {
        return data.map(function (value) {
          return value.toUpperCase();
        });
      },
      function (err, data) {
        stringify(data, function (err, data) {
          process.stdout.write(data);
        });
      },
    );
  });
});
./packages/csv/samples/callback.js

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.