Async Option constant for None.
A pre-resolved Promise<None> that can be reused to avoid creating
new Promise instances when returning None from async functions.
Since None extends Option<never>, this constant can be assigned to any
AsyncOption<T> (i.e., Promise<Option<T>>) due to TypeScript's covariance.
Since
1.8.0
Example
asyncfunctionfindUser(id: number): AsyncOption<User> { if (id < 0) { returnASYNC_NONE; } constuser = awaitdb.findUser(id); returnuser ? Some(user) : ASYNC_NONE; }
Example
// Useful in conditional async returns functionmaybeLoadAsync(shouldLoad: boolean): AsyncOption<Data> { if (!shouldLoad) { returnASYNC_NONE; } returnloadDataAsync(); }
Async Option constant for
None. A pre-resolvedPromise<None>that can be reused to avoid creating new Promise instances when returningNonefrom async functions.Since
None extends Option<never>, this constant can be assigned to anyAsyncOption<T>(i.e.,Promise<Option<T>>) due to TypeScript's covariance.