Skip to content

Add WrappedMaybe['try'] method #75

Open
@erwijet

Description

@erwijet

Introduce a try method on WrappedMaybe which called the given fn and if it throws, it returns null.

const str: string | null = '...';
const schema = z.object(...);

const res = maybe(str)?.try(JSON.parse)?.try(schema.parse)?.take() ?? OTHERWISE;

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions