UNPKG

@adv-ui/boros-tcf-stub

Version:

Adevinta GDPR - Transparency and Consent Framework - Stub for Boros TCF

31 lines (28 loc) 832 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.waitUntil = void 0; var waitUntil = function waitUntil(_ref) { var condition = _ref.condition, _ref$timeout = _ref.timeout, timeout = _ref$timeout === void 0 ? 20000 : _ref$timeout, _ref$interval = _ref.interval, interval = _ref$interval === void 0 ? 5 : _ref$interval, timeoutMessage = _ref.timeoutMessage; return new Promise(function (resolve, reject) { var iid = setInterval(function () { if (condition()) { clearTimeout(tid); clearInterval(iid); resolve(); } }, interval); var tid = setTimeout(function () { clearTimeout(tid); clearInterval(iid); reject(new Error(timeoutMessage)); }, timeout); }); }; exports.waitUntil = waitUntil;