Skip to content

omit

Import from @varavel/vdl-plugin-sdk/utils/objects.

function omit<T, K>(obj, keys): Omit<T, K>;

Creates a new object with specified keys omitted.

This function takes an object and an array of keys, and returns a new object that excludes the properties corresponding to the specified keys.

Type Parameters

Type Parameter Description
T extends Record\<string, any> The type of object.
K extends string | number | symbol The type of keys in object.

Parameters

Parameter Type Description
obj T The object to omit keys from.
keys readonly K[] An array of keys to be omitted from the object.

Returns

Omit\<T, K>

A new object with the specified keys omitted.

Example

const obj = { a: 1, b: 2, c: 3 };
const result = omit(obj, ['b', 'c']);
// result will be { a: 1 }