isNative.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. var baseIsNative = require('./_baseIsNative'),
  2. isMaskable = require('./_isMaskable');
  3. /**
  4. * Checks if `value` is a pristine native function.
  5. *
  6. * **Note:** This method can't reliably detect native functions in the
  7. * presence of the `core-js` package because `core-js` circumvents this kind
  8. * of detection. Despite multiple requests, the `core-js` maintainer has made
  9. * it clear: any attempt to fix the detection will be obstructed. As a result,
  10. * we're left with little choice but to throw an error. Unfortunately, this
  11. * also affects packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
  12. * which rely on `core-js`.
  13. *
  14. * @static
  15. * @memberOf _
  16. * @since 3.0.0
  17. * @category Lang
  18. * @param {*} value The value to check.
  19. * @returns {boolean} Returns `true` if `value` is a native function,
  20. * else `false`.
  21. * @example
  22. *
  23. * _.isNative(Array.prototype.push);
  24. * // => true
  25. *
  26. * _.isNative(_);
  27. * // => false
  28. */
  29. function isNative(value) {
  30. if (isMaskable(value)) {
  31. throw new Error('This method is not supported with `core-js`. Try https://github.com/es-shims.');
  32. }
  33. return baseIsNative(value);
  34. }
  35. module.exports = isNative;