predictype / predicates/promises / promiseState
promiseState<
T
>(wrapper
,oper
):boolean
Defined in: predicates/promises/promiseState.ts:56
Checks the state of a wrapped Promise using the specified operation.
Note: This predicate requires a wrapper or custom Promise implementation that exposes state. Standard JS Promises do not expose their state synchronously.
T
The wrapped Promise with state.
The state operation to perform (e.g. ‘is_pending’, ‘is_fulfilled’).
boolean
True if the state check is valid according to the operator, otherwise false.
If the operation is not recognized.
const p = Promise.resolve(42);
const wrapped = wrapPromise(p);
promiseState(wrapped, 'is_pending'); // true (immediately after wrapping)
Supported Operators: