import { pick } from "https://deno.land/x/typestruct@1.0.0-beta.5/mod.ts";
Create Pick
struct. From struct, pick a set of properties whose keys are in the definition.
Examples
Example 1
Example 1
import {
is,
object,
pick,
string,
} from "https://deno.land/x/typestruct@$VERSION/mod.ts";
import { assertEquals } from "https://deno.land/std@$VERSION/testing/asserts.ts";
const User = object({ id: string(), name: string() });
const data = { name: "tom" };
assertEquals(is(User, data), false);
assertEquals(is(pick(User, ["name"]), data), true);
Type Parameters
K extends keyof U