contains.js 407 B

12345678910111213
  1. define(['./_isArrayLike', './values', './indexOf'], function (_isArrayLike, values, indexOf) {
  2. // Determine if the array or object contains a given item (using `===`).
  3. function contains(obj, item, fromIndex, guard) {
  4. if (!_isArrayLike(obj)) obj = values(obj);
  5. if (typeof fromIndex != 'number' || guard) fromIndex = 0;
  6. return indexOf(obj, item, fromIndex) >= 0;
  7. }
  8. return contains;
  9. });