mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 09:10:35 +08:00
14 lines
366 B
TypeScript
14 lines
366 B
TypeScript
interface Peek {
|
|
<T = undefined>(promise: T | Promise<T>): Promise<T> | T,
|
|
status<T = undefined>(
|
|
promise: T | Promise<T>,
|
|
): 'pending' | 'fulfilled' | 'rejected' | 'unknown'
|
|
}
|
|
|
|
const noopPeek = <T = undefined>(_: Promise<T>) => _;
|
|
noopPeek.status = () => 'unknown';
|
|
|
|
export const peek: Peek = typeof Bun !== 'undefined'
|
|
? Bun.peek
|
|
: noopPeek as Peek;
|