API
@agape/util

omit Function

Creates a new object by omitting specified properties from the original object.

API

function omit<T extends object, K extends string | number | symbol>(  instance: T,  keys: K[]): Omit<TK>

omit

Omit<T, K>

Creates a new object by omitting specified properties from the original object.

@paraminstance:  T
The source object to omit properties from
@paramkeys:  K[]
Array of property names to omit from the result
@returnsOmit<T, K>

Description

Creates a new object by omitting specified properties from the original object.

This function returns a new object that contains all properties from the original object except for the ones specified in the keys parameter.

Usage

Omit a single property

const user = { id: 1, name: 'John', email: '[email protected]', password: 'secret' };

const publicUser = omit(user, ['password']);
// Result: { id: 1, name: 'John', email: '[email protected]' }

Omit multiple properties

const user = { id: 1, name: 'John', email: '[email protected]', password: 'secret' };

const basicUser = omit(user, ['password', 'email']);
// Result: { id: 1, name: 'John' }