UNPKG

@ibsheet/loader

Version:

Dynamically load support module for IBSheet

29 lines 1.23 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.asyncItemTest = asyncItemTest; var lodash_1 = require("../../shared/lodash"); var config_1 = require("../../config"); function asyncItemTest(options) { var _this = this; var debug = (0, lodash_1.get)(options, 'debug', false); var MAX_RETRY = (0, lodash_1.get)(options, 'retry.maxCount', config_1.LOAD_TEST_RETRY_MAX_COUNT); var INTERVAL_TIME = (0, lodash_1.get)(options, 'retry.intervalTime', config_1.LOAD_TEST_RETRY_INTERVAL); return new Promise(function (resolve, reject) { var nCount = 1; var testInterval = setInterval(function () { if (nCount >= MAX_RETRY) { clearInterval(testInterval); return reject("maximum retry attempts reached: ".concat(MAX_RETRY)); } if (_this.test()) { clearInterval(testInterval); return resolve(_this); } if (debug) { console.warn("\"".concat(_this.alias, "\" load delayed (").concat(nCount * INTERVAL_TIME, "ms)")); } nCount += 1; }, INTERVAL_TIME); }); } //# sourceMappingURL=async-test.js.map