Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

just-compact

angus-c6.7kMIT3.2.0TypeScript support: included

returns a copy of an array with falsey values removed

array, compact, falsey, no-dependencies, just

readme

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

changelog

just-compact

3.2.0

Minor Changes

  • Rename node module .js -> .cjs

3.1.1

Patch Changes

  • fix: reorder exports to set default last #488

3.1.0

Minor Changes

  • package.json updates to fix #467 and #483