Skip to content

Commit

Permalink
Create promise before pushing the data in the AsyncParser
Browse files Browse the repository at this point in the history
  • Loading branch information
juanjoDiaz committed Feb 24, 2019
1 parent 0c298e6 commit 6c979d9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/json2csv.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ module.exports.Transform = JSON2CSVTransform;
module.exports.parse = (data, opts) => new JSON2CSVParser(opts).parse(data);
module.exports.parseAsync = (data, opts, transformOpts) => {
const asyncParser = new JSON2CSVAsyncParser(opts, transformOpts);
const promise = asyncParser.promise();

data.forEach(item => asyncParser.input.push(item));
asyncParser.input.push(null);

return asyncParser.promise();
return promise;
};

0 comments on commit 6c979d9

Please sign in to comment.