https://github.com/afeiship/next-compact
Returns a copy of the arraywith all falsy values removed.
https://github.com/afeiship/next-compact
array compact false falsy filter next nil
Last synced: 29 days ago
JSON representation
Returns a copy of the arraywith all falsy values removed.
- Host: GitHub
- URL: https://github.com/afeiship/next-compact
- Owner: afeiship
- License: mit
- Created: 2017-09-06T04:07:37.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2021-09-27T05:24:56.000Z (over 4 years ago)
- Last Synced: 2025-10-28T17:48:59.148Z (8 months ago)
- Topics: array, compact, false, falsy, filter, next, nil
- Language: JavaScript
- Homepage:
- Size: 22.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# next-compact
> Returns a copy of the array/object with all falsy values removed.
[![version][version-image]][version-url]
[![license][license-image]][license-url]
[![size][size-image]][size-url]
[![download][download-image]][download-url]
## installation
```bash
npm install -S @jswork/next-compact
```
## usage
```js
import '@jswork/next-compact';
const arr1 = [0, 1, false, 2, '', 3];
const arr2 = [0, 1, false, 2, '', 3, [], [], 'a'];
const result1 = nx.compact(arr);
const result2 = nx.compact(obj);
// [1, 2, 3]
// [1, 2, 3, 'a']
```
## license
Code released under [the MIT license](https://github.com/afeiship/next-compact/blob/master/LICENSE.txt).
[version-image]: https://img.shields.io/npm/v/@jswork/next-compact
[version-url]: https://npmjs.org/package/@jswork/next-compact
[license-image]: https://img.shields.io/npm/l/@jswork/next-compact
[license-url]: https://github.com/afeiship/next-compact/blob/master/LICENSE.txt
[size-image]: https://img.shields.io/bundlephobia/minzip/@jswork/next-compact
[size-url]: https://github.com/afeiship/next-compact/blob/master/dist/next-compact.min.js
[download-image]: https://img.shields.io/npm/dm/@jswork/next-compact
[download-url]: https://www.npmjs.com/package/@jswork/next-compact