Filters falsy values of the given array
Removes null
and undefined
values and their keys from an object
Example usage:
import { compact } from "@thalesrc/js-utils";
const arr = [undefined, "", false, 0, 1, "1"];
const compacted = compact(arr); // [1, "1"];
const object = {
x: null,
y: undefined,
z: 20
};
const compacted = compact(object); // {z: 20}
Generated using TypeDoc
Compact
Filters falsy values of the given array Removes
null
andundefined
values and their keys from an objectExample usage:
import { compact } from "@thalesrc/js-utils"; const arr = [undefined, "", false, 0, 1, "1"]; const compacted = compact(arr); // [1, "1"]; const object = { x: null, y: undefined, z: 20 }; const compacted = compact(object); // {z: 20}