Projekt

Obecné

Profil

Stáhnout (1.38 KB) Statistiky
| Větev: | Revize:
1
var isFunction = require('./isFunction'),
2
    isMasked = require('./_isMasked'),
3
    isObject = require('./isObject'),
4
    toSource = require('./_toSource');
5

    
6
/**
7
 * Used to match `RegExp`
8
 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
9
 */
10
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
11

    
12
/** Used to detect host constructors (Safari). */
13
var reIsHostCtor = /^\[object .+?Constructor\]$/;
14

    
15
/** Used for built-in method references. */
16
var funcProto = Function.prototype,
17
    objectProto = Object.prototype;
18

    
19
/** Used to resolve the decompiled source of functions. */
20
var funcToString = funcProto.toString;
21

    
22
/** Used to check objects for own properties. */
23
var hasOwnProperty = objectProto.hasOwnProperty;
24

    
25
/** Used to detect if a method is native. */
26
var reIsNative = RegExp('^' +
27
  funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
28
  .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
29
);
30

    
31
/**
32
 * The base implementation of `_.isNative` without bad shim checks.
33
 *
34
 * @private
35
 * @param {*} value The value to check.
36
 * @returns {boolean} Returns `true` if `value` is a native function,
37
 *  else `false`.
38
 */
39
function baseIsNative(value) {
40
  if (!isObject(value) || isMasked(value)) {
41
    return false;
42
  }
43
  var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
44
  return pattern.test(toSource(value));
45
}
46

    
47
module.exports = baseIsNative;
(79-79/571)