|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
344 bytes
|
| Line | |
|---|
| 1 | module.exports = thunkyp
|
|---|
| 2 |
|
|---|
| 3 | function thunkyp (fn) {
|
|---|
| 4 | let running = null
|
|---|
| 5 |
|
|---|
| 6 | return ready
|
|---|
| 7 |
|
|---|
| 8 | function ready () {
|
|---|
| 9 | if (running) return running
|
|---|
| 10 | const p = fn()
|
|---|
| 11 | if (!(p instanceof Promise)) running = Promise.resolve(p)
|
|---|
| 12 | else running = p
|
|---|
| 13 | running.catch(onerror)
|
|---|
| 14 | return running
|
|---|
| 15 | }
|
|---|
| 16 |
|
|---|
| 17 | function onerror () {
|
|---|
| 18 | running = null
|
|---|
| 19 | }
|
|---|
| 20 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.