Skip to main content
Module

x/is_valid_package_name/deps.ts>ifElseFn

Validation for package name
Latest
variable ifElseFn
import { ifElseFn } from "https://deno.land/x/is_valid_package_name@v1.0.0/deps.ts";

Creates a function that will process either the onTrue or the onFalse function depending upon the result of the condition predicate.

Examples

Example 1

ifElseFn((x: number) => x > 10, 'big', 'small')(20) // 'big'
const fn = ifElseFn((x: number) => x > 10, (x) => x + 1, (x) => x - 1)
fn(11) // 12
fn(9) // 8

type

<V, R, T, F>(
condition: (val: V) => R,
onTrue: T | ((val: V) => T),
onFalse: F | ((val: V) => F),
) => unknown