isNative.js 1.2 KB

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