nullpo

Remove falsey values from array and object


Keywords
compact, array, object
License
MIT
Install
npm install nullpo@0.0.1

Documentation

nullpo

Remove falsey values from array and object

npm: nullpo CircleCI Coverage Status XO code style License: MIT code style: prettier TypeScript

Install

yarn add [-D] nullpo

Usage

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

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 nju33.ki@gmail.com