0.6.1 • Published 1 year ago

@akashalib/without-empty-values v0.6.1

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

@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
0.6.1

1 year ago

0.6.0

1 year ago

0.5.0

1 year ago

0.4.0

1 year ago

0.3.0

1 year ago

0.2.3

1 year ago

0.2.2

1 year ago