Skip to main content

pendingSome

@ts-rust/std


@ts-rust/std / Option / pendingSome

Function: pendingSome()

function pendingSome<T>(value): PendingOption<Awaited<T>>;

Defined in: packages/std/src/option/option.ts:88

Creates a PendingOption\<T\> that resolves to Some containing the awaited value.

Takes a value or a promise and wraps its resolved result in a Some, ensuring the value type is Awaited to handle any PromiseLike input.

Type Parameters

Type ParameterDescription

T

The type of the input value or promise.

Parameters

ParameterTypeDescription

value

T | Promise<T>

The value or promise to wrap in Some.

Returns

PendingOption<Awaited<T>>

A PendingOption resolving to Some with the awaited value.

Example

const x = pendingSome(42);
const y = pendingSome(Promise.resolve("hello"));

expect(await x).toStrictEqual(some(42));
expect(await y).toStrictEqual(some("hello"));