1 var escapeRegExp = require('../string/escapeRegExp'),
2 isObjectLike = require('../internal/isObjectLike');
4 /** `Object#toString` result references. */
5 var funcTag = '[object Function]';
7 /** Used to detect host constructors (Safari > 5). */
8 var reIsHostCtor = /^\[object .+?Constructor\]$/;
10 /** Used for native method references. */
11 var objectProto = Object.prototype;
13 /** Used to resolve the decompiled source of functions. */
14 var fnToString = Function.prototype.toString;
17 * Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
20 var objToString = objectProto.toString;
22 /** Used to detect if a method is native. */
23 var reIsNative = RegExp('^' +
24 escapeRegExp(objToString)
25 .replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
29 * Checks if `value` is a native function.
34 * @param {*} value The value to check.
35 * @returns {boolean} Returns `true` if `value` is a native function, else `false`.
38 * _.isNative(Array.prototype.push);
44 function isNative(value) {
48 if (objToString.call(value) == funcTag) {
49 return reIsNative.test(fnToString.call(value));
51 return isObjectLike(value) && reIsHostCtor.test(value);
54 module.exports = isNative;