Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

§Functions

andThenAsyncForOption

Returns None if the input is None, otherwise calls transformer with the value and returns the result.

andThenForOption

Returns None if the input is None, otherwise calls transformer with the value and returns the result.

createNone
createSome
expectSome

Return input as T if the passed input is Some(T). Otherwise, throw TypeError with the passed msg.

filterForOption

Returns None if the option is None, otherwise the result should be resolved by the result of predicate with the wrapped value as the arguments:

flattenForOption

Flatten the inner value of input.

fromErrToOption

Convert to Some(E) if input is Err(E). Otherwise, return None.

fromOkToOption

Convert to Some(T) if input is Ok(T). Otherwise, return None.

inspectOption
  • Return input directly.
    • This value is passed as the input. But it maybe mutated by calling effector.
  • Call effector with the inner value of input if input is Some(T).
  • This main purpose is to inspect an inner value in a chained function calling. If you don't have to do it, you should not mutate the inner value. if-else statement might be sufficient to mutate the inner value instead of calling this function.
isNone
isSome
mapAsyncForOption

Maps a Option<T> to Option<U> by applying a transformer function to an contained Some(T) value, leaving an None value untouched.

mapForOption

Maps a Option<T> to Option<U> by applying a transformer function to an contained Some(T) value, leaving an None value untouched.

mapOrAsyncForOption

Return the result of transformer with using input as an argument for it if input is Some(T). Otherwise, return defaultValue.

mapOrElseAsyncForOption

Maps a Option<T> to U by applying transformer to a contained Some(T) value in input, or a recoverer function to a contained None value in input. This function can be used to unpack a successful result while handling an error.

mapOrElseForOption

Maps a Option<T> to U by applying transformer to a contained Some(T) value in input, or a recoverer function to a contained None value in input. This function can be used to unpack a successful result while handling an error.

mapOrForOption

Return the result of transformer with using input as an argument for it if input is Some(T). Otherwise, return defaultValue.

okOrElseForPlainOption

Transforms the Option<T> into a Result<T, E>, mapping Some(v) to Ok(v) and None to Err(err()).

okOrForPlainOption

Transforms the Option<T> into a Result<T, E>, mapping Some(v) to Ok(v) and None to Err(err).

orElseAsyncForOption

Return input as T if the passed input is Some(T). Otherwise, return the result of recoverer.

orElseForOption

Return input as T if the passed input is Some(T). Otherwise, return the result of recoverer.

toNullableFromOption

Return T if input is Some(T). Otherwise, return null.

toUndefinableFromOption

Return T if input is Some(T). Otherwise, return undefined.

transposeOptionToResult

Transposes an Option of a Result into a Result of an Option.

transposeResultToOption

Transposes a Result of an Option into an Option of a Result.

unwrapOrElseAsyncForOption

Unwraps a result input, returns the content of an Some(T). If the value is an None then it calls def with its value.

unwrapOrElseForOption

Unwraps a result input, returns the content of an Some(T). If the value is an None then it calls def with its value.

unwrapOrForOption

Unwraps a result input, returns the content of an Some(T). If the value is an None then return defaultValue.

unwrapSome

Return the inner T of a Some(T).

§Interfaces

None

This type represents no value. This is a pair of Some(T).

Some

This type contain some value of T.

§Type Aliases

Option deprecated

Consider to use Nullable<T>, Undefinable<T>, or Maybe<T> to express an absence of a value. In JavaScript, they satisfy almost use cases. Probably, you might not have to use this type.