rc-js-util
Version:
A collection of TS and C++ utilities to help writing performant and correct applications, achieved through strict typing and (removable) invariant checking.
16 lines (15 loc) • 364 B
text/typescript
/**
* @public
* Returns a Promise of rejection with the supplied error if the `value` is falsy.
*
* @remarks
* See {@link promiseRejectFalsey}.
*/
export async function promiseRejectFalsey(value: Promise<boolean> | boolean, error: unknown): Promise<void>
{
const result = await value;
if (!result)
{
return Promise.reject(error);
}
}