@akashalib/without-empty-values
v0.6.1
Published
Helper function to return undefined instead of null, empty string, empty array or object with empty values. It also emits undefined elements from an array and does all these things recursively.
Downloads
14
Readme
@akashalib/without-empty-values
Helper function to return undefined instead of null, empty string, empty array or object with empty values. It also emits undefined elements from an array and does all these things recursively.
Install
npm install @akashalib/without-empty-values
# OR
yarn add @akashalib/without-empty-values
Usage
import { withoutEmptyValues } from "@akashalib/without-empty-values";
console.log(withoutEmptyValues(undefined)); // undefined
console.log(withoutEmptyValues(null)); // undefined
console.log(withoutEmptyValues("")); // undefined
console.log(withoutEmptyValues({})); // undefined
console.log(withoutEmptyValues([])); // undefined
console.log(withoutEmptyValues([1, null, "a", ""])); // [1, "a"]
console.log(
withoutEmptyValues({
a: null,
b: "",
c: { ca: [null, 1, "", undefined] },
d: []
})
); // {c: { ca: [1]} }
console.log(
withoutEmptyValues({
a: null,
b: "",
c: { ca: [null, "", undefined] },
d: []
})
); // undefined