together-ai-sdk
Version:
A typescript SDK for the Together AI API
21 lines (20 loc) • 687 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.asyncTimeout = void 0;
/**
* Waits for the timeout to expire, then runs the callback
* Use this when needing to await the timeout:
* `await asyncTimeout(func, 1000)`
* @param timeout - number of milliseconds to wait
* @param callback - the function to execute when the timeout is finished.
* Acts as a blocking sleep function if no callback is provided
*/
const asyncTimeout = async (timeout, callback) => {
return await new Promise(resolve => {
setTimeout(() => {
callback?.();
resolve();
}, timeout);
});
};
exports.asyncTimeout = asyncTimeout;