contains.js 428 B

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