Skip to content

omit

Generate a new object or array from the input object or array with specified keys or indices removed. The returned value is a plain object or array, and the input will not be modified.

Added in v0.0.1

Usage

typescript
import { omit } from 'parsnip-kit'

const obj = omit({ a: 1, b: 2, c: 3 }, ['b', 'c'] as const)
// Omit<{ a: number; b: number; c: number; }, "b" | "c">
// { a: 1 }
const arr = omit([1, 2, 3, 4], ['[1]', '3'] as const)
// Omit<number[], 1 | 3>
// [1, 3]

API

Type Parameter

ArgTypeDescription
Textends objectType of the object to be processed
Rextends readonly string[]Array type of field paths

Arguments

ArgTypeOptionalDefaultDescription
objTfalseundefinedThe object or array to process
keysRfalseundefinedThe keys or array indices to delete

Returns

Type
Omit<T, KeyOrIndex<ExtractUnion<R>>>

Reference

KeyOrIndex ExtractUnion