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

mapOrForNullable

Return the result of transformer with using input as an argument for it if input is not null. Otherwise, return defaultValue.

Basically, this operation is a combination map() and unwrapOr().

  • U must not be Nullable<*>.
    • If the result of transformer is null, this throw an Error.
    • If the result of defaultValue is null, this throw an Error.
  • If you'd like to accept Nullable<*> as U, use a combination andThen() and or().
function mapOrForNullable<T, U>(
input: Nullable<T>,
defaultValue: NotNull<U>,
transformer: TransformFn<T, NotNull<U>>,
): NotNull<U>;
§
mapOrForNullable<T, U>(input: Nullable<T>, defaultValue: NotNull<U>, transformer: TransformFn<T, NotNull<U>>): NotNull<U>
[src]

§Type Parameters

§Parameters

§
input: Nullable<T>
[src]
§
defaultValue: NotNull<U>
[src]
§
transformer: TransformFn<T, NotNull<U>>
[src]

§Return Type