GuobaGuoba Utils

omit

@guoba-ai/utils / object / omit

Function: omit()

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

Defined in: object.ts:82

Create a new object with specified keys omitted.

Parameters

obj

T

The source object

keys

K[]

Keys to omit

Returns

Omit<T, K>

A new object without the specified keys

Example

omit({ a: 1, b: 2, c: 3 }, ['b', 'c']) // { a: 1 }

omit({ a: 1, b: 2 }, []) // { a: 1, b: 2 }

const nested = { value: 1 }
omit({ nested, hidden: true }, ['hidden']).nested === nested // true

Warning

This is a shallow copy. Nested objects are shared with the source object.

On this page