just-compact
TypeScript icon, indicating that this package has built-in type declarations

3.2.0 • Public • Published

just-compact

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-compact
yarn add just-compact

Returns a copy of an array with falsey values removed

import compact from 'just-compact';

compact([1, null, 2, undefined, null, NaN, 3, 4, false, 5]); // [1, 2, 3, 4, 5]
compact([1, 2, [], 4, {}]); // [1, 2, [], 4, {}]
compact([]); // []
compact({}); // throws

Package Sidebar

Install

npm i just-compact

Weekly Downloads

614

Version

3.2.0

License

MIT

Unpacked Size

4.94 kB

Total Files

9

Last publish

Collaborators

  • angus-c