UNPKG

3.92 kBJavaScriptView Raw
1'use strict';
2
3var _commonjsHelpers = require('./_commonjsHelpers-72d386ba.js');
4
5/**
6 * Checks if `value` is the
7 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
8 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
9 *
10 * @static
11 * @memberOf _
12 * @since 0.1.0
13 * @category Lang
14 * @param {*} value The value to check.
15 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
16 * @example
17 *
18 * _.isObject({});
19 * // => true
20 *
21 * _.isObject([1, 2, 3]);
22 * // => true
23 *
24 * _.isObject(_.noop);
25 * // => true
26 *
27 * _.isObject(null);
28 * // => false
29 */
30function isObject(value) {
31 var type = typeof value;
32 return value != null && (type == 'object' || type == 'function');
33}
34
35var isObject_1 = isObject;
36
37/** Detect free variable `global` from Node.js. */
38var freeGlobal = typeof _commonjsHelpers.commonjsGlobal == 'object' && _commonjsHelpers.commonjsGlobal && _commonjsHelpers.commonjsGlobal.Object === Object && _commonjsHelpers.commonjsGlobal;
39
40var _freeGlobal = freeGlobal;
41
42/** Detect free variable `self`. */
43var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
44
45/** Used as a reference to the global object. */
46var root = _freeGlobal || freeSelf || Function('return this')();
47
48var _root = root;
49
50/** Built-in value references. */
51var Symbol = _root.Symbol;
52
53var _Symbol = Symbol;
54
55/** Used for built-in method references. */
56var objectProto = Object.prototype;
57
58/** Used to check objects for own properties. */
59var hasOwnProperty = objectProto.hasOwnProperty;
60
61/**
62 * Used to resolve the
63 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
64 * of values.
65 */
66var nativeObjectToString = objectProto.toString;
67
68/** Built-in value references. */
69var symToStringTag = _Symbol ? _Symbol.toStringTag : undefined;
70
71/**
72 * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
73 *
74 * @private
75 * @param {*} value The value to query.
76 * @returns {string} Returns the raw `toStringTag`.
77 */
78function getRawTag(value) {
79 var isOwn = hasOwnProperty.call(value, symToStringTag),
80 tag = value[symToStringTag];
81
82 try {
83 value[symToStringTag] = undefined;
84 var unmasked = true;
85 } catch (e) {}
86
87 var result = nativeObjectToString.call(value);
88 if (unmasked) {
89 if (isOwn) {
90 value[symToStringTag] = tag;
91 } else {
92 delete value[symToStringTag];
93 }
94 }
95 return result;
96}
97
98var _getRawTag = getRawTag;
99
100/** Used for built-in method references. */
101var objectProto$1 = Object.prototype;
102
103/**
104 * Used to resolve the
105 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
106 * of values.
107 */
108var nativeObjectToString$1 = objectProto$1.toString;
109
110/**
111 * Converts `value` to a string using `Object.prototype.toString`.
112 *
113 * @private
114 * @param {*} value The value to convert.
115 * @returns {string} Returns the converted string.
116 */
117function objectToString(value) {
118 return nativeObjectToString$1.call(value);
119}
120
121var _objectToString = objectToString;
122
123/** `Object#toString` result references. */
124var nullTag = '[object Null]',
125 undefinedTag = '[object Undefined]';
126
127/** Built-in value references. */
128var symToStringTag$1 = _Symbol ? _Symbol.toStringTag : undefined;
129
130/**
131 * The base implementation of `getTag` without fallbacks for buggy environments.
132 *
133 * @private
134 * @param {*} value The value to query.
135 * @returns {string} Returns the `toStringTag`.
136 */
137function baseGetTag(value) {
138 if (value == null) {
139 return value === undefined ? undefinedTag : nullTag;
140 }
141 return (symToStringTag$1 && symToStringTag$1 in Object(value))
142 ? _getRawTag(value)
143 : _objectToString(value);
144}
145
146var _baseGetTag = baseGetTag;
147
148exports.baseGetTag = _baseGetTag;
149exports.isObject = isObject_1;
150exports.root = _root;
151//# sourceMappingURL=isObject-ec755c87.js.map