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
Arg | Type | Description |
---|---|---|
T | extends object | Type of the object to be processed |
R | extends readonly string[] | Array type of field paths |
Arguments
Arg | Type | Optional | Default | Description |
---|---|---|---|---|
obj | T | false | undefined | The object or array to process |
keys | R | false | undefined | The keys or array indices to delete |
Returns
Type |
---|
Omit<T, KeyOrIndex<ExtractUnion<R>>> |