Skip to content

mapTry

mapTry<U, T>(x, fn): AsTry<U>

Map the value of the Try when it is a Success.

Example

mapTry("foobar", s => `${s}${s}`)
// => "foobarfoobar"
mapTry(new Error("foobar"), s => `${s}${s}`)
// => Error("foobar")

Type Parameters

U

The transformed type.

T extends unknown

The input type.

Parameters

x

T

The Try to transform.

fn

(e) => U

The success transform.

Returns

AsTry<U>