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.
Files changed (64) hide show
  1. package/README.md +2 -4
  2. package/dist/ut2.js +124 -69
  3. package/dist/ut2.js.map +1 -1
  4. package/dist/ut2.min.js +1 -1
  5. package/dist/ut2.min.js.map +1 -1
  6. package/es/index.js +1 -0
  7. package/es/internals/checkType.js +11 -0
  8. package/es/internals/compare.js +8 -26
  9. package/es/internals/helpers.js +5 -6
  10. package/es/internals/native.js +10 -1
  11. package/es/isArguments.js +4 -4
  12. package/es/isArrayBuffer.js +3 -3
  13. package/es/isBlob.js +3 -3
  14. package/es/isBoolean.js +3 -2
  15. package/es/isDataView.js +3 -2
  16. package/es/isDate.js +3 -3
  17. package/es/isEqual.js +12 -10
  18. package/es/isError.js +3 -5
  19. package/es/isFunction.js +3 -2
  20. package/es/isMap.js +3 -3
  21. package/es/isMatch.js +71 -0
  22. package/es/isNumber.js +3 -3
  23. package/es/isPlainObject.js +3 -3
  24. package/es/isRegExp.js +3 -3
  25. package/es/isSet.js +3 -3
  26. package/es/isString.js +3 -3
  27. package/es/isSymbol.js +3 -3
  28. package/es/isTypedArray.js +3 -2
  29. package/es/isWeakMap.js +3 -3
  30. package/es/isWeakSet.js +3 -3
  31. package/lib/index.js +2 -0
  32. package/lib/internals/checkType.js +14 -0
  33. package/lib/internals/compare.js +8 -26
  34. package/lib/internals/helpers.js +3 -4
  35. package/lib/internals/native.js +9 -0
  36. package/lib/isArguments.js +2 -2
  37. package/lib/isArrayBuffer.js +3 -3
  38. package/lib/isBlob.js +2 -2
  39. package/lib/isBoolean.js +3 -2
  40. package/lib/isDataView.js +3 -2
  41. package/lib/isDate.js +3 -3
  42. package/lib/isEqual.js +12 -10
  43. package/lib/isError.js +3 -5
  44. package/lib/isFunction.js +3 -2
  45. package/lib/isMap.js +3 -3
  46. package/lib/isMatch.js +73 -0
  47. package/lib/isNumber.js +3 -3
  48. package/lib/isPlainObject.js +2 -2
  49. package/lib/isRegExp.js +3 -3
  50. package/lib/isSet.js +3 -3
  51. package/lib/isString.js +3 -3
  52. package/lib/isSymbol.js +3 -3
  53. package/lib/isTypedArray.js +3 -2
  54. package/lib/isWeakMap.js +3 -3
  55. package/lib/isWeakSet.js +3 -3
  56. package/package.json +1 -1
  57. package/types/index.d.ts +1 -0
  58. package/types/internals/checkType.d.ts +2 -0
  59. package/types/internals/native.d.ts +6 -0
  60. package/types/isBuffer.d.ts +1 -1
  61. package/types/isMatch.d.ts +44 -0
  62. package/es/internals/isType.js +0 -11
  63. package/lib/internals/isType.js +0 -13
  64. package/types/internals/isType.d.ts +0 -11
package/es/index.js CHANGED
@@ -42,6 +42,7 @@ export { default as isFunction } from './isFunction.js';
42
42
  export { default as isInteger } from './isInteger.js';
43
43
  export { default as isLength } from './isLength.js';
44
44
  export { default as isMap } from './isMap.js';
45
+ export { default as isMatch } from './isMatch.js';
45
46
  export { default as isNaN } from './isNaN.js';
46
47
  export { default as isNil } from './isNil.js';
47
48
  export { default as isNull } from './isNull.js';
@@ -0,0 +1,11 @@
1
+ import getTag from './getTag.js';
2
+
3
+ function checkType(value, tag) {
4
+ return getTag(value) === tag;
5
+ }
6
+ function checkTypes(value, tags) {
7
+ var tag = getTag(value);
8
+ return tags.some(function (item) { return tag === item; });
9
+ }
10
+
11
+ export { checkType, checkTypes };
@@ -4,21 +4,12 @@ import toString from '../toString.js';
4
4
  function compareAsc(value, other) {
5
5
  var valueIsSymbol = isSymbol(value);
6
6
  var otherIsSymbol = isSymbol(other);
7
- if (valueIsSymbol && otherIsSymbol) {
8
- return 0;
9
- }
10
- if (valueIsSymbol) {
11
- return 1;
12
- }
13
- if (otherIsSymbol) {
14
- return -1;
15
- }
16
- var valStr = toString(value);
17
- var othStr = toString(other);
18
- if (valStr > othStr) {
7
+ var valueStr = toString(value);
8
+ var otherStr = toString(other);
9
+ if (!otherIsSymbol && (valueIsSymbol || valueStr > otherStr)) {
19
10
  return 1;
20
11
  }
21
- if (valStr < othStr) {
12
+ if (!valueIsSymbol && (otherIsSymbol || valueStr < otherStr)) {
22
13
  return -1;
23
14
  }
24
15
  return 0;
@@ -26,21 +17,12 @@ function compareAsc(value, other) {
26
17
  function compareDesc(value, other) {
27
18
  var valueIsSymbol = isSymbol(value);
28
19
  var otherIsSymbol = isSymbol(other);
29
- if (valueIsSymbol && otherIsSymbol) {
30
- return 0;
31
- }
32
- if (valueIsSymbol) {
33
- return -1;
34
- }
35
- if (otherIsSymbol) {
36
- return 1;
37
- }
38
- var valStr = toString(value);
39
- var othStr = toString(other);
40
- if (valStr > othStr) {
20
+ var valueStr = toString(value);
21
+ var otherStr = toString(other);
22
+ if (!otherIsSymbol && (valueIsSymbol || valueStr > otherStr)) {
41
23
  return -1;
42
24
  }
43
- if (valStr < othStr) {
25
+ if (!valueIsSymbol && (otherIsSymbol || valueStr < otherStr)) {
44
26
  return 1;
45
27
  }
46
28
  return 0;
@@ -1,14 +1,13 @@
1
- import isType from './isType.js';
2
- import { arrayProto } from './native.js';
1
+ import { checkType } from './checkType.js';
2
+ import { arrayProto, argumentsTag } from './native.js';
3
3
 
4
- var argType = 'Arguments';
5
- var supportedArgumentsType = isType((function () { return arguments; })(), argType);
4
+ var supportedArgumentsType = checkType((function () { return arguments; })(), argumentsTag);
6
5
  var FUNC_ERROR_TEXT = 'Expected a function';
7
6
  var numberIsFinite = Number.isFinite;
8
7
  var numberIsInteger = Number.isInteger;
9
8
  var numberIsSafeInteger = Number.isSafeInteger;
10
9
  var objectGetOwnPropertySymbols = Object.getOwnPropertySymbols;
11
10
  var arrayAt = arrayProto.at;
12
- var VERSION = "1.3.1";
11
+ var VERSION = "1.4.0";
13
12
 
14
- export { FUNC_ERROR_TEXT, VERSION, argType, arrayAt, numberIsFinite, numberIsInteger, numberIsSafeInteger, objectGetOwnPropertySymbols, supportedArgumentsType };
13
+ export { FUNC_ERROR_TEXT, VERSION, arrayAt, numberIsFinite, numberIsInteger, numberIsSafeInteger, objectGetOwnPropertySymbols, supportedArgumentsType };
@@ -33,6 +33,9 @@ function toSource(func) {
33
33
  }
34
34
  return '';
35
35
  }
36
+ function wrapTags(tags) {
37
+ return tags.map(function (item) { return '[object ' + item + ']'; });
38
+ }
36
39
  var numberTag = '[object Number]';
37
40
  var booleanTag = '[object Boolean]';
38
41
  var stringTag = '[object String]';
@@ -43,6 +46,12 @@ var errorTag = '[object Error]';
43
46
  var arrayBufferTag = '[object ArrayBuffer]';
44
47
  var argumentsTag = '[object Arguments]';
45
48
  var arrayTag = '[object Array]';
49
+ var typedArrayTags = wrapTags(['Float32Array', 'Float64Array', 'Int8Array', 'Int16Array', 'Int32Array', 'Uint8Array', 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'BigInt64Array', 'BigUint64Array']);
50
+ var functionTags = wrapTags(['Function', 'AsyncFunction', 'GeneratorFunction', 'Proxy']);
51
+ var weakSetTag = '[object WeakSet]';
52
+ var blobTag = '[object Blob]';
53
+ var fileTag = '[object Blob]';
54
+ var domExceptionTag = '[object DOMException]';
46
55
  var objectTag = '[object Object]';
47
56
  var dataViewTag = '[object DataView]';
48
57
  var mapTag = '[object Map]';
@@ -61,4 +70,4 @@ var promiseCtorString = initSource(promiseExisted, toSource(Promise));
61
70
  var setCtorString = initSource(setExisted, toSource(Set));
62
71
  var weakMapCtorString = initSource(weakMapExisted, toSource(WeakMap));
63
72
 
64
- export { MAX_ARRAY_LENGTH, MAX_SAFE_INTEGER, MIN_SAFE_INTEGER, argumentsTag, arrSlice, arrayBufferTag, arrayProto, arrayTag, blobExisted, booleanTag, dataViewCtorString, dataViewExisted, dataViewTag, dateTag, errorTag, functionToString, hasOwnProperty, initSource, mapCtorString, mapExisted, mapTag, numberTag, objectCtorString, objectProto, objectTag, objectToString, promiseCtorString, promiseExisted, promiseTag, propertyIsEnumerable, regExpTag, root, setCtorString, setExisted, setTag, stringTag, symToStringTag, symbolProto, symbolTag, symbolValueOf, toSource, weakMapCtorString, weakMapExisted, weakMapTag };
73
+ export { MAX_ARRAY_LENGTH, MAX_SAFE_INTEGER, MIN_SAFE_INTEGER, argumentsTag, arrSlice, arrayBufferTag, arrayProto, arrayTag, blobExisted, blobTag, booleanTag, dataViewCtorString, dataViewExisted, dataViewTag, dateTag, domExceptionTag, errorTag, fileTag, functionTags, functionToString, hasOwnProperty, initSource, mapCtorString, mapExisted, mapTag, numberTag, objectCtorString, objectProto, objectTag, objectToString, promiseCtorString, promiseExisted, promiseTag, propertyIsEnumerable, regExpTag, root, setCtorString, setExisted, setTag, stringTag, symToStringTag, symbolProto, symbolTag, symbolValueOf, toSource, typedArrayTags, weakMapCtorString, weakMapExisted, weakMapTag, weakSetTag };
package/es/isArguments.js CHANGED
@@ -1,11 +1,11 @@
1
- import isType from './internals/isType.js';
2
- import { hasOwnProperty, propertyIsEnumerable } from './internals/native.js';
3
- import { supportedArgumentsType, argType } from './internals/helpers.js';
1
+ import { argumentsTag, hasOwnProperty, propertyIsEnumerable } from './internals/native.js';
2
+ import { supportedArgumentsType } from './internals/helpers.js';
4
3
  import isObjectLike from './isObjectLike.js';
4
+ import { checkType } from './internals/checkType.js';
5
5
 
6
6
  function isArguments(value) {
7
7
  if (supportedArgumentsType) {
8
- return isObjectLike(value) && isType(value, argType);
8
+ return checkType(value, argumentsTag);
9
9
  }
10
10
  return isObjectLike(value) && hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee');
11
11
  }
@@ -1,9 +1,9 @@
1
- import isType from './internals/isType.js';
1
+ import { checkType } from './internals/checkType.js';
2
+ import { arrayBufferTag } from './internals/native.js';
2
3
  import { nodeIsArrayBuffer } from './internals/nodeUtil.js';
3
- import isObjectLike from './isObjectLike.js';
4
4
 
5
5
  function isArrayBuffer(value) {
6
- return nodeIsArrayBuffer ? nodeIsArrayBuffer(value) : isObjectLike(value) && isType(value, 'ArrayBuffer');
6
+ return nodeIsArrayBuffer ? nodeIsArrayBuffer(value) : checkType(value, arrayBufferTag);
7
7
  }
8
8
 
9
9
  export { isArrayBuffer as default };
package/es/isBlob.js CHANGED
@@ -1,8 +1,8 @@
1
- import isType from './internals/isType.js';
2
- import { blobExisted } from './internals/native.js';
1
+ import { checkTypes } from './internals/checkType.js';
2
+ import { blobExisted, blobTag, fileTag } from './internals/native.js';
3
3
 
4
4
  function isBlob(value) {
5
- return (blobExisted && value instanceof Blob) || isType(value, ['Blob', 'File']);
5
+ return (blobExisted && value instanceof Blob) || checkTypes(value, [blobTag, fileTag]);
6
6
  }
7
7
 
8
8
  export { isBlob as default };
package/es/isBoolean.js CHANGED
@@ -1,7 +1,8 @@
1
- import isType from './internals/isType.js';
1
+ import { checkType } from './internals/checkType.js';
2
+ import { booleanTag } from './internals/native.js';
2
3
 
3
4
  function isBoolean(value) {
4
- return value === true || value === false || isType(value, 'Boolean');
5
+ return value === true || value === false || checkType(value, booleanTag);
5
6
  }
6
7
 
7
8
  export { isBoolean as default };
package/es/isDataView.js CHANGED
@@ -1,7 +1,8 @@
1
- import isType from './internals/isType.js';
1
+ import { checkType } from './internals/checkType.js';
2
+ import { dataViewTag } from './internals/native.js';
2
3
 
3
4
  function isDataView(value) {
4
- return isType(value, 'DataView');
5
+ return checkType(value, dataViewTag);
5
6
  }
6
7
 
7
8
  export { isDataView as default };
package/es/isDate.js CHANGED
@@ -1,9 +1,9 @@
1
- import isType from './internals/isType.js';
1
+ import { checkType } from './internals/checkType.js';
2
+ import { dateTag } from './internals/native.js';
2
3
  import { nodeIsDate } from './internals/nodeUtil.js';
3
- import isObjectLike from './isObjectLike.js';
4
4
 
5
5
  function isDate(value) {
6
- return nodeIsDate ? nodeIsDate(value) : isObjectLike(value) && isType(value, 'Date');
6
+ return nodeIsDate ? nodeIsDate(value) : checkType(value, dateTag);
7
7
  }
8
8
 
9
9
  export { isDate as default };
package/es/isEqual.js CHANGED
@@ -122,13 +122,14 @@ function isEqualDeep(value, other, customizer, strictCheck, valueStack, otherSta
122
122
  if (hasCustomizer) {
123
123
  var compared = customizer(value[length], other[length], length, value, other, valueStack, otherStack);
124
124
  if (compared !== undefined) {
125
- result = !!compared;
126
- break;
125
+ if (!compared) {
126
+ return false;
127
+ }
128
+ continue;
127
129
  }
128
130
  }
129
131
  if (!isEqualDeep(value[length], other[length], customizer, strictCheck, valueStack, otherStack)) {
130
- result = false;
131
- break;
132
+ return false;
132
133
  }
133
134
  }
134
135
  }
@@ -144,23 +145,24 @@ function isEqualDeep(value, other, customizer, strictCheck, valueStack, otherSta
144
145
  if (hasCustomizer) {
145
146
  var compared = customizer(value[key], other[key], key, value, other, valueStack, otherStack);
146
147
  if (compared !== undefined) {
147
- result = !!compared;
148
- break;
148
+ if (!compared) {
149
+ return false;
150
+ }
151
+ continue;
149
152
  }
150
153
  }
151
154
  if (!(hasOwnProperty.call(other, key) && isEqualDeep(value[key], other[key], customizer, strictCheck, valueStack, otherStack))) {
152
- result = false;
153
- break;
155
+ return false;
154
156
  }
155
157
  if (!skipCtor && key === 'constructor') {
156
158
  skipCtor = true;
157
159
  }
158
160
  }
159
- if (result && !skipCtor) {
161
+ if (!skipCtor) {
160
162
  var valCtor = value.constructor;
161
163
  var othCtor = other.constructor;
162
164
  if (valCtor !== othCtor && !(isFunction(valCtor) && valCtor instanceof valCtor && isFunction(othCtor) && othCtor instanceof othCtor) && 'constructor' in value && 'constructor' in other) {
163
- result = false;
165
+ return false;
164
166
  }
165
167
  }
166
168
  }
package/es/isError.js CHANGED
@@ -1,11 +1,9 @@
1
- import isType from './internals/isType.js';
1
+ import { checkTypes } from './internals/checkType.js';
2
+ import { errorTag, domExceptionTag } from './internals/native.js';
2
3
  import isObjectLike from './isObjectLike.js';
3
4
 
4
5
  function isError(value) {
5
- if (!isObjectLike(value)) {
6
- return false;
7
- }
8
- return value instanceof Error || isType(value, ['Error', 'DOMException']);
6
+ return isObjectLike(value) && (value instanceof Error || checkTypes(value, [errorTag, domExceptionTag]));
9
7
  }
10
8
 
11
9
  export { isError as default };
package/es/isFunction.js CHANGED
@@ -1,11 +1,12 @@
1
- import isType from './internals/isType.js';
1
+ import { checkTypes } from './internals/checkType.js';
2
+ import { functionTags } from './internals/native.js';
2
3
  import isObject from './isObject.js';
3
4
 
4
5
  function isFunction(value) {
5
6
  if (!isObject(value)) {
6
7
  return false;
7
8
  }
8
- return isType(value, ['Function', 'AsyncFunction', 'GeneratorFunction', 'Proxy']);
9
+ return checkTypes(value, functionTags);
9
10
  }
10
11
 
11
12
  export { isFunction as default };
package/es/isMap.js CHANGED
@@ -1,9 +1,9 @@
1
- import isType from './internals/isType.js';
1
+ import { checkType } from './internals/checkType.js';
2
+ import { mapTag } from './internals/native.js';
2
3
  import { nodeIsMap } from './internals/nodeUtil.js';
3
- import isObjectLike from './isObjectLike.js';
4
4
 
5
5
  function isMap(value) {
6
- return nodeIsMap ? nodeIsMap(value) : isObjectLike(value) && isType(value, 'Map');
6
+ return nodeIsMap ? nodeIsMap(value) : checkType(value, mapTag);
7
7
  }
8
8
 
9
9
  export { isMap as default };
package/es/isMatch.js ADDED
@@ -0,0 +1,71 @@
1
+ import allKeys from './allKeys.js';
2
+ import { checkType } from './internals/checkType.js';
3
+ import { objectTag } from './internals/native.js';
4
+ import isEqual from './isEqual.js';
5
+
6
+ function isDeepComparable(object, source) {
7
+ return checkType(object, objectTag) && checkType(source, objectTag);
8
+ }
9
+ function baseIsMatch(object, source, customizer, strictCheck, objStack, srcStack) {
10
+ var hasCustomizer = typeof customizer === 'function';
11
+ if (isDeepComparable(object, source)) {
12
+ objStack = objStack || [];
13
+ srcStack = srcStack || [];
14
+ var stackLen = objStack.length;
15
+ while (stackLen--) {
16
+ if (objStack[stackLen] === object && srcStack[stackLen] === source) {
17
+ return true;
18
+ }
19
+ }
20
+ objStack.push(object);
21
+ srcStack.push(source);
22
+ var keys = allKeys(source);
23
+ var length_1 = keys.length;
24
+ while (length_1--) {
25
+ var key = keys[length_1];
26
+ if (!(key in object)) {
27
+ return false;
28
+ }
29
+ var compared = void 0;
30
+ if (hasCustomizer) {
31
+ compared = customizer(object[key], source[key], key, object, source, objStack, srcStack);
32
+ }
33
+ if (compared !== undefined) {
34
+ if (!compared) {
35
+ return false;
36
+ }
37
+ continue;
38
+ }
39
+ if (!baseIsMatch(object[key], source[key], customizer, strictCheck, objStack, srcStack)) {
40
+ return false;
41
+ }
42
+ }
43
+ objStack.pop();
44
+ srcStack.pop();
45
+ return true;
46
+ }
47
+ var result = isEqual(object, source, function (objValue, srcValue, k, obj, src) {
48
+ if (hasCustomizer) {
49
+ var compared = customizer(objValue, srcValue, k, obj, src, objStack, srcStack);
50
+ if (compared !== undefined) {
51
+ return compared;
52
+ }
53
+ }
54
+ if (isDeepComparable(objValue, srcValue)) {
55
+ return baseIsMatch(objValue, srcValue, customizer, strictCheck, objStack, srcStack);
56
+ }
57
+ }, strictCheck);
58
+ return result;
59
+ }
60
+ function isMatch(object, source, customizer, strictCheck) {
61
+ if (strictCheck === void 0) { strictCheck = false; }
62
+ if (typeof customizer === 'function' && isDeepComparable(object, source)) {
63
+ var compared = customizer(object, source);
64
+ if (compared !== undefined) {
65
+ return !!compared;
66
+ }
67
+ }
68
+ return baseIsMatch(object, source, customizer, strictCheck);
69
+ }
70
+
71
+ export { isMatch as default };
package/es/isNumber.js CHANGED
@@ -1,8 +1,8 @@
1
- import isType from './internals/isType.js';
2
- import isObjectLike from './isObjectLike.js';
1
+ import { checkType } from './internals/checkType.js';
2
+ import { numberTag } from './internals/native.js';
3
3
 
4
4
  function isNumber(value) {
5
- return typeof value === 'number' || (isObjectLike(value) && isType(value, 'Number'));
5
+ return typeof value === 'number' || checkType(value, numberTag);
6
6
  }
7
7
 
8
8
  export { isNumber as default };
@@ -1,9 +1,9 @@
1
- import { hasOwnProperty, functionToString, objectCtorString } from './internals/native.js';
2
- import isType from './internals/isType.js';
1
+ import { objectTag, hasOwnProperty, functionToString, objectCtorString } from './internals/native.js';
2
+ import { checkType } from './internals/checkType.js';
3
3
  import isObjectLike from './isObjectLike.js';
4
4
 
5
5
  function isPlainObject(value) {
6
- if (!isObjectLike(value) || !isType(value, 'Object')) {
6
+ if (!isObjectLike(value) || !checkType(value, objectTag)) {
7
7
  return false;
8
8
  }
9
9
  var proto = Object.getPrototypeOf(Object(value));
package/es/isRegExp.js CHANGED
@@ -1,9 +1,9 @@
1
- import isType from './internals/isType.js';
1
+ import { checkType } from './internals/checkType.js';
2
+ import { regExpTag } from './internals/native.js';
2
3
  import { nodeIsRegExp } from './internals/nodeUtil.js';
3
- import isObjectLike from './isObjectLike.js';
4
4
 
5
5
  function isRegExp(value) {
6
- return nodeIsRegExp ? nodeIsRegExp(value) : isObjectLike(value) && isType(value, 'RegExp');
6
+ return nodeIsRegExp ? nodeIsRegExp(value) : checkType(value, regExpTag);
7
7
  }
8
8
 
9
9
  export { isRegExp as default };
package/es/isSet.js CHANGED
@@ -1,9 +1,9 @@
1
- import isType from './internals/isType.js';
1
+ import { checkType } from './internals/checkType.js';
2
+ import { setTag } from './internals/native.js';
2
3
  import { nodeIsSet } from './internals/nodeUtil.js';
3
- import isObjectLike from './isObjectLike.js';
4
4
 
5
5
  function isSet(value) {
6
- return nodeIsSet ? nodeIsSet(value) : isObjectLike(value) && isType(value, 'Set');
6
+ return nodeIsSet ? nodeIsSet(value) : checkType(value, setTag);
7
7
  }
8
8
 
9
9
  export { isSet as default };
package/es/isString.js CHANGED
@@ -1,8 +1,8 @@
1
- import isType from './internals/isType.js';
2
- import isObjectLike from './isObjectLike.js';
1
+ import { checkType } from './internals/checkType.js';
2
+ import { stringTag } from './internals/native.js';
3
3
 
4
4
  function isString(value) {
5
- return typeof value === 'string' || (isObjectLike(value) && isType(value, 'String'));
5
+ return typeof value === 'string' || checkType(value, stringTag);
6
6
  }
7
7
 
8
8
  export { isString as default };
package/es/isSymbol.js CHANGED
@@ -1,8 +1,8 @@
1
- import isType from './internals/isType.js';
2
- import isObjectLike from './isObjectLike.js';
1
+ import { checkType } from './internals/checkType.js';
2
+ import { symbolTag } from './internals/native.js';
3
3
 
4
4
  function isSymbol(value) {
5
- return typeof value === 'symbol' || (isObjectLike(value) && isType(value, 'Symbol'));
5
+ return typeof value === 'symbol' || checkType(value, symbolTag);
6
6
  }
7
7
 
8
8
  export { isSymbol as default };
@@ -1,4 +1,5 @@
1
- import isType from './internals/isType.js';
1
+ import { checkTypes } from './internals/checkType.js';
2
+ import { typedArrayTags } from './internals/native.js';
2
3
  import { nodeIsTypedArray } from './internals/nodeUtil.js';
3
4
  import isLength from './isLength.js';
4
5
  import isObjectLike from './isObjectLike.js';
@@ -7,7 +8,7 @@ function isTypedArray(value) {
7
8
  if (nodeIsTypedArray) {
8
9
  return nodeIsTypedArray(value);
9
10
  }
10
- return isObjectLike(value) && isLength(value.length) && isType(value, ['Float32Array', 'Float64Array', 'Int8Array', 'Int16Array', 'Int32Array', 'Uint8Array', 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'BigInt64Array', 'BigUint64Array']);
11
+ return isObjectLike(value) && isLength(value.length) && checkTypes(value, typedArrayTags);
11
12
  }
12
13
 
13
14
  export { isTypedArray as default };
package/es/isWeakMap.js CHANGED
@@ -1,8 +1,8 @@
1
- import isType from './internals/isType.js';
2
- import isObjectLike from './isObjectLike.js';
1
+ import { checkType } from './internals/checkType.js';
2
+ import { weakMapTag } from './internals/native.js';
3
3
 
4
4
  function isWeakMap(value) {
5
- return isObjectLike(value) && isType(value, 'WeakMap');
5
+ return checkType(value, weakMapTag);
6
6
  }
7
7
 
8
8
  export { isWeakMap as default };
package/es/isWeakSet.js CHANGED
@@ -1,8 +1,8 @@
1
- import isType from './internals/isType.js';
2
- import isObjectLike from './isObjectLike.js';
1
+ import { checkType } from './internals/checkType.js';
2
+ import { weakSetTag } from './internals/native.js';
3
3
 
4
4
  function isWeakSet(value) {
5
- return isObjectLike(value) && isType(value, 'WeakSet');
5
+ return checkType(value, weakSetTag);
6
6
  }
7
7
 
8
8
  export { isWeakSet as default };
package/lib/index.js CHANGED
@@ -44,6 +44,7 @@ var isFunction = require('./isFunction.js');
44
44
  var isInteger = require('./isInteger.js');
45
45
  var isLength = require('./isLength.js');
46
46
  var isMap = require('./isMap.js');
47
+ var isMatch = require('./isMatch.js');
47
48
  var isNaN = require('./isNaN.js');
48
49
  var isNil = require('./isNil.js');
49
50
  var isNull = require('./isNull.js');
@@ -161,6 +162,7 @@ exports.isFunction = isFunction;
161
162
  exports.isInteger = isInteger;
162
163
  exports.isLength = isLength;
163
164
  exports.isMap = isMap;
165
+ exports.isMatch = isMatch;
164
166
  exports.isNaN = isNaN;
165
167
  exports.isNil = isNil;
166
168
  exports.isNull = isNull;
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ var getTag = require('./getTag.js');
4
+
5
+ function checkType(value, tag) {
6
+ return getTag(value) === tag;
7
+ }
8
+ function checkTypes(value, tags) {
9
+ var tag = getTag(value);
10
+ return tags.some(function (item) { return tag === item; });
11
+ }
12
+
13
+ exports.checkType = checkType;
14
+ exports.checkTypes = checkTypes;
@@ -6,21 +6,12 @@ var toString = require('../toString.js');
6
6
  function compareAsc(value, other) {
7
7
  var valueIsSymbol = isSymbol(value);
8
8
  var otherIsSymbol = isSymbol(other);
9
- if (valueIsSymbol && otherIsSymbol) {
10
- return 0;
11
- }
12
- if (valueIsSymbol) {
13
- return 1;
14
- }
15
- if (otherIsSymbol) {
16
- return -1;
17
- }
18
- var valStr = toString(value);
19
- var othStr = toString(other);
20
- if (valStr > othStr) {
9
+ var valueStr = toString(value);
10
+ var otherStr = toString(other);
11
+ if (!otherIsSymbol && (valueIsSymbol || valueStr > otherStr)) {
21
12
  return 1;
22
13
  }
23
- if (valStr < othStr) {
14
+ if (!valueIsSymbol && (otherIsSymbol || valueStr < otherStr)) {
24
15
  return -1;
25
16
  }
26
17
  return 0;
@@ -28,21 +19,12 @@ function compareAsc(value, other) {
28
19
  function compareDesc(value, other) {
29
20
  var valueIsSymbol = isSymbol(value);
30
21
  var otherIsSymbol = isSymbol(other);
31
- if (valueIsSymbol && otherIsSymbol) {
32
- return 0;
33
- }
34
- if (valueIsSymbol) {
35
- return -1;
36
- }
37
- if (otherIsSymbol) {
38
- return 1;
39
- }
40
- var valStr = toString(value);
41
- var othStr = toString(other);
42
- if (valStr > othStr) {
22
+ var valueStr = toString(value);
23
+ var otherStr = toString(other);
24
+ if (!otherIsSymbol && (valueIsSymbol || valueStr > otherStr)) {
43
25
  return -1;
44
26
  }
45
- if (valStr < othStr) {
27
+ if (!valueIsSymbol && (otherIsSymbol || valueStr < otherStr)) {
46
28
  return 1;
47
29
  }
48
30
  return 0;
@@ -1,14 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var isType = require('./isType.js');
3
+ var checkType = require('./checkType.js');
4
4
  var native = require('./native.js');
5
5
 
6
- exports.argType = 'Arguments';
7
- exports.supportedArgumentsType = isType((function () { return arguments; })(), exports.argType);
6
+ exports.supportedArgumentsType = checkType.checkType((function () { return arguments; })(), native.argumentsTag);
8
7
  exports.FUNC_ERROR_TEXT = 'Expected a function';
9
8
  exports.numberIsFinite = Number.isFinite;
10
9
  exports.numberIsInteger = Number.isInteger;
11
10
  exports.numberIsSafeInteger = Number.isSafeInteger;
12
11
  exports.objectGetOwnPropertySymbols = Object.getOwnPropertySymbols;
13
12
  exports.arrayAt = native.arrayProto.at;
14
- exports.VERSION = "1.3.1";
13
+ exports.VERSION = "1.4.0";
@@ -35,6 +35,9 @@ function toSource(func) {
35
35
  }
36
36
  return '';
37
37
  }
38
+ function wrapTags(tags) {
39
+ return tags.map(function (item) { return '[object ' + item + ']'; });
40
+ }
38
41
  exports.numberTag = '[object Number]';
39
42
  exports.booleanTag = '[object Boolean]';
40
43
  exports.stringTag = '[object String]';
@@ -45,6 +48,12 @@ exports.errorTag = '[object Error]';
45
48
  exports.arrayBufferTag = '[object ArrayBuffer]';
46
49
  exports.argumentsTag = '[object Arguments]';
47
50
  exports.arrayTag = '[object Array]';
51
+ exports.typedArrayTags = wrapTags(['Float32Array', 'Float64Array', 'Int8Array', 'Int16Array', 'Int32Array', 'Uint8Array', 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'BigInt64Array', 'BigUint64Array']);
52
+ exports.functionTags = wrapTags(['Function', 'AsyncFunction', 'GeneratorFunction', 'Proxy']);
53
+ exports.weakSetTag = '[object WeakSet]';
54
+ exports.blobTag = '[object Blob]';
55
+ exports.fileTag = '[object Blob]';
56
+ exports.domExceptionTag = '[object DOMException]';
48
57
  exports.objectTag = '[object Object]';
49
58
  exports.dataViewTag = '[object DataView]';
50
59
  exports.mapTag = '[object Map]';
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var isType = require('./internals/isType.js');
4
3
  var native = require('./internals/native.js');
5
4
  var helpers = require('./internals/helpers.js');
6
5
  var isObjectLike = require('./isObjectLike.js');
6
+ var checkType = require('./internals/checkType.js');
7
7
 
8
8
  function isArguments(value) {
9
9
  if (helpers.supportedArgumentsType) {
10
- return isObjectLike(value) && isType(value, helpers.argType);
10
+ return checkType.checkType(value, native.argumentsTag);
11
11
  }
12
12
  return isObjectLike(value) && native.hasOwnProperty.call(value, 'callee') && !native.propertyIsEnumerable.call(value, 'callee');
13
13
  }