Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

_baseIsNative.js 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. var isFunction = require('./isFunction'),
  2. isMasked = require('./_isMasked'),
  3. isObject = require('./isObject'),
  4. toSource = require('./_toSource');
  5. /**
  6. * Used to match `RegExp`
  7. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  8. */
  9. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
  10. /** Used to detect host constructors (Safari). */
  11. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  12. /** Used for built-in method references. */
  13. var funcProto = Function.prototype,
  14. objectProto = Object.prototype;
  15. /** Used to resolve the decompiled source of functions. */
  16. var funcToString = funcProto.toString;
  17. /** Used to check objects for own properties. */
  18. var hasOwnProperty = objectProto.hasOwnProperty;
  19. /** Used to detect if a method is native. */
  20. var reIsNative = RegExp('^' +
  21. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  22. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  23. );
  24. /**
  25. * The base implementation of `_.isNative` without bad shim checks.
  26. *
  27. * @private
  28. * @param {*} value The value to check.
  29. * @returns {boolean} Returns `true` if `value` is a native function,
  30. * else `false`.
  31. */
  32. function baseIsNative(value) {
  33. if (!isObject(value) || isMasked(value)) {
  34. return false;
  35. }
  36. var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
  37. return pattern.test(toSource(value));
  38. }
  39. module.exports = baseIsNative;