External module "object/compact"
Functions
compact
- compact<T>(object: T, additionalValuesToRemove?: any[]): Partial<T>
-
Type parameters
-
T: Record<string | number | symbol, any>
Parameters
-
object: T
-
Default value additionalValuesToRemove: any[] = []
Returns Partial<T>
Compacted object
Removes
null
andundefined
values and their keys from an objectAdditional values can be removed by passing to an array as the second argument
Example usage:
import { compact } from "@thalesrc/js-utils/object"; const a = { x: null, y: undefined, z: 20 }; compact(a); // {z: 20}
Static usage example:
import "@thalesrc/js-utils/object/static/compact"; const a = { x: null, y: undefined, z: 20 }; Object.compact(a); // {z: 20}