import { cv } from "https://deno.land/x/is_valid@v1.0.0-beta.16/mod.ts";
Utility function to convert arguments.
Examples
Example 1
Example 1
const fn = cv(() => 1, (val) => val + 1)
fn() // 2
const upcast = cv((val: unknown) => val as string, (val) => val.length > 8)
upcast('hello-world' as unknown) // true
const mailHeader = cv((user: { name: string }) => user.name, (name) => `Dear ${name}` )
mailHeader({ name: 'Tom' }) // 'Dear Tom'