1.0.0 • Published 4 years ago

@feizheng/next-compact v1.0.0

Weekly downloads
1
License
MIT
Repository
-
Last release
4 years ago

next-compact

Returns a copy of the array/object with all falsy values removed.

installation

npm install -S @feizheng/next-compact

usage

import '@feizheng/next-compact';

var arr1 = [0, 1, false, 2, '', 3];
var obj = {
  name: 'fei',
  age: 0,
  test: 12,
  ni: null,
  tes2: undefined
};

var result1 = nx.compact(arr);
var result2 = nx.compact(obj);
// [1, 2, 3]
// { name: 'fei', test: 12 }
1.0.0

4 years ago