UNPKG

pulsar_sdk_js

Version:

A convenient way for you to interact with Pulsar's Third Party APIs, using typified classes.

18 lines (17 loc) 628 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.sleep = exports.waitForCondition = void 0; async function waitForCondition(conditionFunction, maxTimeout, interval = 100) { const startTime = Date.now(); while (!conditionFunction()) { if (Date.now() - startTime > maxTimeout) { throw new Error('Condition not met within the specified timeout.'); } await sleep(interval); } } exports.waitForCondition = waitForCondition; async function sleep(interval) { await new Promise((resolve) => setTimeout(resolve, interval)); } exports.sleep = sleep;