UNPKG

redis-smq-common

Version:

Provides essential components and utilities shared across RedisSMQ packages.

21 lines 620 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.withTimeout = withTimeout; const index_js_1 = require("./errors/index.js"); function withTimeout(callback, timeoutMs) { let called = false; const timeoutId = setTimeout(() => { if (called) return; called = true; callback(new index_js_1.AsyncCallbackTimeoutError()); }, timeoutMs); return (err, result) => { if (called) return; called = true; clearTimeout(timeoutId); callback(err, result); }; } //# sourceMappingURL=with-timeout.js.map