Sha256: 45acbde118952bc0b412b9546a93b27af3633bf9721f9017e99242a2bd3a9bd8

Contents?: true

Size: 658 Bytes

Versions: 167

Compression:

Stored size: 658 Bytes

Contents

/**
 * Creates an array with all falsey values removed. The values `false`, `null`,
 * `0`, `""`, `undefined`, and `NaN` are falsey.
 *
 * @static
 * @memberOf _
 * @category Array
 * @param {Array} array The array to compact.
 * @returns {Array} Returns the new array of filtered values.
 * @example
 *
 * _.compact([0, 1, false, 2, '', 3]);
 * // => [1, 2, 3]
 */
function compact(array) {
  var index = -1,
      length = array ? array.length : 0,
      resIndex = -1,
      result = [];

  while (++index < length) {
    var value = array[index];
    if (value) {
      result[++resIndex] = value;
    }
  }
  return result;
}

module.exports = compact;

Version data entries

167 entries across 87 versions & 9 rubygems

Version Path
ilog-0.4.1 node_modules/babel-plugin-proto-to-assign/node_modules/lodash/array/compact.js
ilog-0.4.1 node_modules/contents/node_modules/lodash/array/compact.js
ilog-0.4.1 node_modules/babel/node_modules/lodash/array/compact.js
ilog-0.4.0 node_modules/babel-plugin-proto-to-assign/node_modules/lodash/array/compact.js
ilog-0.4.0 node_modules/contents/node_modules/lodash/array/compact.js
ilog-0.4.0 node_modules/babel/node_modules/lodash/array/compact.js
ilog-0.3.3 node_modules/babel/node_modules/lodash/array/compact.js
ilog-0.3.3 node_modules/babel-plugin-proto-to-assign/node_modules/lodash/array/compact.js
ilog-0.3.3 node_modules/contents/node_modules/lodash/array/compact.js
trusty-festivity-extension-2.6.3 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/array/compact.js
trusty-festivity-extension-2.6.3 node_modules/bower/node_modules/inquirer/node_modules/lodash/array/compact.js
trusty-festivity-extension-2.6.2 node_modules/bower/node_modules/inquirer/node_modules/lodash/array/compact.js
trusty-festivity-extension-2.6.2 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/array/compact.js
trusty-festivity-extension-2.6.1 node_modules/bower/node_modules/inquirer/node_modules/lodash/array/compact.js
trusty-festivity-extension-2.6.1 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/array/compact.js
xcodebuild-helper-1.2.5 externals/ios-sim-master/node_modules/lodash/array/compact.js
trusty-festivity-extension-2.6 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/array/compact.js
trusty-festivity-extension-2.6 node_modules/bower/node_modules/inquirer/node_modules/lodash/array/compact.js
trusty-festivity-extension-2.5.19 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/array/compact.js
trusty-festivity-extension-2.5.19 node_modules/bower/node_modules/inquirer/node_modules/lodash/array/compact.js