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.
1234567891011121314151617181920 |
- module.exports = thunkyp
-
- function thunkyp (fn) {
- let running = null
-
- return ready
-
- function ready () {
- if (running) return running
- const p = fn()
- if (!(p instanceof Promise)) running = Promise.resolve(p)
- else running = p
- running.catch(onerror)
- return running
- }
-
- function onerror () {
- running = null
- }
- }
|