assistant-stream
Version:
Streaming utilities for AI assistants
16 lines (15 loc) • 489 B
JavaScript
// src/core/utils/withPromiseOrValue.ts
function withPromiseOrValue(callback, thenHandler, catchHandler) {
let value;
try {
const promiseOrValue = callback();
if (typeof promiseOrValue === "object" && promiseOrValue !== null && "then" in promiseOrValue) return promiseOrValue.then(thenHandler, catchHandler);
value = promiseOrValue;
} catch (e) {
catchHandler(e);
return;
}
thenHandler(value);
}
export { withPromiseOrValue };
//# sourceMappingURL=withPromiseOrValue.js.map