just-flush

returns a copy of an array or object with null/undefined members removed

Usage no npm install needed!

<script type="module">
  import justFlush from 'https://cdn.skypack.dev/just-flush';
</script>

README

just-flush

Part of a library of zero-dependency npm modules that do just do one thing. Guilt-free utilities for every occasion.

🍦 Try it

npm install just-flush
yarn add just-flush

Returns a copy of an array or object with null/undefined members removed

import flush from 'just-flush';

flush([1, undefined, 2, null, 3, NaN, 0]); // [1, 2, 3, NaN, 0]
flush([true, null, false, true, [null], undefined]); // [true, false, true, [null]]
flush({a: 2, b: null, c: 4, d: undefined}); // {a: 2, c: 4}
flush('something'); // undefined
flush(); // undefined