@carefrees/form-utils-vue-hooks 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/README.md +7 -0
  2. package/esm/hooks/attr/attr.FormItem.d.ts +94 -0
  3. package/esm/hooks/attr/attr.FormItem.js +104 -0
  4. package/esm/hooks/index.d.ts +13 -0
  5. package/esm/hooks/index.js +13 -0
  6. package/esm/hooks/register/register.FormHideItem.d.ts +9 -0
  7. package/esm/hooks/register/register.FormHideItem.js +26 -0
  8. package/esm/hooks/register/register.FormItem.d.ts +24 -0
  9. package/esm/hooks/register/register.FormItem.js +67 -0
  10. package/esm/hooks/register/register.FormList.d.ts +9 -0
  11. package/esm/hooks/register/register.FormList.js +42 -0
  12. package/esm/hooks/register/register.form.d.ts +4 -0
  13. package/esm/hooks/register/register.form.js +10 -0
  14. package/esm/hooks/useAttrs.d.ts +25 -0
  15. package/esm/hooks/useAttrs.js +26 -0
  16. package/esm/hooks/useEffect.d.ts +2 -0
  17. package/esm/hooks/useEffect.js +12 -0
  18. package/esm/hooks/useForm.d.ts +8 -0
  19. package/esm/hooks/useForm.js +21 -0
  20. package/esm/hooks/useFormItem.d.ts +8 -0
  21. package/esm/hooks/useFormItem.js +21 -0
  22. package/esm/hooks/useFormItemParentName.d.ts +18 -0
  23. package/esm/hooks/useFormItemParentName.js +47 -0
  24. package/esm/hooks/useFormList.d.ts +8 -0
  25. package/esm/hooks/useFormList.js +21 -0
  26. package/esm/hooks/useHtmlFor.d.ts +2 -0
  27. package/esm/hooks/useHtmlFor.js +7 -0
  28. package/esm/hooks/useMultipleForm.d.ts +8 -0
  29. package/esm/hooks/useMultipleForm.js +21 -0
  30. package/esm/hooks/useRule.d.ts +4 -0
  31. package/esm/hooks/useRule.js +12 -0
  32. package/esm/index.d.ts +4 -0
  33. package/esm/index.js +4 -0
  34. package/esm/instance/formInstance.d.ts +58 -0
  35. package/esm/instance/formInstance.js +132 -0
  36. package/esm/instance/formItemBaseInstance.d.ts +23 -0
  37. package/esm/instance/formItemBaseInstance.js +6 -0
  38. package/esm/instance/formItemInstance.d.ts +18 -0
  39. package/esm/instance/formItemInstance.js +11 -0
  40. package/esm/instance/formListInstance.d.ts +43 -0
  41. package/esm/instance/formListInstance.js +95 -0
  42. package/esm/instance/index.d.ts +5 -0
  43. package/esm/instance/index.js +5 -0
  44. package/esm/instance/multipleInstance.d.ts +32 -0
  45. package/esm/instance/multipleInstance.js +77 -0
  46. package/esm/instance/ruleIntsnace.d.ts +45 -0
  47. package/esm/instance/ruleIntsnace.js +52 -0
  48. package/esm/interface/index.d.ts +31 -0
  49. package/esm/interface/index.js +0 -0
  50. package/esm/utils/cloneByNamePathList.d.ts +3 -0
  51. package/esm/utils/cloneByNamePathList.js +11 -0
  52. package/esm/utils/get.d.ts +26 -0
  53. package/esm/utils/get.js +13 -0
  54. package/esm/utils/index.d.ts +4 -0
  55. package/esm/utils/index.js +4 -0
  56. package/esm/utils/interface.d.ts +3 -0
  57. package/esm/utils/interface.js +0 -0
  58. package/esm/utils/set.d.ts +32 -0
  59. package/esm/utils/set.js +29 -0
  60. package/esm/utils/utils.d.ts +172 -0
  61. package/esm/utils/utils.js +131 -0
  62. package/lib/hooks/attr/attr.FormItem.d.ts +94 -0
  63. package/lib/hooks/attr/attr.FormItem.js +138 -0
  64. package/lib/hooks/index.d.ts +13 -0
  65. package/lib/hooks/index.js +168 -0
  66. package/lib/hooks/register/register.FormHideItem.d.ts +9 -0
  67. package/lib/hooks/register/register.FormHideItem.js +60 -0
  68. package/lib/hooks/register/register.FormItem.d.ts +24 -0
  69. package/lib/hooks/register/register.FormItem.js +101 -0
  70. package/lib/hooks/register/register.FormList.d.ts +9 -0
  71. package/lib/hooks/register/register.FormList.js +76 -0
  72. package/lib/hooks/register/register.form.d.ts +4 -0
  73. package/lib/hooks/register/register.form.js +44 -0
  74. package/lib/hooks/useAttrs.d.ts +25 -0
  75. package/lib/hooks/useAttrs.js +63 -0
  76. package/lib/hooks/useEffect.d.ts +2 -0
  77. package/lib/hooks/useEffect.js +46 -0
  78. package/lib/hooks/useForm.d.ts +8 -0
  79. package/lib/hooks/useForm.js +61 -0
  80. package/lib/hooks/useFormItem.d.ts +8 -0
  81. package/lib/hooks/useFormItem.js +61 -0
  82. package/lib/hooks/useFormItemParentName.d.ts +18 -0
  83. package/lib/hooks/useFormItemParentName.js +84 -0
  84. package/lib/hooks/useFormList.d.ts +8 -0
  85. package/lib/hooks/useFormList.js +61 -0
  86. package/lib/hooks/useHtmlFor.d.ts +2 -0
  87. package/lib/hooks/useHtmlFor.js +41 -0
  88. package/lib/hooks/useMultipleForm.d.ts +8 -0
  89. package/lib/hooks/useMultipleForm.js +61 -0
  90. package/lib/hooks/useRule.d.ts +4 -0
  91. package/lib/hooks/useRule.js +46 -0
  92. package/lib/index.d.ts +4 -0
  93. package/lib/index.js +87 -0
  94. package/lib/instance/formInstance.d.ts +58 -0
  95. package/lib/instance/formInstance.js +166 -0
  96. package/lib/instance/formItemBaseInstance.d.ts +23 -0
  97. package/lib/instance/formItemBaseInstance.js +40 -0
  98. package/lib/instance/formItemInstance.d.ts +18 -0
  99. package/lib/instance/formItemInstance.js +45 -0
  100. package/lib/instance/formListInstance.d.ts +43 -0
  101. package/lib/instance/formListInstance.js +129 -0
  102. package/lib/instance/index.d.ts +5 -0
  103. package/lib/instance/index.js +96 -0
  104. package/lib/instance/multipleInstance.d.ts +32 -0
  105. package/lib/instance/multipleInstance.js +111 -0
  106. package/lib/instance/ruleIntsnace.d.ts +45 -0
  107. package/lib/instance/ruleIntsnace.js +96 -0
  108. package/lib/interface/index.d.ts +31 -0
  109. package/lib/interface/index.js +18 -0
  110. package/lib/utils/cloneByNamePathList.d.ts +3 -0
  111. package/lib/utils/cloneByNamePathList.js +45 -0
  112. package/lib/utils/get.d.ts +26 -0
  113. package/lib/utils/get.js +47 -0
  114. package/lib/utils/index.d.ts +4 -0
  115. package/lib/utils/index.js +87 -0
  116. package/lib/utils/interface.d.ts +3 -0
  117. package/lib/utils/interface.js +18 -0
  118. package/lib/utils/set.d.ts +32 -0
  119. package/lib/utils/set.js +63 -0
  120. package/lib/utils/utils.d.ts +172 -0
  121. package/lib/utils/utils.js +198 -0
  122. package/package.json +30 -0
  123. package/src/hooks/attr/attr.FormItem.tsx +185 -0
  124. package/src/hooks/index.ts +13 -0
  125. package/src/hooks/register/register.FormHideItem.ts +28 -0
  126. package/src/hooks/register/register.FormItem.ts +93 -0
  127. package/src/hooks/register/register.FormList.ts +49 -0
  128. package/src/hooks/register/register.form.ts +13 -0
  129. package/src/hooks/useAttrs.ts +64 -0
  130. package/src/hooks/useEffect.ts +13 -0
  131. package/src/hooks/useForm.ts +34 -0
  132. package/src/hooks/useFormItem.ts +33 -0
  133. package/src/hooks/useFormItemParentName.ts +49 -0
  134. package/src/hooks/useFormList.ts +33 -0
  135. package/src/hooks/useHtmlFor.ts +9 -0
  136. package/src/hooks/useMultipleForm.ts +30 -0
  137. package/src/hooks/useRule.ts +16 -0
  138. package/src/index.ts +4 -0
  139. package/src/instance/formInstance.ts +220 -0
  140. package/src/instance/formItemBaseInstance.ts +23 -0
  141. package/src/instance/formItemInstance.ts +23 -0
  142. package/src/instance/formListInstance.ts +108 -0
  143. package/src/instance/index.ts +5 -0
  144. package/src/instance/multipleInstance.ts +109 -0
  145. package/src/instance/ruleIntsnace.ts +89 -0
  146. package/src/interface/index.ts +38 -0
  147. package/src/utils/cloneByNamePathList.ts +13 -0
  148. package/src/utils/get.ts +53 -0
  149. package/src/utils/index.ts +4 -0
  150. package/src/utils/interface.ts +4 -0
  151. package/src/utils/set.ts +85 -0
  152. package/src/utils/utils.ts +504 -0
@@ -0,0 +1,85 @@
1
+ /**
2
+ * @description [从lodash中搬了部分需要的代码块](https://www.lodashjs.com/)
3
+ */
4
+
5
+ import { toKey, isObject, castPath, assignValue, isIndex } from './utils';
6
+ import { PropertyPath } from './interface';
7
+
8
+ /**
9
+ * The base implementation of `set`.
10
+ *
11
+ * @private
12
+ * @param {Object} object The object to modify.
13
+ * @param {Array|string} path The path of the property to set.
14
+ * @param {*} value The value to set.
15
+ * @param {Function} [customizer] The function to customize path creation.
16
+ * @returns {Object} Returns `object`.
17
+ */
18
+ function baseSet(object: any, path: PropertyPath, value: any, customizer?: Function) {
19
+ if (!isObject(object)) {
20
+ return object;
21
+ }
22
+ path = castPath(path, object);
23
+
24
+ // 一般都是数组,或者对象进行处理,其他的不进行处理
25
+
26
+ const length = path.length;
27
+ const lastIndex = length - 1;
28
+
29
+ let index = -1;
30
+ let nested = object;
31
+
32
+ while (nested != null && ++index < length) {
33
+ const key = toKey(path[index]);
34
+ let newValue = value;
35
+
36
+ if (index !== lastIndex) {
37
+ const objValue = nested[key];
38
+ newValue = customizer ? customizer(objValue, key, nested) : undefined;
39
+ if (newValue === undefined) {
40
+ // 对数据进行数组还是对象进行判断处理
41
+ if (Array.isArray(objValue)) {
42
+ newValue = [...objValue];
43
+ } else if (objValue !== null && Object.prototype.toString.call(objValue) === '[object Object]') {
44
+ newValue = { ...objValue };
45
+ } else {
46
+ newValue = isObject(objValue) ? objValue : isIndex(path[index + 1]) ? [] : {};
47
+ }
48
+ }
49
+ }
50
+ assignValue(nested, key, newValue);
51
+ nested = nested[key];
52
+ }
53
+ return object;
54
+ }
55
+
56
+ /**
57
+ * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
58
+ * it's created. Arrays are created for missing index properties while objects
59
+ * are created for all other missing properties. Use `setWith` to customize
60
+ * `path` creation.
61
+ *
62
+ * **Note:** This method mutates `object`.
63
+ *
64
+ * @since 3.7.0
65
+ * @category Object
66
+ * @param {Object} object The object to modify.
67
+ * @param {Array|string} path The path of the property to set.
68
+ * @param {*} value The value to set.
69
+ * @returns {Object} Returns `object`.
70
+ * @see has, hasIn, get, unset
71
+ * @example
72
+ *
73
+ * const object = { 'a': [{ 'b': { 'c': 3 } }] }
74
+ *
75
+ * set(object, 'a[0].b.c', 4)
76
+ * console.log(object.a[0].b.c)
77
+ * // => 4
78
+ *
79
+ * set(object, ['x', '0', 'y', 'z'], 5)
80
+ * console.log(object.x[0].y.z)
81
+ * // => 5
82
+ */
83
+ export function set<T = any>(object: T, path: PropertyPath, value: any): T {
84
+ return object == null ? object : baseSet(object, path, value);
85
+ }
@@ -0,0 +1,504 @@
1
+ /**
2
+ * @description [从lodash中搬了部分需要的代码块](https://www.lodashjs.com/)
3
+ */
4
+
5
+ import { PropertyPath } from './interface';
6
+
7
+ const charCodeOfDot = '.'.charCodeAt(0);
8
+ const reEscapeChar = /\\(\\)?/g;
9
+ const rePropName = RegExp(
10
+ // Match anything that isn't a dot or bracket.
11
+ '[^.[\\]]+' +
12
+ '|' +
13
+ // Or match property names within brackets.
14
+ '\\[(?:' +
15
+ // Match a non-string expression.
16
+ '([^"\'][^[]*)' +
17
+ '|' +
18
+ // Or match strings (supports escaping characters).
19
+ '(["\'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2' +
20
+ ')\\]' +
21
+ '|' +
22
+ // Or match "" as the space between consecutive dots or empty brackets.
23
+ '(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))',
24
+ 'g',
25
+ );
26
+
27
+ /**
28
+ * Converts `string` to a property path array.
29
+ *
30
+ * @param {string} string The string to convert.
31
+ * @returns {Array} Returns the property path array.
32
+ */
33
+ export const stringToPath = (string: string) => {
34
+ const result = [];
35
+ if (string.charCodeAt(0) === charCodeOfDot) {
36
+ result.push('');
37
+ }
38
+ // @ts-ignore
39
+ string.replace(rePropName, (match, expression, quote, subString) => {
40
+ let key = match;
41
+ if (quote) {
42
+ key = subString.replace(reEscapeChar, '$1');
43
+ } else if (expression) {
44
+ key = expression.trim();
45
+ }
46
+ result.push(key);
47
+ });
48
+ return result;
49
+ };
50
+
51
+ /**
52
+ * Gets the `toStringTag` of `value`.
53
+ *
54
+ * @private
55
+ * @param {*} value The value to query.
56
+ * @returns {string} Returns the `toStringTag`.
57
+ */
58
+ export function getTag(value: any) {
59
+ const toString = Object.prototype.toString;
60
+ if (value == null) {
61
+ return value === undefined ? '[object Undefined]' : '[object Null]';
62
+ }
63
+ return toString.call(value);
64
+ }
65
+
66
+ /**
67
+ * Checks if `value` is classified as a `Symbol` primitive or object.
68
+ *
69
+ * @since 4.0.0
70
+ * @category Lang
71
+ * @param {*} value The value to check.
72
+ * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
73
+ * @example
74
+ *
75
+ * isSymbol(Symbol.iterator)
76
+ * // => true
77
+ *
78
+ * isSymbol('abc')
79
+ * // => false
80
+ */
81
+ export function isSymbol(value: any) {
82
+ const type = typeof value;
83
+ return type === 'symbol' || (type === 'object' && value != null && getTag(value) === '[object Symbol]');
84
+ }
85
+
86
+ /** Used to match property names within property paths. */
87
+ const reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/;
88
+ const reIsPlainProp = /^\w*$/;
89
+
90
+ /**
91
+ * Checks if `value` is a property name and not a property path.
92
+ *
93
+ * @private
94
+ * @param {*} value The value to check.
95
+ * @param {Object} [object] The object to query keys on.
96
+ * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
97
+ */
98
+ export function isKey(value: any, object: any) {
99
+ if (Array.isArray(value)) {
100
+ return false;
101
+ }
102
+ const type = typeof value;
103
+ if (type === 'number' || type === 'boolean' || value == null || isSymbol(value)) {
104
+ return true;
105
+ }
106
+ return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || (object != null && value in Object(object));
107
+ }
108
+
109
+ /**
110
+ * Casts `value` to a path array if it's not one.
111
+ *
112
+ * @private
113
+ * @param {*} value The value to inspect.
114
+ * @param {Object} [object] The object to query keys on.
115
+ * @returns {Array} Returns the cast property path array.
116
+ */
117
+ export function castPath(value: any, object: any) {
118
+ if (Array.isArray(value)) {
119
+ return value;
120
+ }
121
+ return isKey(value, object) ? [value] : stringToPath(value);
122
+ }
123
+
124
+ /** Used as references for various `Number` constants. */
125
+ const INFINITY = 1 / 0;
126
+
127
+ /**
128
+ * Converts `value` to a string key if it's not a string or symbol.
129
+ *
130
+ * @private
131
+ * @param {*} value The value to inspect.
132
+ * @returns {string|symbol} Returns the key.
133
+ */
134
+ export function toKey(value: any) {
135
+ if (typeof value === 'string' || isSymbol(value)) {
136
+ return value;
137
+ }
138
+ const result = `${value}`;
139
+ return result === '0' && 1 / value === -INFINITY ? '-0' : result;
140
+ }
141
+
142
+ /**
143
+ * Checks if `value` is the
144
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
145
+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
146
+ *
147
+ * @since 0.1.0
148
+ * @category Lang
149
+ * @param {*} value The value to check.
150
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
151
+ * @example
152
+ *
153
+ * isObject({})
154
+ * // => true
155
+ *
156
+ * isObject([1, 2, 3])
157
+ * // => true
158
+ *
159
+ * isObject(Function)
160
+ * // => true
161
+ *
162
+ * isObject(null)
163
+ * // => false
164
+ */
165
+ export function isObject(value: any) {
166
+ const type = typeof value;
167
+ return value != null && (type === 'object' || type === 'function');
168
+ }
169
+
170
+ /** Used as references for various `Number` constants. */
171
+ const MAX_SAFE_INTEGER = 9007199254740991;
172
+
173
+ /** Used to detect unsigned integer values. */
174
+ const reIsUint = /^(?:0|[1-9]\d*)$/;
175
+
176
+ /**
177
+ * Checks if `value` is a valid array-like index.
178
+ *
179
+ * @private
180
+ * @param {*} value The value to check.
181
+ * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
182
+ * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
183
+ */
184
+ export function isIndex(value: any, length?: number) {
185
+ const type = typeof value;
186
+ length = length == null ? MAX_SAFE_INTEGER : length;
187
+
188
+ return (
189
+ !!length &&
190
+ (type === 'number' || (type !== 'symbol' && reIsUint.test(value))) &&
191
+ value > -1 &&
192
+ value % 1 === 0 &&
193
+ value < length
194
+ );
195
+ }
196
+
197
+ /**
198
+ * The base implementation of `assignValue` and `assignMergeValue` without
199
+ * value checks.
200
+ *
201
+ * @private
202
+ * @param {Object} object The object to modify.
203
+ * @param {string} key The key of the property to assign.
204
+ * @param {*} value The value to assign.
205
+ */
206
+ export function baseAssignValue(object: any, key: any, value: any) {
207
+ if (key === '__proto__') {
208
+ Object.defineProperty(object, key, {
209
+ configurable: true,
210
+ enumerable: true,
211
+ value: value,
212
+ writable: true,
213
+ });
214
+ } else {
215
+ object[key] = value;
216
+ }
217
+ }
218
+
219
+ /**
220
+ * Performs a
221
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
222
+ * comparison between two values to determine if they are equivalent.
223
+ *
224
+ * @since 4.0.0
225
+ * @category Lang
226
+ * @param {*} value The value to compare.
227
+ * @param {*} other The other value to compare.
228
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
229
+ * @example
230
+ *
231
+ * const object = { 'a': 1 }
232
+ * const other = { 'a': 1 }
233
+ *
234
+ * eq(object, object)
235
+ * // => true
236
+ *
237
+ * eq(object, other)
238
+ * // => false
239
+ *
240
+ * eq('a', 'a')
241
+ * // => true
242
+ *
243
+ * eq('a', Object('a'))
244
+ * // => false
245
+ *
246
+ * eq(NaN, NaN)
247
+ * // => true
248
+ */
249
+ export function eq(value: any, other: any) {
250
+ return value === other || (value !== value && other !== other);
251
+ }
252
+
253
+ /** Used to check objects for own properties. */
254
+ const hasOwnProperty = Object.prototype.hasOwnProperty;
255
+
256
+ /**
257
+ * Assigns `value` to `key` of `object` if the existing value is not equivalent.
258
+ *
259
+ * @private
260
+ * @param {Object} object The object to modify.
261
+ * @param {string} key The key of the property to assign.
262
+ * @param {*} value The value to assign.
263
+ */
264
+ export function assignValue(object: any, key: any, value: any) {
265
+ const objValue = object[key];
266
+
267
+ if (!(hasOwnProperty.call(object, key) && eq(objValue, value))) {
268
+ if (value !== 0 || 1 / value === 1 / objValue) {
269
+ baseAssignValue(object, key, value);
270
+ }
271
+ } else if (value === undefined && !(key in object)) {
272
+ baseAssignValue(object, key, value);
273
+ }
274
+ }
275
+
276
+ /**
277
+ * The base implementation of `_.has` without support for deep paths.
278
+ *
279
+ * @private
280
+ * @param {Object} [object] The object to query.
281
+ * @param {Array|string} key The key to check.
282
+ * @returns {boolean} Returns `true` if `key` exists, else `false`.
283
+ */
284
+ function baseHas<T = any>(object: T, key: string | number) {
285
+ return object != null && hasOwnProperty.call(object, key);
286
+ }
287
+
288
+ /**
289
+ * Checks if `value` is a valid array-like length.
290
+ *
291
+ * **Note:** This method is loosely based on
292
+ * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
293
+ *
294
+ * @static
295
+ * @memberOf _
296
+ * @since 4.0.0
297
+ * @category Lang
298
+ * @param {*} value The value to check.
299
+ * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
300
+ * @example
301
+ *
302
+ * _.isLength(3);
303
+ * // => true
304
+ *
305
+ * _.isLength(Number.MIN_VALUE);
306
+ * // => false
307
+ *
308
+ * _.isLength(Infinity);
309
+ * // => false
310
+ *
311
+ * _.isLength('3');
312
+ * // => false
313
+ */
314
+ function isLength<T = any>(value: T) {
315
+ return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
316
+ }
317
+
318
+ function isObjectLike<T = any>(value: T) {
319
+ return value != null && typeof value == 'object';
320
+ }
321
+
322
+ /** Used for built-in method references. */
323
+ var objectProto = Object.prototype;
324
+
325
+ /**
326
+ * Used to resolve the
327
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
328
+ * of values.
329
+ */
330
+ var nativeObjectToString = objectProto.toString;
331
+
332
+ /** Built-in value references. */
333
+ var symToStringTag: any = Symbol ? Symbol.toStringTag : undefined;
334
+
335
+ /**
336
+ * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
337
+ *
338
+ * @private
339
+ * @param {*} value The value to query.
340
+ * @returns {string} Returns the raw `toStringTag`.
341
+ */
342
+ function getRawTag(value: any) {
343
+ var isOwn = hasOwnProperty.call(value, symToStringTag),
344
+ tag = value[symToStringTag];
345
+
346
+ try {
347
+ value[symToStringTag] = undefined;
348
+ var unmasked = true;
349
+ } catch (e) {}
350
+
351
+ var result = nativeObjectToString.call(value);
352
+ // @ts-ignore
353
+ if (unmasked) {
354
+ if (isOwn) {
355
+ value[symToStringTag] = tag;
356
+ } else {
357
+ delete value[symToStringTag];
358
+ }
359
+ }
360
+ return result;
361
+ }
362
+ /**
363
+ * Used to resolve the
364
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
365
+ * of values.
366
+ */
367
+ var nativeObjectToString = objectProto.toString;
368
+
369
+ /**
370
+ * Converts `value` to a string using `Object.prototype.toString`.
371
+ *
372
+ * @private
373
+ * @param {*} value The value to convert.
374
+ * @returns {string} Returns the converted string.
375
+ */
376
+ function objectToString(value: any) {
377
+ return nativeObjectToString.call(value);
378
+ }
379
+
380
+ /** `Object#toString` result references. */
381
+ var nullTag = '[object Null]',
382
+ undefinedTag = '[object Undefined]';
383
+
384
+ /**
385
+ * The base implementation of `getTag` without fallbacks for buggy environments.
386
+ *
387
+ * @private
388
+ * @param {*} value The value to query.
389
+ * @returns {string} Returns the `toStringTag`.
390
+ */
391
+ function baseGetTag(value: any) {
392
+ if (value == null) {
393
+ return value === undefined ? undefinedTag : nullTag;
394
+ }
395
+ return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
396
+ }
397
+
398
+ /** `Object#toString` result references. */
399
+ var argsTag = '[object Arguments]';
400
+
401
+ /**
402
+ * The base implementation of `_.isArguments`.
403
+ *
404
+ * @private
405
+ * @param {*} value The value to check.
406
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
407
+ */
408
+ function baseIsArguments(value: any) {
409
+ return isObjectLike(value) && baseGetTag(value) == argsTag;
410
+ }
411
+
412
+ /** Built-in value references. */
413
+ const propertyIsEnumerable = objectProto.propertyIsEnumerable;
414
+
415
+ /**
416
+ * Checks if `value` is likely an `arguments` object.
417
+ *
418
+ * @static
419
+ * @memberOf _
420
+ * @since 0.1.0
421
+ * @category Lang
422
+ * @param {*} value The value to check.
423
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
424
+ * else `false`.
425
+ * @example
426
+ *
427
+ * _.isArguments(function() { return arguments; }());
428
+ * // => true
429
+ *
430
+ * _.isArguments([1, 2, 3]);
431
+ * // => false
432
+ */
433
+ var isArguments = baseIsArguments(
434
+ (function () {
435
+ return arguments;
436
+ })(),
437
+ )
438
+ ? baseIsArguments
439
+ : function (value: any) {
440
+ return isObjectLike(value) && hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee');
441
+ };
442
+ /**
443
+ * Checks if `path` exists on `object`.
444
+ *
445
+ * @private
446
+ * @param {Object} object The object to query.
447
+ * @param {Array|string} path The path to check.
448
+ * @param {Function} hasFunc The function to check properties.
449
+ * @returns {boolean} Returns `true` if `path` exists, else `false`.
450
+ */
451
+ function hasPath<T = any>(object: T, path: PropertyPath, hasFunc: (obj: any, key: string | number) => boolean) {
452
+ path = castPath(path, object);
453
+
454
+ var index = -1,
455
+ length = path.length,
456
+ result = false;
457
+
458
+ while (++index < length) {
459
+ var key = toKey(path[index]);
460
+ if (!(result = object != null && hasFunc(object, key))) {
461
+ break;
462
+ }
463
+ // @ts-ignore
464
+ object = object[key];
465
+ }
466
+ if (result || ++index != length) {
467
+ return result;
468
+ }
469
+ // @ts-ignore
470
+ length = object == null ? 0 : object.length;
471
+
472
+ return !!length && isLength(length) && isIndex(key, length) && (Array.isArray(object) || isArguments(object));
473
+ }
474
+
475
+ /**
476
+ * Checks if `path` is a direct property of `object`.
477
+ *
478
+ * @static
479
+ * @since 0.1.0
480
+ * @memberOf _
481
+ * @category Object
482
+ * @param {Object} object The object to query.
483
+ * @param {Array|string} path The path to check.
484
+ * @returns {boolean} Returns `true` if `path` exists, else `false`.
485
+ * @example
486
+ *
487
+ * var object = { 'a': { 'b': 2 } };
488
+ * var other = _.create({ 'a': _.create({ 'b': 2 }) });
489
+ *
490
+ * _.has(object, 'a');
491
+ * // => true
492
+ *
493
+ * _.has(object, 'a.b');
494
+ * // => true
495
+ *
496
+ * _.has(object, ['a', 'b']);
497
+ * // => true
498
+ *
499
+ * _.has(other, 'a');
500
+ * // => false
501
+ */
502
+ export function has<T = any>(object: T, path: PropertyPath) {
503
+ return object != null && hasPath(object, path, baseHas);
504
+ }