Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
csv-stringify-as-promised
Advanced tools
The csv-stringify
is great, but it doesn't support promises! This module is a lightweight promise wrapper around it. The only prod dependency is csv-stringify
.
const stringify = require('csv-stringify-as-promised');
const assert = require('assert');
const input = [ [ '1', '2', '3', '4' ], [ 'a', 'b', 'c', 'd' ] ];
stringify(input).then((output) => {
assert.equal(output,
`1,2,3,4
a,b,c,d
`);
}).catch((err) => {
assert.fail(err);
});
You can pass any csv-stringify
options by passing an object as the second argument.
const stringify = require('csv-stringify-as-promised');
const assert = require('assert');
const options = { quotedString: true }
const input = [ [ '1', '2', '3', '4' ], [ 'a', 'b', 'c', 'd' ] ];
stringify(input, options).then((output) => {
assert.equal(output,
`"1","2","3","4"
"a","b","c","d"
`);
}).catch((err) => {
assert.fail(err);
});
By default, this module uses Node's builtin Promise
object, but if you prefer to use a different promise library, you can do so simply by overwriting the Promise
property on the module.
const stringify = require('csv-stringify-as-promised');
const bluebird = require('bluebird');
stringify.Promise = bluebird;
const input = [ [ '1', '2', '3', '4' ], [ 'a', 'b', 'c', 'd' ] ];
stringify(input).then((output) => {
// uses bluebird instead of Promise
}).catch((err) => {
// handle error
});
By default, this module uses csv-stringify
library, but if you prefer to use a different CSV library, you can do so simply by overwriting the csvStringify
property on the module.
const stringify = require('csv-stringify-as-promised');
stringify.csvStringify = yourCustomLibrary;
This module requires NodeJS 8 or greater
npm t
FAQs
csv-stringify wrapped in a promise
The npm package csv-stringify-as-promised receives a total of 4,105 weekly downloads. As such, csv-stringify-as-promised popularity was classified as popular.
We found that csv-stringify-as-promised demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.