UNPKG

@adaptabletools/adaptable-cjs

Version:

Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements

25 lines (24 loc) 790 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.runIfNotResolvedIn = void 0; /** * Calls the callback if the promise does not resolve in a amount of time. * * @param promise * @param callback Called if promise does not resolve in the time defined by 'delay' * @param delay Time after which if the promise was not resolved the callback (fn) is called. */ const runIfNotResolvedIn = async (promise, callback, delay = 100) => { let isFulfilled = false; promise?.then(() => { isFulfilled = true; }); (async () => { await new Promise((resolve) => setTimeout(resolve, delay)); if (!isFulfilled) { callback(); } })(); return promise; }; exports.runIfNotResolvedIn = runIfNotResolvedIn;