method AsyncResult.prototype.map
AsyncResult.prototype.map<U>(fn: (value: T) => U): AsyncResult<U, E>

Transforms the Ok value using a mapper function, leaving Err untouched.

Examples

Example 1

const result = fetchUser("123")
  .map(user => user.name)
  .map(name => name.toUpperCase());

Type Parameters

The type of the transformed value

Parameters

fn: (value: T) => U

Function to transform the Ok value

Return Type

A new AsyncResult with the transformed value

Usage

import { AsyncResult } from "result/mod.ts";