https://github.com/nju33/nullpo
Remove falsey values from array and object
https://github.com/nju33/nullpo
array compact object
Last synced: about 1 year ago
JSON representation
Remove falsey values from array and object
- Host: GitHub
- URL: https://github.com/nju33/nullpo
- Owner: nju33
- Created: 2017-04-02T15:39:25.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2018-03-09T08:51:58.000Z (over 8 years ago)
- Last Synced: 2024-04-26T15:43:05.769Z (about 2 years ago)
- Topics: array, compact, object
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/nullpo
- Size: 92.8 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# nullpo
Remove falsey values from array and object

[](https://circleci.com/gh/nju33/nullpo)
[](https://coveralls.io/github/nju33/nullpo?branch=master)
[](https://github.com/sindresorhus/xo)
[](https://opensource.org/licenses/MIT)
[](https://github.com/prettier/prettier)
[](https://github.com/ellerbrock/typescript-badges/)
## Install
```bash
yarn add [-D] nullpo
```
## Usage
```js
import nullpo from 'nullpo';
nullpo(['foo', null, '', 123, false, () => {}]);
// [ 'foo', 123, [Function] ]
nullpo({
foo: 'foo',
null: null,
empty: '',
number: 123,
boolean: false,
function() {}
});
// {
// foo: 'foo',
// number: 123,
// function: [Function: function]
// }
nullpo('foo'); // 'foo'
nullpo(123); // 123
```
## API
```ts
export type NullpoArray = any[];
export type NullpoObject = {[k: string]: any};
declare function nullpo(args: NullpoArray): NullpoArray;
declare function nullpo(args: NullpoObject): NullpoObject;
declare function nullpo(args: any): any;
```
## Lisence
The MIT License (MIT)
Copyright (c) 2017 nju33