UNPKG

977 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.done = exports.isItReady = exports.removeFromPending = exports.addPending = void 0;
4/**
5 * pending indicates any ongoing procceses
6 */
7var pending = [];
8var addPending = function (promise) {
9 pending.push(promise);
10};
11exports.addPending = addPending;
12var removeFromPending = function (promise) {
13 pending = pending.filter(function (a) { return a !== promise; });
14};
15exports.removeFromPending = removeFromPending;
16/**
17 * is it really ready?
18 */
19var readyFlag = false;
20var isItReady = function () { return readyFlag; };
21exports.isItReady = isItReady;
22/**
23 * waits for all necessary imports to be fulfilled
24 */
25var done = function () {
26 if (pending.length) {
27 readyFlag = false;
28 return Promise.all(pending)
29 .then(function (a) { return a[1]; })
30 .then(exports.done);
31 }
32 readyFlag = true;
33 return Promise.resolve();
34};
35exports.done = done;