Giter VIP home page Giter VIP logo

Comments (4)

andykais avatar andykais commented on August 15, 2024

follow up question, what is the interopability between native promises and Q promises? Are these both legal

const nativePromise = (n) => new Promise(resolve => setTimeout(resolve, n))
const qPromise = (n) => {
  const deferred = q.defer()
  setTimeout(() => deferred.resolve(), n)
  return deferred.promise
}

const qPromiseFromNative = Q.resolve(nativePromise(100))
const nativePromiseFromQ = Promise.resolve(qPromise(100))

from q.

benjamingr avatar benjamingr commented on August 15, 2024

No, but it is pretty close, for example native promises have more guarantees on timings

from q.

andykais avatar andykais commented on August 15, 2024

Thanks, I was able to discover some differences with unhandledRejections as well. A native promise will become unhandled at the end of one node event loop. A Q promise does not have that guarantee. Q uses its own custom nextTick, so it makes sense.

If you wish to elaborate on their differences I would be interested. If not, feel free to close this issue. I see that there are subtle differences now.

from q.

benjamingr avatar benjamingr commented on August 15, 2024

@andykais well, I (helped) spec how unhandledRejection behaves in Node ( https://gist.github.com/benjamingr/0237932cee84712951a2 ) and I added the events to Q ( #643 ).

I don't think you should rely on the differences between Q and Node here :]

from q.

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.