includes.js 623 B

1234567891011121314
  1. var isPrototypeOf = require('../../internals/object-is-prototype-of');
  2. var arrayMethod = require('../array/virtual/includes');
  3. var stringMethod = require('../string/virtual/includes');
  4. var ArrayPrototype = Array.prototype;
  5. var StringPrototype = String.prototype;
  6. module.exports = function (it) {
  7. var own = it.includes;
  8. if (it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.includes)) return arrayMethod;
  9. if (typeof it == 'string' || it === StringPrototype || (isPrototypeOf(StringPrototype, it) && own === StringPrototype.includes)) {
  10. return stringMethod;
  11. } return own;
  12. };