Code Monkey home page Code Monkey logo

Comments (5)

Jeff-Tian avatar Jeff-Tian commented on June 8, 2024 4

Yes, thank you. I'm good with wrapping it with new Promise(), and jsonexport is really helpful for converting json to csv in my project.

from jsonexport.

AckerApple avatar AckerApple commented on June 8, 2024 1

NOTE: previous comment was me signed in from my work account

from jsonexport.

AckerApple avatar AckerApple commented on June 8, 2024

I don’t use await new Promise, I use just new Promise with a then attached to it.

But otherwise, I promise jsonexport relatively the same way you demonstrated above

from jsonexport.

Jeff-Tian avatar Jeff-Tian commented on June 8, 2024

Yes I agree await new Promise is ugly, so is there any better way to improve it?

For example, the json-2-csv repo support the traditional node js fasion

var json2csvCallback = function (err, csv) {
    if (err)
        throw err;
    console.log(csv);
};
converter.json2csv(documents, json2csvCallback);

and at the same time, it exposes an async/await fasion:

const csvData = await converter.json2csvAsync(data);
console.log(csvData)

Is this repo jsonexport exposes a -Async like method as well?

from jsonexport.

applecod avatar applecod commented on June 8, 2024

This library has no async function beyond a callback as far as I know.

I’m an Angular guy and I use Observables over Promises but absolutely I still use Promises.

One day it might be Promises someone needs. Another day it’s Observables. And then another day someone wants functional Ramda like access.

In whatever project I’m on that needs jsonexport, I just add one function that wraps jsonexport in an Observervable. I’ve even used the promise package Bluebird to promisify jsonexport (bluebird has one function called promisify that converts any callback to a promise).

To close, the ol saying “if it ain’t broke don’t fix it” comes to mind. That may come off as a lazy statement but I’ve never felt the need to “improve” this package (with async abilities)

from jsonexport.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.