Skip to main content
Module

x/ddu_vim/deps.ts>maybe

Dark deno-powered UI framework for neovim/Vim
Latest
function maybe
import { maybe } from "https://deno.land/x/ddu_vim@v4.0.0/deps.ts";

Returns the input value if it satisfies the provided predicate, or undefined otherwise.

import { is, maybe } from "https://deno.land/x/unknownutil@v4.0.0/mod.ts";

const a: unknown = "hello";
const _: string = maybe(a, is.String) ?? "default value";

Parameters

x: unknown

The value to be tested.

pred: Predicate<T>

The predicate function to test the value against.

Returns

T | undefined

The input value x if it satisfies the predicate, or undefined otherwise.