UNPKG

json-schema-library

Version:

Customizable and hackable json-validator and json-schema utilities for traversal, data generation and validation

11 lines (9 loc) 375 B
import { isObject } from "../utils/isObject"; export function pick<T extends { [P in keyof T]: unknown }, K extends keyof T>(value: T, ...properties: K[]) { if (!isObject(value) || properties.length === 0) { return value; } const result = {} as Pick<T, K>; properties.forEach((property) => (result[property] = value[property])); return result; }