PapaParse
PapaParse copied to clipboard
promises?
Is there any way to use a promise instead of a callback? I've gotten to where I hate callbacks.
this worked for me:
const papaPromise = (importFile) => new Promise((resolve, reject) => {
const file = fs.createReadStream(importFile);
Papa.parse(file, {
header: true,
complete: function(results) {
resolve(results);
},
error: function(error) {
reject(error);
}
});
})
const results = await papaPromise(importFile);
@kcrawfordus thanks for your snipet. It will be great if you can provide a PR to include it as part of papaParse docs
Any plans to have the API itself support promises?
@custompro12 not from my side but I will be happy to review a PR that ads support for it
Was confusing seeing an undefined return type lol, almost had the callback pattern purged from my mind.
@custompro12 not from my side but I will be happy to review a PR that ads support for it
Cool. I will add a pull request on the weekend 👍
Any update on this?