Skip to content

omit

Omit unwanted attributes from an object

106 bytes

Usage

Given an object and a list of keys in the object, returns a new object without any of the given keys.

import * as
import _
_
from 'radashi'
const
const fish: {
name: string;
weight: number;
source: string;
brackish: boolean;
}
fish
= {
name: string
name
: 'Bass',
weight: number
weight
: 8,
source: string
source
: 'lake',
brackish: boolean
brackish
: false,
}
import _
_
.
omit<{
name: string;
weight: number;
source: string;
brackish: boolean;
}, "name" | "source">(obj: {
name: string;
weight: number;
source: string;
brackish: boolean;
}, keys: readonly ("name" | "source")[]): Omit<...>
export omit

Omit a list of properties from an object returning a new object with the properties that remain.

@seehttps://radashi.js.org/reference/object/omit

@example

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

@version12.1.0

omit
(
const fish: {
name: string;
weight: number;
source: string;
brackish: boolean;
}
fish
, ['name', 'source']) // => { weight, brackish }