UNPKG

appium-xcuitest-driver

Version:

Appium driver for iOS using XCUITest for backend

30 lines 929 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TimeoutError = void 0; exports.withTimeout = withTimeout; /** Error thrown by {@link withTimeout} when the deadline is exceeded. */ class TimeoutError extends Error { constructor(message) { super(message ?? 'Operation timed out'); this.name = 'TimeoutError'; } } exports.TimeoutError = TimeoutError; /** Resolves with `promise` or rejects if it does not settle before `timeoutMs`. */ async function withTimeout(promise, timeoutMs, message) { let timer = null; try { return await Promise.race([ promise, new Promise((_resolve, reject) => { timer = setTimeout(() => reject(new TimeoutError(message)), timeoutMs); }), ]); } finally { if (timer) { clearTimeout(timer); } } } //# sourceMappingURL=async.js.map