ut2 1.3.1 → 1.4.0
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.
- package/README.md +2 -4
- package/dist/ut2.js +124 -69
- package/dist/ut2.js.map +1 -1
- package/dist/ut2.min.js +1 -1
- package/dist/ut2.min.js.map +1 -1
- package/es/index.js +1 -0
- package/es/internals/checkType.js +11 -0
- package/es/internals/compare.js +8 -26
- package/es/internals/helpers.js +5 -6
- package/es/internals/native.js +10 -1
- package/es/isArguments.js +4 -4
- package/es/isArrayBuffer.js +3 -3
- package/es/isBlob.js +3 -3
- package/es/isBoolean.js +3 -2
- package/es/isDataView.js +3 -2
- package/es/isDate.js +3 -3
- package/es/isEqual.js +12 -10
- package/es/isError.js +3 -5
- package/es/isFunction.js +3 -2
- package/es/isMap.js +3 -3
- package/es/isMatch.js +71 -0
- package/es/isNumber.js +3 -3
- package/es/isPlainObject.js +3 -3
- package/es/isRegExp.js +3 -3
- package/es/isSet.js +3 -3
- package/es/isString.js +3 -3
- package/es/isSymbol.js +3 -3
- package/es/isTypedArray.js +3 -2
- package/es/isWeakMap.js +3 -3
- package/es/isWeakSet.js +3 -3
- package/lib/index.js +2 -0
- package/lib/internals/checkType.js +14 -0
- package/lib/internals/compare.js +8 -26
- package/lib/internals/helpers.js +3 -4
- package/lib/internals/native.js +9 -0
- package/lib/isArguments.js +2 -2
- package/lib/isArrayBuffer.js +3 -3
- package/lib/isBlob.js +2 -2
- package/lib/isBoolean.js +3 -2
- package/lib/isDataView.js +3 -2
- package/lib/isDate.js +3 -3
- package/lib/isEqual.js +12 -10
- package/lib/isError.js +3 -5
- package/lib/isFunction.js +3 -2
- package/lib/isMap.js +3 -3
- package/lib/isMatch.js +73 -0
- package/lib/isNumber.js +3 -3
- package/lib/isPlainObject.js +2 -2
- package/lib/isRegExp.js +3 -3
- package/lib/isSet.js +3 -3
- package/lib/isString.js +3 -3
- package/lib/isSymbol.js +3 -3
- package/lib/isTypedArray.js +3 -2
- package/lib/isWeakMap.js +3 -3
- package/lib/isWeakSet.js +3 -3
- package/package.json +1 -1
- package/types/index.d.ts +1 -0
- package/types/internals/checkType.d.ts +2 -0
- package/types/internals/native.d.ts +6 -0
- package/types/isBuffer.d.ts +1 -1
- package/types/isMatch.d.ts +44 -0
- package/es/internals/isType.js +0 -11
- package/lib/internals/isType.js +0 -13
- package/types/internals/isType.d.ts +0 -11
package/lib/isArrayBuffer.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var checkType = require('./internals/checkType.js');
|
|
4
|
+
var native = require('./internals/native.js');
|
|
4
5
|
var nodeUtil = require('./internals/nodeUtil.js');
|
|
5
|
-
var isObjectLike = require('./isObjectLike.js');
|
|
6
6
|
|
|
7
7
|
function isArrayBuffer(value) {
|
|
8
|
-
return nodeUtil.nodeIsArrayBuffer ? nodeUtil.nodeIsArrayBuffer(value) :
|
|
8
|
+
return nodeUtil.nodeIsArrayBuffer ? nodeUtil.nodeIsArrayBuffer(value) : checkType.checkType(value, native.arrayBufferTag);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
module.exports = isArrayBuffer;
|
package/lib/isBlob.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var checkType = require('./internals/checkType.js');
|
|
4
4
|
var native = require('./internals/native.js');
|
|
5
5
|
|
|
6
6
|
function isBlob(value) {
|
|
7
|
-
return (native.blobExisted && value instanceof Blob) ||
|
|
7
|
+
return (native.blobExisted && value instanceof Blob) || checkType.checkTypes(value, [native.blobTag, native.fileTag]);
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
module.exports = isBlob;
|
package/lib/isBoolean.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var checkType = require('./internals/checkType.js');
|
|
4
|
+
var native = require('./internals/native.js');
|
|
4
5
|
|
|
5
6
|
function isBoolean(value) {
|
|
6
|
-
return value === true || value === false ||
|
|
7
|
+
return value === true || value === false || checkType.checkType(value, native.booleanTag);
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
module.exports = isBoolean;
|
package/lib/isDataView.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var checkType = require('./internals/checkType.js');
|
|
4
|
+
var native = require('./internals/native.js');
|
|
4
5
|
|
|
5
6
|
function isDataView(value) {
|
|
6
|
-
return
|
|
7
|
+
return checkType.checkType(value, native.dataViewTag);
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
module.exports = isDataView;
|
package/lib/isDate.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var checkType = require('./internals/checkType.js');
|
|
4
|
+
var native = require('./internals/native.js');
|
|
4
5
|
var nodeUtil = require('./internals/nodeUtil.js');
|
|
5
|
-
var isObjectLike = require('./isObjectLike.js');
|
|
6
6
|
|
|
7
7
|
function isDate(value) {
|
|
8
|
-
return nodeUtil.nodeIsDate ? nodeUtil.nodeIsDate(value) :
|
|
8
|
+
return nodeUtil.nodeIsDate ? nodeUtil.nodeIsDate(value) : checkType.checkType(value, native.dateTag);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
module.exports = isDate;
|
package/lib/isEqual.js
CHANGED
|
@@ -124,13 +124,14 @@ function isEqualDeep(value, other, customizer, strictCheck, valueStack, otherSta
|
|
|
124
124
|
if (hasCustomizer) {
|
|
125
125
|
var compared = customizer(value[length], other[length], length, value, other, valueStack, otherStack);
|
|
126
126
|
if (compared !== undefined) {
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
if (!compared) {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
continue;
|
|
129
131
|
}
|
|
130
132
|
}
|
|
131
133
|
if (!isEqualDeep(value[length], other[length], customizer, strictCheck, valueStack, otherStack)) {
|
|
132
|
-
|
|
133
|
-
break;
|
|
134
|
+
return false;
|
|
134
135
|
}
|
|
135
136
|
}
|
|
136
137
|
}
|
|
@@ -146,23 +147,24 @@ function isEqualDeep(value, other, customizer, strictCheck, valueStack, otherSta
|
|
|
146
147
|
if (hasCustomizer) {
|
|
147
148
|
var compared = customizer(value[key], other[key], key, value, other, valueStack, otherStack);
|
|
148
149
|
if (compared !== undefined) {
|
|
149
|
-
|
|
150
|
-
|
|
150
|
+
if (!compared) {
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
continue;
|
|
151
154
|
}
|
|
152
155
|
}
|
|
153
156
|
if (!(native.hasOwnProperty.call(other, key) && isEqualDeep(value[key], other[key], customizer, strictCheck, valueStack, otherStack))) {
|
|
154
|
-
|
|
155
|
-
break;
|
|
157
|
+
return false;
|
|
156
158
|
}
|
|
157
159
|
if (!skipCtor && key === 'constructor') {
|
|
158
160
|
skipCtor = true;
|
|
159
161
|
}
|
|
160
162
|
}
|
|
161
|
-
if (
|
|
163
|
+
if (!skipCtor) {
|
|
162
164
|
var valCtor = value.constructor;
|
|
163
165
|
var othCtor = other.constructor;
|
|
164
166
|
if (valCtor !== othCtor && !(isFunction(valCtor) && valCtor instanceof valCtor && isFunction(othCtor) && othCtor instanceof othCtor) && 'constructor' in value && 'constructor' in other) {
|
|
165
|
-
|
|
167
|
+
return false;
|
|
166
168
|
}
|
|
167
169
|
}
|
|
168
170
|
}
|
package/lib/isError.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var checkType = require('./internals/checkType.js');
|
|
4
|
+
var native = require('./internals/native.js');
|
|
4
5
|
var isObjectLike = require('./isObjectLike.js');
|
|
5
6
|
|
|
6
7
|
function isError(value) {
|
|
7
|
-
|
|
8
|
-
return false;
|
|
9
|
-
}
|
|
10
|
-
return value instanceof Error || isType(value, ['Error', 'DOMException']);
|
|
8
|
+
return isObjectLike(value) && (value instanceof Error || checkType.checkTypes(value, [native.errorTag, native.domExceptionTag]));
|
|
11
9
|
}
|
|
12
10
|
|
|
13
11
|
module.exports = isError;
|
package/lib/isFunction.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var checkType = require('./internals/checkType.js');
|
|
4
|
+
var native = require('./internals/native.js');
|
|
4
5
|
var isObject = require('./isObject.js');
|
|
5
6
|
|
|
6
7
|
function isFunction(value) {
|
|
7
8
|
if (!isObject(value)) {
|
|
8
9
|
return false;
|
|
9
10
|
}
|
|
10
|
-
return
|
|
11
|
+
return checkType.checkTypes(value, native.functionTags);
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
module.exports = isFunction;
|
package/lib/isMap.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var checkType = require('./internals/checkType.js');
|
|
4
|
+
var native = require('./internals/native.js');
|
|
4
5
|
var nodeUtil = require('./internals/nodeUtil.js');
|
|
5
|
-
var isObjectLike = require('./isObjectLike.js');
|
|
6
6
|
|
|
7
7
|
function isMap(value) {
|
|
8
|
-
return nodeUtil.nodeIsMap ? nodeUtil.nodeIsMap(value) :
|
|
8
|
+
return nodeUtil.nodeIsMap ? nodeUtil.nodeIsMap(value) : checkType.checkType(value, native.mapTag);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
module.exports = isMap;
|
package/lib/isMatch.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var allKeys = require('./allKeys.js');
|
|
4
|
+
var checkType = require('./internals/checkType.js');
|
|
5
|
+
var native = require('./internals/native.js');
|
|
6
|
+
var isEqual = require('./isEqual.js');
|
|
7
|
+
|
|
8
|
+
function isDeepComparable(object, source) {
|
|
9
|
+
return checkType.checkType(object, native.objectTag) && checkType.checkType(source, native.objectTag);
|
|
10
|
+
}
|
|
11
|
+
function baseIsMatch(object, source, customizer, strictCheck, objStack, srcStack) {
|
|
12
|
+
var hasCustomizer = typeof customizer === 'function';
|
|
13
|
+
if (isDeepComparable(object, source)) {
|
|
14
|
+
objStack = objStack || [];
|
|
15
|
+
srcStack = srcStack || [];
|
|
16
|
+
var stackLen = objStack.length;
|
|
17
|
+
while (stackLen--) {
|
|
18
|
+
if (objStack[stackLen] === object && srcStack[stackLen] === source) {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
objStack.push(object);
|
|
23
|
+
srcStack.push(source);
|
|
24
|
+
var keys = allKeys(source);
|
|
25
|
+
var length_1 = keys.length;
|
|
26
|
+
while (length_1--) {
|
|
27
|
+
var key = keys[length_1];
|
|
28
|
+
if (!(key in object)) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
var compared = void 0;
|
|
32
|
+
if (hasCustomizer) {
|
|
33
|
+
compared = customizer(object[key], source[key], key, object, source, objStack, srcStack);
|
|
34
|
+
}
|
|
35
|
+
if (compared !== undefined) {
|
|
36
|
+
if (!compared) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (!baseIsMatch(object[key], source[key], customizer, strictCheck, objStack, srcStack)) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
objStack.pop();
|
|
46
|
+
srcStack.pop();
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
var result = isEqual(object, source, function (objValue, srcValue, k, obj, src) {
|
|
50
|
+
if (hasCustomizer) {
|
|
51
|
+
var compared = customizer(objValue, srcValue, k, obj, src, objStack, srcStack);
|
|
52
|
+
if (compared !== undefined) {
|
|
53
|
+
return compared;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (isDeepComparable(objValue, srcValue)) {
|
|
57
|
+
return baseIsMatch(objValue, srcValue, customizer, strictCheck, objStack, srcStack);
|
|
58
|
+
}
|
|
59
|
+
}, strictCheck);
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
function isMatch(object, source, customizer, strictCheck) {
|
|
63
|
+
if (strictCheck === void 0) { strictCheck = false; }
|
|
64
|
+
if (typeof customizer === 'function' && isDeepComparable(object, source)) {
|
|
65
|
+
var compared = customizer(object, source);
|
|
66
|
+
if (compared !== undefined) {
|
|
67
|
+
return !!compared;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return baseIsMatch(object, source, customizer, strictCheck);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
module.exports = isMatch;
|
package/lib/isNumber.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var checkType = require('./internals/checkType.js');
|
|
4
|
+
var native = require('./internals/native.js');
|
|
5
5
|
|
|
6
6
|
function isNumber(value) {
|
|
7
|
-
return typeof value === 'number' || (
|
|
7
|
+
return typeof value === 'number' || checkType.checkType(value, native.numberTag);
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
module.exports = isNumber;
|
package/lib/isPlainObject.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var native = require('./internals/native.js');
|
|
4
|
-
var
|
|
4
|
+
var checkType = require('./internals/checkType.js');
|
|
5
5
|
var isObjectLike = require('./isObjectLike.js');
|
|
6
6
|
|
|
7
7
|
function isPlainObject(value) {
|
|
8
|
-
if (!isObjectLike(value) || !
|
|
8
|
+
if (!isObjectLike(value) || !checkType.checkType(value, native.objectTag)) {
|
|
9
9
|
return false;
|
|
10
10
|
}
|
|
11
11
|
var proto = Object.getPrototypeOf(Object(value));
|
package/lib/isRegExp.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var checkType = require('./internals/checkType.js');
|
|
4
|
+
var native = require('./internals/native.js');
|
|
4
5
|
var nodeUtil = require('./internals/nodeUtil.js');
|
|
5
|
-
var isObjectLike = require('./isObjectLike.js');
|
|
6
6
|
|
|
7
7
|
function isRegExp(value) {
|
|
8
|
-
return nodeUtil.nodeIsRegExp ? nodeUtil.nodeIsRegExp(value) :
|
|
8
|
+
return nodeUtil.nodeIsRegExp ? nodeUtil.nodeIsRegExp(value) : checkType.checkType(value, native.regExpTag);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
module.exports = isRegExp;
|
package/lib/isSet.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var checkType = require('./internals/checkType.js');
|
|
4
|
+
var native = require('./internals/native.js');
|
|
4
5
|
var nodeUtil = require('./internals/nodeUtil.js');
|
|
5
|
-
var isObjectLike = require('./isObjectLike.js');
|
|
6
6
|
|
|
7
7
|
function isSet(value) {
|
|
8
|
-
return nodeUtil.nodeIsSet ? nodeUtil.nodeIsSet(value) :
|
|
8
|
+
return nodeUtil.nodeIsSet ? nodeUtil.nodeIsSet(value) : checkType.checkType(value, native.setTag);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
module.exports = isSet;
|
package/lib/isString.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var checkType = require('./internals/checkType.js');
|
|
4
|
+
var native = require('./internals/native.js');
|
|
5
5
|
|
|
6
6
|
function isString(value) {
|
|
7
|
-
return typeof value === 'string' || (
|
|
7
|
+
return typeof value === 'string' || checkType.checkType(value, native.stringTag);
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
module.exports = isString;
|
package/lib/isSymbol.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var checkType = require('./internals/checkType.js');
|
|
4
|
+
var native = require('./internals/native.js');
|
|
5
5
|
|
|
6
6
|
function isSymbol(value) {
|
|
7
|
-
return typeof value === 'symbol' || (
|
|
7
|
+
return typeof value === 'symbol' || checkType.checkType(value, native.symbolTag);
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
module.exports = isSymbol;
|
package/lib/isTypedArray.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var checkType = require('./internals/checkType.js');
|
|
4
|
+
var native = require('./internals/native.js');
|
|
4
5
|
var nodeUtil = require('./internals/nodeUtil.js');
|
|
5
6
|
var isLength = require('./isLength.js');
|
|
6
7
|
var isObjectLike = require('./isObjectLike.js');
|
|
@@ -9,7 +10,7 @@ function isTypedArray(value) {
|
|
|
9
10
|
if (nodeUtil.nodeIsTypedArray) {
|
|
10
11
|
return nodeUtil.nodeIsTypedArray(value);
|
|
11
12
|
}
|
|
12
|
-
return isObjectLike(value) && isLength(value.length) &&
|
|
13
|
+
return isObjectLike(value) && isLength(value.length) && checkType.checkTypes(value, native.typedArrayTags);
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
module.exports = isTypedArray;
|
package/lib/isWeakMap.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var checkType = require('./internals/checkType.js');
|
|
4
|
+
var native = require('./internals/native.js');
|
|
5
5
|
|
|
6
6
|
function isWeakMap(value) {
|
|
7
|
-
return
|
|
7
|
+
return checkType.checkType(value, native.weakMapTag);
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
module.exports = isWeakMap;
|
package/lib/isWeakSet.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var checkType = require('./internals/checkType.js');
|
|
4
|
+
var native = require('./internals/native.js');
|
|
5
5
|
|
|
6
6
|
function isWeakSet(value) {
|
|
7
|
-
return
|
|
7
|
+
return checkType.checkType(value, native.weakSetTag);
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
module.exports = isWeakSet;
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -66,6 +66,7 @@ export { default as isFunction } from './isFunction';
|
|
|
66
66
|
export { default as isInteger } from './isInteger';
|
|
67
67
|
export { default as isLength } from './isLength';
|
|
68
68
|
export { default as isMap } from './isMap';
|
|
69
|
+
export { default as isMatch } from './isMatch';
|
|
69
70
|
export { default as isNaN } from './isNaN';
|
|
70
71
|
export { default as isNil } from './isNil';
|
|
71
72
|
export { default as isNull } from './isNull';
|
|
@@ -47,6 +47,12 @@ export declare const errorTag = "[object Error]";
|
|
|
47
47
|
export declare const arrayBufferTag = "[object ArrayBuffer]";
|
|
48
48
|
export declare const argumentsTag = "[object Arguments]";
|
|
49
49
|
export declare const arrayTag = "[object Array]";
|
|
50
|
+
export declare const typedArrayTags: string[];
|
|
51
|
+
export declare const functionTags: string[];
|
|
52
|
+
export declare const weakSetTag = "[object WeakSet]";
|
|
53
|
+
export declare const blobTag = "[object Blob]";
|
|
54
|
+
export declare const fileTag = "[object Blob]";
|
|
55
|
+
export declare const domExceptionTag = "[object DOMException]";
|
|
50
56
|
export declare const objectTag = "[object Object]";
|
|
51
57
|
export declare const dataViewTag = "[object DataView]";
|
|
52
58
|
export declare const mapTag = "[object Map]";
|
package/types/isBuffer.d.ts
CHANGED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
type Customizer = (objValue: any, srcValue: any, key?: number | string | symbol, object?: any, source?: any, objStack?: any[], srcStack?: any[]) => void | undefined | boolean;
|
|
2
|
+
/**
|
|
3
|
+
* 执行一个深比较,确定 `object` 是否含有和 `source` 完全相等的属性值。
|
|
4
|
+
*
|
|
5
|
+
* 注意:只有普通对象才会执行部分匹配,函数、数组不会执行部分匹配。
|
|
6
|
+
*
|
|
7
|
+
* 如果 `strictCheck=true` , 以下值不相等:
|
|
8
|
+
*
|
|
9
|
+
* 1. `0` `-0`
|
|
10
|
+
* 2. `typeof` 不同类型,如 `1` `Object(1)`
|
|
11
|
+
* 3. 无效日期对象,如 `new Date('')` `new Date('abc')`
|
|
12
|
+
*
|
|
13
|
+
* @static
|
|
14
|
+
* @alias module:Language.isMatch
|
|
15
|
+
* @since 1.4.0
|
|
16
|
+
* @requires module:Language.isEqual
|
|
17
|
+
* @param {Object} object 要检查的对象。
|
|
18
|
+
* @param {Object} source 属性值相匹配的对象。
|
|
19
|
+
* @param {Function} [customizer] 自定义比较。
|
|
20
|
+
* @param {boolean} [strictCheck=false] 严格比较。
|
|
21
|
+
* @returns {boolean} 如果 `object` 匹配,返回 `true` ,否则返回 `false` 。
|
|
22
|
+
* @example
|
|
23
|
+
*
|
|
24
|
+
* const object = { a: 1, b: -0 }
|
|
25
|
+
*
|
|
26
|
+
* isMatch(object, { a: 1 }); // true
|
|
27
|
+
* isMatch(object, { b: 0 }); // true
|
|
28
|
+
*
|
|
29
|
+
* // 严格比较
|
|
30
|
+
* isMatch(object, { b: 0 }, undefined, true); // false
|
|
31
|
+
*
|
|
32
|
+
* // 自定义比较
|
|
33
|
+
* function customizer(objValue, srcValue){
|
|
34
|
+
* if(typeof objValue === 'string' && typeof srcValue === 'string'){
|
|
35
|
+
* return true;
|
|
36
|
+
* }
|
|
37
|
+
* }
|
|
38
|
+
* isMatch({ foo: 'a' }, { foo: 'b' }, customizer); // true
|
|
39
|
+
* isMatch({ foo: ['a'] }, { foo: ['b'] }, customizer); // true
|
|
40
|
+
* isMatch({ foo: 'a' }, { foo: 'b' }, customizer); // true
|
|
41
|
+
*
|
|
42
|
+
*/
|
|
43
|
+
declare function isMatch(object: object, source: object, customizer?: Customizer, strictCheck?: boolean): boolean;
|
|
44
|
+
export default isMatch;
|
package/es/internals/isType.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import getTag from './getTag.js';
|
|
2
|
-
|
|
3
|
-
function isType(value, type) {
|
|
4
|
-
var nativeTypeString = getTag(value);
|
|
5
|
-
if (typeof type === 'string') {
|
|
6
|
-
return nativeTypeString === '[object ' + type + ']';
|
|
7
|
-
}
|
|
8
|
-
return type.some(function (item) { return nativeTypeString === '[object ' + item + ']'; });
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export { isType as default };
|
package/lib/internals/isType.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var getTag = require('./getTag.js');
|
|
4
|
-
|
|
5
|
-
function isType(value, type) {
|
|
6
|
-
var nativeTypeString = getTag(value);
|
|
7
|
-
if (typeof type === 'string') {
|
|
8
|
-
return nativeTypeString === '[object ' + type + ']';
|
|
9
|
-
}
|
|
10
|
-
return type.some(function (item) { return nativeTypeString === '[object ' + item + ']'; });
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
module.exports = isType;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 检测值的 `Object.prototype.toString` 类型。
|
|
3
|
-
*
|
|
4
|
-
* @private
|
|
5
|
-
* @since 1.0.0
|
|
6
|
-
* @param {*} value 检查值
|
|
7
|
-
* @param {string | string[]} type 类型名称
|
|
8
|
-
* @returns {boolean} 返回值类型是否匹配
|
|
9
|
-
*/
|
|
10
|
-
declare function isType(value: any, type: string | string[]): boolean;
|
|
11
|
-
export default isType;
|