json-schema-library
Version:
Customizable and hackable json-validator and json-schema utilities for traversal, data generation and validation
14 lines (13 loc) • 368 B
JavaScript
import { isObject } from "../utils/isObject";
export function pick(value, ...properties) {
if (!isObject(value) || properties.length === 0) {
return value;
}
const result = {};
properties.forEach((property) => {
if (value[property] !== undefined) {
result[property] = value[property];
}
});
return result;
}