Dashboard sipadu mbip
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

promise.js 344B

1234567891011121314151617181920
  1. module.exports = thunkyp
  2. function thunkyp (fn) {
  3. let running = null
  4. return ready
  5. function ready () {
  6. if (running) return running
  7. const p = fn()
  8. if (!(p instanceof Promise)) running = Promise.resolve(p)
  9. else running = p
  10. running.catch(onerror)
  11. return running
  12. }
  13. function onerror () {
  14. running = null
  15. }
  16. }