index.js 326 B

123456789101112
  1. 'use strict';
  2. const intoStream = require('into-stream');
  3. const csvParser = require('csv-parser');
  4. const getStream = require('get-stream');
  5. module.exports = (input, opts) => {
  6. if (typeof input === 'string' || Buffer.isBuffer(input)) {
  7. input = intoStream(input);
  8. }
  9. return getStream.array(input.pipe(csvParser(opts)));
  10. };