ut2 1.3.2 → 1.4.1

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 (58) hide show
  1. package/dist/ut2.js +104 -33
  2. package/dist/ut2.js.map +1 -1
  3. package/dist/ut2.min.js +1 -1
  4. package/dist/ut2.min.js.map +1 -1
  5. package/es/index.js +1 -0
  6. package/es/internals/checkType.js +11 -0
  7. package/es/internals/helpers.js +5 -6
  8. package/es/internals/native.js +10 -1
  9. package/es/isArguments.js +4 -4
  10. package/es/isArrayBuffer.js +3 -3
  11. package/es/isBlob.js +3 -3
  12. package/es/isBoolean.js +3 -2
  13. package/es/isDataView.js +3 -2
  14. package/es/isDate.js +3 -3
  15. package/es/isError.js +3 -5
  16. package/es/isFunction.js +3 -2
  17. package/es/isMap.js +3 -3
  18. package/es/isMatch.js +71 -0
  19. package/es/isNumber.js +3 -3
  20. package/es/isPlainObject.js +3 -3
  21. package/es/isRegExp.js +3 -3
  22. package/es/isSet.js +3 -3
  23. package/es/isString.js +3 -3
  24. package/es/isSymbol.js +3 -3
  25. package/es/isTypedArray.js +3 -2
  26. package/es/isWeakMap.js +3 -3
  27. package/es/isWeakSet.js +3 -3
  28. package/lib/index.js +2 -0
  29. package/lib/internals/checkType.js +14 -0
  30. package/lib/internals/helpers.js +3 -4
  31. package/lib/internals/native.js +9 -0
  32. package/lib/isArguments.js +2 -2
  33. package/lib/isArrayBuffer.js +3 -3
  34. package/lib/isBlob.js +2 -2
  35. package/lib/isBoolean.js +3 -2
  36. package/lib/isDataView.js +3 -2
  37. package/lib/isDate.js +3 -3
  38. package/lib/isError.js +3 -5
  39. package/lib/isFunction.js +3 -2
  40. package/lib/isMap.js +3 -3
  41. package/lib/isMatch.js +73 -0
  42. package/lib/isNumber.js +3 -3
  43. package/lib/isPlainObject.js +2 -2
  44. package/lib/isRegExp.js +3 -3
  45. package/lib/isSet.js +3 -3
  46. package/lib/isString.js +3 -3
  47. package/lib/isSymbol.js +3 -3
  48. package/lib/isTypedArray.js +3 -2
  49. package/lib/isWeakMap.js +3 -3
  50. package/lib/isWeakSet.js +3 -3
  51. package/package.json +2 -4
  52. package/types/index.d.ts +1 -0
  53. package/types/internals/checkType.d.ts +2 -0
  54. package/types/internals/native.d.ts +6 -0
  55. package/types/isMatch.d.ts +44 -0
  56. package/es/internals/isType.js +0 -11
  57. package/lib/internals/isType.js +0 -13
  58. package/types/internals/isType.d.ts +0 -11
package/dist/ut2.js CHANGED
@@ -43,6 +43,9 @@
43
43
  }
44
44
  return '';
45
45
  }
46
+ function wrapTags(tags) {
47
+ return tags.map(function (item) { return '[object ' + item + ']'; });
48
+ }
46
49
  var numberTag = '[object Number]';
47
50
  var booleanTag = '[object Boolean]';
48
51
  var stringTag = '[object String]';
@@ -53,6 +56,12 @@
53
56
  var arrayBufferTag = '[object ArrayBuffer]';
54
57
  var argumentsTag = '[object Arguments]';
55
58
  var arrayTag = '[object Array]';
59
+ var typedArrayTags = wrapTags(['Float32Array', 'Float64Array', 'Int8Array', 'Int16Array', 'Int32Array', 'Uint8Array', 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'BigInt64Array', 'BigUint64Array']);
60
+ var functionTags = wrapTags(['Function', 'AsyncFunction', 'GeneratorFunction', 'Proxy']);
61
+ var weakSetTag = '[object WeakSet]';
62
+ var blobTag = '[object Blob]';
63
+ var fileTag = '[object Blob]';
64
+ var domExceptionTag = '[object DOMException]';
56
65
  var objectTag = '[object Object]';
57
66
  var dataViewTag = '[object DataView]';
58
67
  var mapTag = '[object Map]';
@@ -129,20 +138,16 @@
129
138
  }
130
139
  var getTag$1 = getTag;
131
140
 
132
- function isType(value, type) {
133
- var nativeTypeString = getTag$1(value);
134
- if (typeof type === 'string') {
135
- return nativeTypeString === '[object ' + type + ']';
136
- }
137
- return type.some(function (item) { return nativeTypeString === '[object ' + item + ']'; });
141
+ function checkType(value, tag) {
142
+ return getTag$1(value) === tag;
138
143
  }
139
-
140
- function isObjectLike(value) {
141
- return value != null && typeof value === 'object';
144
+ function checkTypes(value, tags) {
145
+ var tag = getTag$1(value);
146
+ return tags.some(function (item) { return tag === item; });
142
147
  }
143
148
 
144
149
  function isSymbol(value) {
145
- return typeof value === 'symbol' || (isObjectLike(value) && isType(value, 'Symbol'));
150
+ return typeof value === 'symbol' || checkType(value, symbolTag);
146
151
  }
147
152
 
148
153
  var reIsBinary = /^0b[01]+$/i;
@@ -273,21 +278,20 @@
273
278
  });
274
279
  }
275
280
 
276
- var argType = 'Arguments';
277
- var supportedArgumentsType = isType((function () { return arguments; })(), argType);
281
+ var supportedArgumentsType = checkType((function () { return arguments; })(), argumentsTag);
278
282
  var FUNC_ERROR_TEXT = 'Expected a function';
279
283
  var numberIsFinite = Number.isFinite;
280
284
  var numberIsInteger = Number.isInteger;
281
285
  var numberIsSafeInteger = Number.isSafeInteger;
282
286
  var objectGetOwnPropertySymbols = Object.getOwnPropertySymbols;
283
287
  var arrayAt = arrayProto.at;
284
- var VERSION = "1.3.2";
288
+ var VERSION = "1.4.1";
285
289
 
286
290
  function isFunction(value) {
287
291
  if (!isObject(value)) {
288
292
  return false;
289
293
  }
290
- return isType(value, ['Function', 'AsyncFunction', 'GeneratorFunction', 'Proxy']);
294
+ return checkTypes(value, functionTags);
291
295
  }
292
296
 
293
297
  function isLength(value) {
@@ -375,6 +379,10 @@
375
379
  return uniq(array.concat(other), iteratee, strickCheck);
376
380
  }
377
381
 
382
+ function isObjectLike(value) {
383
+ return value != null && typeof value === 'object';
384
+ }
385
+
378
386
  function isArrayLikeObject(value) {
379
387
  return isObjectLike(value) && isArrayLike(value);
380
388
  }
@@ -736,7 +744,7 @@
736
744
 
737
745
  function isArguments(value) {
738
746
  if (supportedArgumentsType) {
739
- return isObjectLike(value) && isType(value, argType);
747
+ return checkType(value, argumentsTag);
740
748
  }
741
749
  return isObjectLike(value) && hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee');
742
750
  }
@@ -764,15 +772,15 @@
764
772
  var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
765
773
 
766
774
  function isArrayBuffer(value) {
767
- return nodeIsArrayBuffer ? nodeIsArrayBuffer(value) : isObjectLike(value) && isType(value, 'ArrayBuffer');
775
+ return nodeIsArrayBuffer ? nodeIsArrayBuffer(value) : checkType(value, arrayBufferTag);
768
776
  }
769
777
 
770
778
  function isBlob(value) {
771
- return (blobExisted && value instanceof Blob) || isType(value, ['Blob', 'File']);
779
+ return (blobExisted && value instanceof Blob) || checkTypes(value, [blobTag, fileTag]);
772
780
  }
773
781
 
774
782
  function isBoolean(value) {
775
- return value === true || value === false || isType(value, 'Boolean');
783
+ return value === true || value === false || checkType(value, booleanTag);
776
784
  }
777
785
 
778
786
  function isBuffer(value) {
@@ -783,15 +791,15 @@
783
791
  }
784
792
 
785
793
  function isDataView(value) {
786
- return isType(value, 'DataView');
794
+ return checkType(value, dataViewTag);
787
795
  }
788
796
 
789
797
  function isDate(value) {
790
- return nodeIsDate ? nodeIsDate(value) : isObjectLike(value) && isType(value, 'Date');
798
+ return nodeIsDate ? nodeIsDate(value) : checkType(value, dateTag);
791
799
  }
792
800
 
793
801
  function isPlainObject(value) {
794
- if (!isObjectLike(value) || !isType(value, 'Object')) {
802
+ if (!isObjectLike(value) || !checkType(value, objectTag)) {
795
803
  return false;
796
804
  }
797
805
  var proto = Object.getPrototypeOf(Object(value));
@@ -829,11 +837,11 @@
829
837
  }
830
838
 
831
839
  function isMap(value) {
832
- return nodeIsMap ? nodeIsMap(value) : isObjectLike(value) && isType(value, 'Map');
840
+ return nodeIsMap ? nodeIsMap(value) : checkType(value, mapTag);
833
841
  }
834
842
 
835
843
  function isSet(value) {
836
- return nodeIsSet ? nodeIsSet(value) : isObjectLike(value) && isType(value, 'Set');
844
+ return nodeIsSet ? nodeIsSet(value) : checkType(value, setTag);
837
845
  }
838
846
 
839
847
  function isEmpty(value) {
@@ -876,7 +884,7 @@
876
884
  if (nodeIsTypedArray) {
877
885
  return nodeIsTypedArray(value);
878
886
  }
879
- return isObjectLike(value) && isLength(value.length) && isType(value, ['Float32Array', 'Float64Array', 'Int8Array', 'Int16Array', 'Int32Array', 'Uint8Array', 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'BigInt64Array', 'BigUint64Array']);
887
+ return isObjectLike(value) && isLength(value.length) && checkTypes(value, typedArrayTags);
880
888
  }
881
889
 
882
890
  function mapToArray(map) {
@@ -1055,10 +1063,7 @@
1055
1063
  }
1056
1064
 
1057
1065
  function isError(value) {
1058
- if (!isObjectLike(value)) {
1059
- return false;
1060
- }
1061
- return value instanceof Error || isType(value, ['Error', 'DOMException']);
1066
+ return isObjectLike(value) && (value instanceof Error || checkTypes(value, [errorTag, domExceptionTag]));
1062
1067
  }
1063
1068
 
1064
1069
  function isFinite(value) {
@@ -1069,8 +1074,73 @@
1069
1074
  return numberIsInteger ? numberIsInteger(value) : isFinite(value) && Math.floor(value) === value;
1070
1075
  }
1071
1076
 
1077
+ function isDeepComparable(object, source) {
1078
+ return checkType(object, objectTag) && checkType(source, objectTag);
1079
+ }
1080
+ function baseIsMatch(object, source, customizer, strictCheck, objStack, srcStack) {
1081
+ var hasCustomizer = typeof customizer === 'function';
1082
+ if (isDeepComparable(object, source)) {
1083
+ objStack = objStack || [];
1084
+ srcStack = srcStack || [];
1085
+ var stackLen = objStack.length;
1086
+ while (stackLen--) {
1087
+ if (objStack[stackLen] === object && srcStack[stackLen] === source) {
1088
+ return true;
1089
+ }
1090
+ }
1091
+ objStack.push(object);
1092
+ srcStack.push(source);
1093
+ var keys = allKeys(source);
1094
+ var length_1 = keys.length;
1095
+ while (length_1--) {
1096
+ var key = keys[length_1];
1097
+ if (!(key in object)) {
1098
+ return false;
1099
+ }
1100
+ var compared = void 0;
1101
+ if (hasCustomizer) {
1102
+ compared = customizer(object[key], source[key], key, object, source, objStack, srcStack);
1103
+ }
1104
+ if (compared !== undefined) {
1105
+ if (!compared) {
1106
+ return false;
1107
+ }
1108
+ continue;
1109
+ }
1110
+ if (!baseIsMatch(object[key], source[key], customizer, strictCheck, objStack, srcStack)) {
1111
+ return false;
1112
+ }
1113
+ }
1114
+ objStack.pop();
1115
+ srcStack.pop();
1116
+ return true;
1117
+ }
1118
+ var result = isEqual(object, source, function (objValue, srcValue, k, obj, src) {
1119
+ if (hasCustomizer) {
1120
+ var compared = customizer(objValue, srcValue, k, obj, src, objStack, srcStack);
1121
+ if (compared !== undefined) {
1122
+ return compared;
1123
+ }
1124
+ }
1125
+ if (isDeepComparable(objValue, srcValue)) {
1126
+ return baseIsMatch(objValue, srcValue, customizer, strictCheck, objStack, srcStack);
1127
+ }
1128
+ }, strictCheck);
1129
+ return result;
1130
+ }
1131
+ function isMatch(object, source, customizer, strictCheck) {
1132
+ if (strictCheck === void 0) { strictCheck = false; }
1133
+ if (typeof customizer === 'function' && isDeepComparable(object, source)) {
1134
+ var compared = customizer(object, source);
1135
+ if (compared !== undefined) {
1136
+ return !!compared;
1137
+ }
1138
+ }
1139
+ return baseIsMatch(object, source, customizer, strictCheck);
1140
+ }
1141
+
1072
1142
  function isNumber(value) {
1073
- return typeof value === 'number' || (isObjectLike(value) && isType(value, 'Number'));
1143
+ return typeof value === 'number' || checkType(value, numberTag);
1074
1144
  }
1075
1145
 
1076
1146
  function isNaN(value) {
@@ -1086,7 +1156,7 @@
1086
1156
  }
1087
1157
 
1088
1158
  function isRegExp(value) {
1089
- return nodeIsRegExp ? nodeIsRegExp(value) : isObjectLike(value) && isType(value, 'RegExp');
1159
+ return nodeIsRegExp ? nodeIsRegExp(value) : checkType(value, regExpTag);
1090
1160
  }
1091
1161
 
1092
1162
  function isSafeInteger(value) {
@@ -1094,7 +1164,7 @@
1094
1164
  }
1095
1165
 
1096
1166
  function isString(value) {
1097
- return typeof value === 'string' || (isObjectLike(value) && isType(value, 'String'));
1167
+ return typeof value === 'string' || checkType(value, stringTag);
1098
1168
  }
1099
1169
 
1100
1170
  function isUndefined(value) {
@@ -1102,11 +1172,11 @@
1102
1172
  }
1103
1173
 
1104
1174
  function isWeakMap(value) {
1105
- return isObjectLike(value) && isType(value, 'WeakMap');
1175
+ return checkType(value, weakMapTag);
1106
1176
  }
1107
1177
 
1108
1178
  function isWeakSet(value) {
1109
- return isObjectLike(value) && isType(value, 'WeakSet');
1179
+ return checkType(value, weakSetTag);
1110
1180
  }
1111
1181
 
1112
1182
  function decimalAdjust(type, value, precision) {
@@ -1609,6 +1679,7 @@
1609
1679
  exports.isInteger = isInteger;
1610
1680
  exports.isLength = isLength;
1611
1681
  exports.isMap = isMap;
1682
+ exports.isMatch = isMatch;
1612
1683
  exports.isNaN = isNaN;
1613
1684
  exports.isNil = isNil;
1614
1685
  exports.isNull = isNull;