Skip to content

Commit 650913f

Browse files
juanjoDiazknownasilya
authored andcommitted
feat: Pass transform options through (#262)
* Pass transform options through * Update readme
1 parent e7f943c commit 650913f

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,11 @@ const Json2csvTransform = require('json2csv').Transform;
212212

213213
const fields = ['field1', 'field2', 'field3'];
214214
const opts = { fields };
215+
const transformOpts = { highWaterMark: 16384, encoding: 'utf-8' };
215216

216217
const input = fs.createReadStream(inputPath, { encoding: 'utf8' });
217218
const output = fs.createWriteStream(outputPath, { encoding: 'utf8' });
218-
const json2csv = new Json2csvTransform(opts);
219+
const json2csv = new Json2csvTransform(opts, transformOpts);
219220

220221
const processor = input.pipe(json2csv).pipe(output);
221222

lib/JSON2CSVTransform.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ const Parser = require('jsonparse');
55
const JSON2CSVBase = require('./JSON2CSVBase');
66

77
class JSON2CSVTransform extends Transform {
8-
constructor(opts) {
9-
super(opts);
8+
constructor(opts, transformOpts) {
9+
super(transformOpts);
1010

1111
// Inherit methods from JSON2CSVBase since extends doesn't
1212
// allow multiple inheritance and manually preprocess opts

0 commit comments

Comments
 (0)