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 6 years ago by doowb .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install arrayify-compact 
SYNC missed versions from official npm registry.

arrayify-compact NPM version

Casts the given value to a flatten array, and removes falsey items (similar to lodash compact).

Install

Install with npm

$ npm i arrayify-compact --save

Install with bower

$ bower install arrayify-compact --save

Usage

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

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

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

Related

Other utils for working with arrays.

  • arr-flatten: Recursively flatten an array or arrays. This is the fastest implementation of array flatten.
  • arr-reduce: Fast array reduce that also loops over sparse elements.
  • arr-pluck: Retrieves the value of a specified property from all elements in the collection.
  • arr-map: Faster, node.js focused alternative to JavaScript's native array map.
  • arr-union: Combines a list of arrays, returning a single array with unique values, using strict equality… more
  • array-unique: Return an array free of duplicate values. Fastest ES5 implementation.
  • utils: Fast, generic JavaScript/node.js utility functions.

Running tests

Install dev dependencies:

$ npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue

Author

Jon Schlinkert

License

Copyright © 2015 Jon Schlinkert Released under the MIT license.


This file was generated by verb-cli on June 19, 2015.

Current Tags

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

3 Versions

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

Copyright 2013 - present © cnpmjs.org | Home |