
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
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 2,290 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
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.