arrayify-compact
Similar to Lo-Dash's compact method, but coerces values to arrays first, then returns a flattened array with all falsey values removed. The values false, null, 0, "", undefined, and NaN are all falsey.
Last updated 7 years ago by doowb .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install arrayify-compact 
SYNC missed versions from official npm registry.

arrayify-compact NPM version

Similar to Lo-Dash's compact method, but coerces values to arrays first, then returns a flattened array with all falsey values removed. The values false, null, 0, "", undefined, and NaN are all falsey.

Install

Install with npm:

npm i arrayify-compact --save-dev

Usage

var arrayify = require('arrayify-compact');
console.log(arrayify('a'));
//=> ['a']

console.log(arrayify(['a', 'b', ['c', ['d']]]));
//=> ['a', 'b', 'c', 'd']

console.log(arrayify(['a', 'b', ['c', ['d'], null, false, 0, NaN, '', [], undefined]]));
//=> ['a', 'b', 'c', 'd']

Author

Jon Schlinkert

License

Copyright (c) 2014 Jon Schlinkert, contributors.
Released under the MIT license


This file was generated by verb-cli on July 06, 2014.

Current Tags

  • 0.2.0                                ...           latest (11 years ago)
  • 0.1.1                                ...           patch (7 years ago)

3 Versions

  • 0.1.1                                ...           7 years ago
  • 0.2.0                                ...           11 years ago
  • 0.1.0                                ...           12 years ago
Maintainers (2)
Downloads
Total 7
Today 0
This Week 0
This Month 4
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (3)

© 2010 - cnpmjs.org x YWFE | Home | YWFE