Objects.omit()
Syntax
function omit<T extends object, Keys extends keyof T>(object: T, ...which: Keys[]): Omit<T, Keys>
Creates a new object from an existing one with a set of keys excluded.
Parameters | |
object
|
The object to omit keys from. |
which
Rest
|
The keys to exclude from the new object. |
Example
import { Objects } from 'potence';
const colors = {
red: 0xff0000,
yellow: 0xffff00,
green: 0x00ff00,
blue: 0x0000ff,
purple: 0xff00ff,
cyan: 0x00ffff
};
Objects.omit(colors, 'blue', 'cyan');
// returns:
// {
// red: 0xff0000,
// yellow: 0xffff00,
// green: 0x00ff00,
// purple: 0xff00ff
// }
Remarks
This function is analogous to TypeScript’s
Omit<T>
.
This function uses
Objects.filter()
internally. If you wish to filter by value, you may want to use
Objects.filter()
directly.
See also
Objects.pick()
.