first commit
This commit is contained in:
20
app_vue/node_modules/thunky/promise.js
generated
vendored
Normal file
20
app_vue/node_modules/thunky/promise.js
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
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
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user