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

tryCatch

import { tryCatch } from "https://github.gh-proxy.cn/raw.githubusercontent.com/baetheus/fun/main/datum.ts";

Create a Datum from a function that might throw.

@example
import { tryCatch } from "./datum.ts";

const safeParse = tryCatch(JSON.parse);
const result1 = safeParse('{"key": "value"}'); // Replete({key: "value"})
const result2 = safeParse('invalid json'); // Initial
function tryCatch<AS extends unknown[], A>(fasr: (...as: AS) => A): (...as: AS) => Datum<A>;
§
tryCatch<AS extends unknown[], A>(fasr: (...as: AS) => A): (...as: AS) => Datum<A>
[src]

§Type Parameters

§
AS extends unknown[]
[src]

§Parameters

§
fasr: (...as: AS) => A
[src]

§Return Type

§
(...as: AS) => Datum<A>
[src]