Sha256: bce785094893c31352f823105409eb43214fbfe27fd14c52d8608b37d6153d4f

Contents?: true

Size: 1.73 KB

Versions: 274

Compression:

Stored size: 1.73 KB

Contents

var baseIndexOf = require('./_baseIndexOf'),
    isArrayLike = require('./isArrayLike'),
    isString = require('./isString'),
    toInteger = require('./toInteger'),
    values = require('./values');

/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeMax = Math.max;

/**
 * Checks if `value` is in `collection`. If `collection` is a string, it's
 * checked for a substring of `value`, otherwise
 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
 * is used for equality comparisons. If `fromIndex` is negative, it's used as
 * the offset from the end of `collection`.
 *
 * @static
 * @memberOf _
 * @since 0.1.0
 * @category Collection
 * @param {Array|Object|string} collection The collection to inspect.
 * @param {*} value The value to search for.
 * @param {number} [fromIndex=0] The index to search from.
 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
 * @returns {boolean} Returns `true` if `value` is found, else `false`.
 * @example
 *
 * _.includes([1, 2, 3], 1);
 * // => true
 *
 * _.includes([1, 2, 3], 1, 2);
 * // => false
 *
 * _.includes({ 'a': 1, 'b': 2 }, 1);
 * // => true
 *
 * _.includes('abcd', 'bc');
 * // => true
 */
function includes(collection, value, fromIndex, guard) {
  collection = isArrayLike(collection) ? collection : values(collection);
  fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;

  var length = collection.length;
  if (fromIndex < 0) {
    fromIndex = nativeMax(length + fromIndex, 0);
  }
  return isString(collection)
    ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
    : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
}

module.exports = includes;

Version data entries

274 entries across 272 versions & 30 rubygems

Version Path
immosquare-cleaner-0.1.60 node_modules/lodash/includes.js
immosquare-cleaner-0.1.59 node_modules/lodash/includes.js
immosquare-cleaner-0.1.58 node_modules/lodash/includes.js
immosquare-cleaner-0.1.57 node_modules/lodash/includes.js
immosquare-cleaner-0.1.56 node_modules/lodash/includes.js
immosquare-cleaner-0.1.55 node_modules/lodash/includes.js
immosquare-cleaner-0.1.54 node_modules/lodash/includes.js
immosquare-cleaner-0.1.53 node_modules/lodash/includes.js
immosquare-cleaner-0.1.52 node_modules/lodash/includes.js
trusty-cms-6.3.1 node_modules/lodash/includes.js
immosquare-cleaner-0.1.51 node_modules/lodash/includes.js
boring_generators-0.15.0 tmp/templates/app_template/node_modules/lodash/includes.js
clapton-0.0.26 lib/clapton/javascripts/node_modules/lodash/includes.js
clapton-0.0.25 lib/clapton/javascripts/node_modules/lodash/includes.js
immosquare-cleaner-0.1.50 node_modules/lodash/includes.js
clapton-0.0.24 lib/clapton/javascripts/node_modules/lodash/includes.js
clapton-0.0.23 lib/clapton/javascripts/node_modules/lodash/includes.js
clapton-0.0.22 lib/clapton/javascripts/node_modules/lodash/includes.js
clapton-0.0.21 lib/clapton/javascripts/node_modules/lodash/includes.js
clapton-0.0.20 lib/clapton/javascripts/node_modules/lodash/includes.js