These functions provide convenient ways to exclude specific properties, undefined values, or null values from an object. They are built on top of the merge function.
Creates a new object that includes all properties of obj except the specified keys. This is a shallow operation.
import { omit } from '@jsopen/objects';
const original = { a: 1, b: 2, c: 3 };
const result = omit(original, ['b', 'c']);
// result is { a: 1 }Creates a new object by excluding all properties that have undefined as their value.
deep: false(default): Only top-levelundefinedvalues are removed.deep: true: Recursively removesundefinedvalues from plain objects and arrays.deep: 'full': Recursively removesundefinedvalues from all objects including class instances.
import { omitUndefined } from '@jsopen/objects';
const original = { a: 1, b: undefined, c: { d: undefined } };
const result = omitUndefined(original, true);
// result is { a: 1, c: {} }Creates a new object by excluding all properties that have null as their value.
deep: false(default): Only top-levelnullvalues are removed.deep: true: Recursively removesnullvalues from plain objects and arrays.deep: 'full': Recursively removesnullvalues from all objects including class instances.
import { omitNull } from '@jsopen/objects';
const original = { a: 1, b: null, c: { d: null } };
const result = omitNull(original, true);
// result is { a: 1, c: {} }Creates a new object by excluding all properties that have either null or undefined as their value.
deep: false(default): Only top-level nullish values are removed.deep: true: Recursively removes nullish values from plain objects and arrays.deep: 'full': Recursively removes nullish values from all objects including class instances.
import { omitNullish } from '@jsopen/objects';
const original = { a: 1, b: null, c: undefined, d: { e: null } };
const result = omitNullish(original, true);
// result is { a: 1, d: {} }These functions use standard merge options internally. omitUndefined, omitNull, and omitNullish preserve property descriptors by default (copyDescriptors: true).