react / wstein / node_modules / jest-cli / node_modules / istanbul / node_modules / js-yaml / node_modules / argparse / node_modules / lodash / lang / isNative.js
80742 viewsvar escapeRegExp = require('../string/escapeRegExp'),1isObjectLike = require('../internal/isObjectLike');23/** `Object#toString` result references. */4var funcTag = '[object Function]';56/** Used to detect host constructors (Safari > 5). */7var reIsHostCtor = /^\[object .+?Constructor\]$/;89/** Used for native method references. */10var objectProto = Object.prototype;1112/** Used to resolve the decompiled source of functions. */13var fnToString = Function.prototype.toString;1415/** Used to check objects for own properties. */16var hasOwnProperty = objectProto.hasOwnProperty;1718/**19* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)20* of values.21*/22var objToString = objectProto.toString;2324/** Used to detect if a method is native. */25var reIsNative = RegExp('^' +26escapeRegExp(fnToString.call(hasOwnProperty))27.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'28);2930/**31* Checks if `value` is a native function.32*33* @static34* @memberOf _35* @category Lang36* @param {*} value The value to check.37* @returns {boolean} Returns `true` if `value` is a native function, else `false`.38* @example39*40* _.isNative(Array.prototype.push);41* // => true42*43* _.isNative(_);44* // => false45*/46function isNative(value) {47if (value == null) {48return false;49}50if (objToString.call(value) == funcTag) {51return reIsNative.test(fnToString.call(value));52}53return isObjectLike(value) && reIsHostCtor.test(value);54}5556module.exports = isNative;575859