mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 09:47:48 +00:00
Bump to v4.13.0.
This commit is contained in:
43
isNative.js
43
isNative.js
@@ -1,31 +1,15 @@
|
||||
define(['./isFunction', './_isHostObject', './isObject', './_toSource'], function(isFunction, isHostObject, isObject, toSource) {
|
||||
define(['./_baseIsNative', './_isMaskable'], function(baseIsNative, isMaskable) {
|
||||
|
||||
/**
|
||||
* Used to match `RegExp`
|
||||
* [syntax characters](http://ecma-international.org/ecma-262/6.0/#sec-patterns).
|
||||
*/
|
||||
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
||||
|
||||
/** Used to detect host constructors (Safari). */
|
||||
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var objectProto = Object.prototype;
|
||||
|
||||
/** Used to resolve the decompiled source of functions. */
|
||||
var funcToString = Function.prototype.toString;
|
||||
|
||||
/** Used to check objects for own properties. */
|
||||
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||
|
||||
/** Used to detect if a method is native. */
|
||||
var reIsNative = RegExp('^' +
|
||||
funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
|
||||
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
|
||||
);
|
||||
|
||||
/**
|
||||
* Checks if `value` is a native function.
|
||||
* Checks if `value` is a pristine native function.
|
||||
*
|
||||
* **Note:** This method can't reliably detect native functions in the
|
||||
* presence of the `core-js` package because `core-js` circumvents this kind
|
||||
* of detection. Despite multiple requests, the `core-js` maintainer has made
|
||||
* it clear: any attempt to fix the detection will be obstructed. As a result,
|
||||
* we're left with little choice but to throw an error. Unfortunately, this
|
||||
* also affects packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
|
||||
* which rely on `core-js`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
@@ -43,11 +27,10 @@ define(['./isFunction', './_isHostObject', './isObject', './_toSource'], functio
|
||||
* // => false
|
||||
*/
|
||||
function isNative(value) {
|
||||
if (!isObject(value)) {
|
||||
return false;
|
||||
if (isMaskable(value)) {
|
||||
throw new Error('This method is not supported with `core-js`. Try https://github.com/es-shims.');
|
||||
}
|
||||
var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
|
||||
return pattern.test(toSource(value));
|
||||
return baseIsNative(value);
|
||||
}
|
||||
|
||||
return isNative;
|
||||
|
||||
Reference in New Issue
Block a user