juanjoDiaz / json2csv

Flexible conversion between JSON and CSV
https://juanjodiaz.github.io/json2csv/
MIT License
296 stars 32 forks source link

WHATWG Async Parser crashing with an exception in v7.0.0 #35

Closed aadilmehrajbhat closed 1 year ago

aadilmehrajbhat commented 1 year ago

I am unable to generate the CSV using WHATWG Async Parser available in v7.0.0. I have also included the codesandbox link for reference: https://codesandbox.io/s/whatwg-parser-2rz8ty

import { AsyncParser } from "@json2csv/whatwg";

const data = [
  { carModel: "Audi", price: 0, colors: ["blue", "green", "yellow"] },
  { carModel: "BMW", price: 15000, colors: ["red", "blue"] },
  { carModel: "Mercedes", price: 20000, colors: "yellow" },
  { carModel: "Porsche", price: 30000, colors: ["green", "teal", "aqua"] },
  { carModel: "Tesla", price: 50000, colors: [] }
];

(async () => {
  const opts = {};
  const transformOpts = {};
  const asyncOpts = {};
  const parser = new AsyncParser(opts, transformOpts, asyncOpts);

  const csv = await parser.parse(data).promise();

  document.body.innerText = csv;
})();

Screenshot 2023-05-30 at 3 37 25 PM

juanjoDiaz commented 1 year ago

Good catch!

Fixed on v7.0.1. See https://codesandbox.io/s/whatwg-parser-forked-mc9j6f