UNPKG

flipper-common

Version:

Server & UI shared Flipper utilities

26 lines 766 B
"use strict"; /** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @format */ Object.defineProperty(exports, "__esModule", { value: true }); exports.timeout = void 0; function timeout(ms, promise, timeoutMessage) { return new Promise((resolve, reject) => { const timeoutHandle = setTimeout(() => { reject(new Error(timeoutMessage || `Timed out in ${ms} ms.`)); }, ms); promise .then(resolve) .finally(() => { clearTimeout(timeoutHandle); }) .catch(reject); }); } exports.timeout = timeout; //# sourceMappingURL=timeout.js.map