SIGN IN SIGN UP

A modern JavaScript utility library delivering modularity, performance, & extras.

0 0 9 JavaScript
2016-09-17 22:24:52 -07:00
define(['./isFunction', './_isMasked', './isObject', './_toSource'], function(isFunction, isMasked, isObject, toSource) {
2016-05-21 00:48:34 -07:00
/**
* Used to match `RegExp`
2016-08-07 21:21:03 -07:00
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
2016-05-21 00:48:34 -07:00
*/
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
/** Used to detect host constructors (Safari). */
var reIsHostCtor = /^\[object .+?Constructor\]$/;
/** Used for built-in method references. */
2016-08-11 23:27:31 -07:00
var funcProto = Function.prototype,
objectProto = Object.prototype;
2016-05-21 00:48:34 -07:00
/** Used to resolve the decompiled source of functions. */
2016-08-11 23:27:31 -07:00
var funcToString = funcProto.toString;
2016-05-21 00:48:34 -07:00
/** 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.*?') + '$'
);
/**
* The base implementation of `_.isNative` without bad shim checks.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a native function,
* else `false`.
*/
function baseIsNative(value) {
if (!isObject(value) || isMasked(value)) {
return false;
}
2016-09-17 22:24:52 -07:00
var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
2016-05-21 00:48:34 -07:00
return pattern.test(toSource(value));
}
return baseIsNative;
});