at.js 479 B

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