1 var isFunction = require('./isFunction'),
2 isObjectLike = require('../internal/isObjectLike');
4 /** Used to detect host constructors (Safari > 5). */
5 var reIsHostCtor = /^\[object .+?Constructor\]$/;
7 /** Used for native method references. */
8 var objectProto = Object.prototype;
10 /** Used to resolve the decompiled source of functions. */
11 var fnToString = Function.prototype.toString;
13 /** Used to check objects for own properties. */
14 var hasOwnProperty = objectProto.hasOwnProperty;
16 /** Used to detect if a method is native. */
17 var reIsNative = RegExp('^' +
18 fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g, '\\$&')
19 .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
23 * Checks if `value` is a native function.
28 * @param {*} value The value to check.
29 * @returns {boolean} Returns `true` if `value` is a native function, else `false`.
32 * _.isNative(Array.prototype.push);
38 function isNative(value) {
42 if (isFunction(value)) {
43 return reIsNative.test(fnToString.call(value));
45 return isObjectLike(value) && reIsHostCtor.test(value);
48 module.exports = isNative;