includes.js 533 B

12345678910111213
  1. var arrayIncludes = require('../array/virtual/includes');
  2. var stringIncludes = require('../string/virtual/includes');
  3. var ArrayPrototype = Array.prototype;
  4. var StringPrototype = String.prototype;
  5. module.exports = function (it) {
  6. var own = it.includes;
  7. if (it === ArrayPrototype || (it instanceof Array && own === ArrayPrototype.includes)) return arrayIncludes;
  8. if (typeof it === 'string' || it === StringPrototype || (it instanceof String && own === StringPrototype.includes)) {
  9. return stringIncludes;
  10. } return own;
  11. };