at.js 607 B

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