@react-md/utils
Version:
General utils for react-md.
39 lines • 815 B
JavaScript
/**
* Create a new object that does not contain the provided keys.
*
* @example
* Simple Examples
* ```ts
* const object = {
* a: "",
* b: 3,
* c: false,
* 4: null,
* } as const;
*
* expect(omit(object, ["a"])).toEqual({
* b: 3,
* c: false,
* 4: null,
* });
* expect(omit(object, ["a", "c", "d"])).toEqual({ b: 3 });
* ```
*
* @internal
* @param object - The object to remove keys from
* @param omitKeys - The keys to remove.
* @returns a new object without the specified keys
*/
export function omit(object, omitKeys) {
if (!omitKeys.length) {
return object;
}
var result = {};
for (var key in object) {
if (!omitKeys.includes(key)) {
result[key] = object[key];
}
}
return result;
}
//# sourceMappingURL=omit.js.map