ryu1kn / csv-writer

Convert objects/arrays into a CSV string or write them into a CSV file
https://www.npmjs.com/package/csv-writer
MIT License
246 stars 39 forks source link

Support writing to other destinations #80

Open darichey opened 3 years ago

darichey commented 3 years ago

It would be great if we could write to stdout or a Buffer, for example. This should be very easy, because fs.writeFile already supports writing to these.

This already works:

const writer: CsvWriter<T> = createObjectCsvWriter({
    // @ts-ignore
    path: process.stdout.fd,
   // ...
});

Therefore, the only thing that needs to change is the type of path to match the type of the file parameter for fs.writeFile. However, this has changed over time. The readme states the minimum version of node is 4 (in which string is the correct type), but the version of node types is "^14.14.7".

What do you think? If you are amenable to the idea, I can open a pull request.