json-schema-library
Version:
Customizable and hackable json-validator and json-schema utilities for traversal, data generation and validation
20 lines (19 loc) • 466 B
JavaScript
/**
* Omit properties from input schema. Accepts any number of properties to
* remove. Example:
*
* ```ts
* omit(myObject, "if", "dependencies");
* ```
*
* @returns shallow copy of input object without specified properties
*/
export function omit(object, ...keysToOmit) {
const result = {};
Object.keys(object).forEach((key) => {
if (!keysToOmit.includes(key)) {
result[key] = object[key];
}
});
return result;
}