1 | var isFunction = require('./isFunction'),
|
2 | isMasked = require('./_isMasked'),
|
3 | isObject = require('./isObject'),
|
4 | toSource = require('./_toSource');
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
11 |
|
12 |
|
13 | var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
14 |
|
15 |
|
16 | var funcProto = Function.prototype,
|
17 | objectProto = Object.prototype;
|
18 |
|
19 |
|
20 | var funcToString = funcProto.toString;
|
21 |
|
22 |
|
23 | var hasOwnProperty = objectProto.hasOwnProperty;
|
24 |
|
25 |
|
26 | var reIsNative = RegExp('^' +
|
27 | funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
|
28 | .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
|
29 | );
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
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;
|