ut2 1.4.9 → 1.5.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 +4 -4
- package/dist/ut2.js +52 -53
- package/dist/ut2.js.map +1 -1
- package/dist/ut2.min.js +1 -1
- package/dist/ut2.min.js.map +1 -1
- package/es/internals/getSymbols.js +2 -2
- package/es/internals/getTag.js +8 -8
- package/es/internals/getTagWithBugfix.js +6 -6
- package/es/internals/helpers.js +4 -4
- package/es/internals/keys.js +2 -2
- package/es/internals/native.js +9 -8
- package/es/internals/nodeUtil.js +0 -5
- package/es/internals/root.js +2 -1
- package/es/isArguments.js +3 -3
- package/es/isArrayBuffer.js +2 -2
- package/es/isBlob.js +2 -2
- package/es/isBoolean.js +2 -2
- package/es/isDate.js +2 -2
- package/es/isEqual.js +3 -3
- package/es/isError.js +2 -2
- package/es/isFunction.js +2 -2
- package/es/isMatch.js +2 -2
- package/es/isNumber.js +2 -2
- package/es/isPlainObject.js +4 -4
- package/es/isRegExp.js +2 -2
- package/es/isString.js +2 -2
- package/es/isSymbol.js +2 -2
- package/es/isTypedArray.js +2 -2
- package/es/isWeakSet.js +2 -2
- package/es/nth.js +3 -3
- package/lib/internals/getSymbols.js +1 -1
- package/lib/internals/getTag.js +7 -7
- package/lib/internals/getTagWithBugfix.js +5 -5
- package/lib/internals/helpers.js +3 -3
- package/lib/internals/keys.js +1 -1
- package/lib/internals/native.js +8 -7
- package/lib/internals/nodeUtil.js +0 -5
- package/lib/internals/root.js +2 -1
- package/lib/isArguments.js +2 -2
- package/lib/isArrayBuffer.js +1 -1
- package/lib/isBlob.js +1 -1
- package/lib/isBoolean.js +1 -1
- package/lib/isDate.js +1 -1
- package/lib/isEqual.js +2 -2
- package/lib/isError.js +1 -1
- package/lib/isFunction.js +1 -1
- package/lib/isMatch.js +1 -1
- package/lib/isNumber.js +1 -1
- package/lib/isPlainObject.js +3 -3
- package/lib/isRegExp.js +1 -1
- package/lib/isString.js +1 -1
- package/lib/isSymbol.js +1 -1
- package/lib/isTypedArray.js +1 -1
- package/lib/isWeakSet.js +1 -1
- package/lib/nth.js +2 -2
- package/package.json +8 -7
- package/types/internals/native.d.ts +8 -7
package/README.md
CHANGED
|
@@ -18,18 +18,18 @@
|
|
|
18
18
|
|
|
19
19
|
安装依赖
|
|
20
20
|
|
|
21
|
-
#### npm
|
|
22
|
-
|
|
23
21
|
```shell
|
|
24
22
|
npm install ut2
|
|
25
23
|
```
|
|
26
24
|
|
|
27
|
-
#### yarn
|
|
28
|
-
|
|
29
25
|
```shell
|
|
30
26
|
yarn add ut2
|
|
31
27
|
```
|
|
32
28
|
|
|
29
|
+
```shell
|
|
30
|
+
pnpm add ut2
|
|
31
|
+
```
|
|
32
|
+
|
|
33
33
|
### 浏览器原生开发环境
|
|
34
34
|
|
|
35
35
|
如果你的项目使用的是原生方式开发,可以在浏览器中使用 `script` 标签直接引入文件,并使用全局变量 `ut2` 。
|
package/dist/ut2.js
CHANGED
|
@@ -9,19 +9,20 @@
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
var objectProto = Object.prototype;
|
|
12
|
-
var
|
|
12
|
+
var objectProtoToString = objectProto.toString;
|
|
13
|
+
var objectProtoHasOwnProperty = objectProto.hasOwnProperty;
|
|
14
|
+
var objectProtoPropertyIsEnumerable = objectProto.propertyIsEnumerable;
|
|
13
15
|
var objectGetOwnPropertySymbols = Object.getOwnPropertySymbols;
|
|
14
16
|
var objectGetPrototypeOf = Object.getPrototypeOf;
|
|
15
17
|
var objectKeys = Object.keys;
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
var functionToString = Function.prototype.toString;
|
|
18
|
+
var functionProto = Function.prototype;
|
|
19
|
+
var functionProtoToString = functionProto.toString;
|
|
19
20
|
var symbolExisted = typeof Symbol !== 'undefined';
|
|
20
21
|
var symbolProto = symbolExisted ? Symbol.prototype : undefined;
|
|
21
|
-
var
|
|
22
|
+
var symbolToStringTag = symbolExisted ? Symbol.toStringTag : undefined;
|
|
22
23
|
var arrayProto = Array.prototype;
|
|
23
|
-
var
|
|
24
|
-
var
|
|
24
|
+
var arrayProtoSlice = arrayProto.slice;
|
|
25
|
+
var arrayProtoAt = arrayProto.at;
|
|
25
26
|
var numberIsFinite = Number.isFinite;
|
|
26
27
|
var numberIsInteger = Number.isInteger;
|
|
27
28
|
var numberIsSafeInteger = Number.isSafeInteger;
|
|
@@ -56,7 +57,7 @@
|
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
function isSymbol(value) {
|
|
59
|
-
return typeof value === 'symbol' ||
|
|
60
|
+
return typeof value === 'symbol' || objectProtoToString.call(value) === symbolTag;
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
var reIsBinary = /^0b[01]+$/i;
|
|
@@ -191,7 +192,7 @@
|
|
|
191
192
|
if (typeof value === 'function') {
|
|
192
193
|
return true;
|
|
193
194
|
}
|
|
194
|
-
var tag =
|
|
195
|
+
var tag = objectProtoToString.call(value);
|
|
195
196
|
return functionTags.some(function (item) { return item === tag; });
|
|
196
197
|
}
|
|
197
198
|
|
|
@@ -208,8 +209,8 @@
|
|
|
208
209
|
if (!isArrayLike(array)) {
|
|
209
210
|
return undefined;
|
|
210
211
|
}
|
|
211
|
-
if (typeof
|
|
212
|
-
return
|
|
212
|
+
if (typeof arrayProtoAt === 'function') {
|
|
213
|
+
return arrayProtoAt.call(array, n);
|
|
213
214
|
}
|
|
214
215
|
var index = n < 0 ? n + array.length : n;
|
|
215
216
|
return array[index];
|
|
@@ -475,13 +476,13 @@
|
|
|
475
476
|
return value == null || value !== value ? defaultValue : value;
|
|
476
477
|
}
|
|
477
478
|
|
|
478
|
-
var VERSION = "1.
|
|
479
|
-
var supportedArgumentsType =
|
|
479
|
+
var VERSION = "1.5.0";
|
|
480
|
+
var supportedArgumentsType = objectProtoToString.call((function () { return arguments; })()) === argumentsTag;
|
|
480
481
|
var FUNC_ERROR_TEXT = 'Expected a function';
|
|
481
482
|
function toSource(func) {
|
|
482
483
|
if (func !== null) {
|
|
483
484
|
try {
|
|
484
|
-
return
|
|
485
|
+
return functionProtoToString.call(func);
|
|
485
486
|
}
|
|
486
487
|
catch (e) {
|
|
487
488
|
}
|
|
@@ -665,26 +666,19 @@
|
|
|
665
666
|
|
|
666
667
|
function isArguments(value) {
|
|
667
668
|
if (supportedArgumentsType) {
|
|
668
|
-
return
|
|
669
|
+
return objectProtoToString.call(value) === argumentsTag;
|
|
669
670
|
}
|
|
670
|
-
return isObjectLike(value) &&
|
|
671
|
+
return isObjectLike(value) && objectProtoHasOwnProperty.call(value, 'callee') && !objectProtoPropertyIsEnumerable.call(value, 'callee');
|
|
671
672
|
}
|
|
672
673
|
|
|
673
|
-
var freeGlobal = typeof global === 'object' && global && global.Object === Object && global;
|
|
674
|
-
var freeSelf = typeof self === 'object' && self && self.Object === Object && self;
|
|
675
|
-
var root = freeGlobal || freeSelf || Function('return this')() || {};
|
|
676
|
-
|
|
677
674
|
var freeExports = typeof exports === 'object' && exports && !exports.nodeType && exports;
|
|
678
675
|
var freeModule = freeExports && typeof module === 'object' && module && !module.nodeType && module;
|
|
679
|
-
var moduleExports = freeModule && freeModule.exports === freeExports;
|
|
680
|
-
var freeProcess = moduleExports && root.process;
|
|
681
676
|
var nodeUtil = (function () {
|
|
682
677
|
try {
|
|
683
678
|
var types = freeModule && freeModule.require && freeModule.require('util').types;
|
|
684
679
|
if (types) {
|
|
685
680
|
return types;
|
|
686
681
|
}
|
|
687
|
-
return freeProcess && freeProcess.binding && freeProcess.binding('util');
|
|
688
682
|
}
|
|
689
683
|
catch (e) {
|
|
690
684
|
}
|
|
@@ -697,7 +691,7 @@
|
|
|
697
691
|
var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
|
|
698
692
|
|
|
699
693
|
function isArrayBuffer(value) {
|
|
700
|
-
return nodeIsArrayBuffer ? nodeIsArrayBuffer(value) :
|
|
694
|
+
return nodeIsArrayBuffer ? nodeIsArrayBuffer(value) : objectProtoToString.call(value) === arrayBufferTag;
|
|
701
695
|
}
|
|
702
696
|
|
|
703
697
|
var blobExisted = typeof Blob !== 'undefined';
|
|
@@ -705,11 +699,11 @@
|
|
|
705
699
|
if (blobExisted && value instanceof Blob) {
|
|
706
700
|
return true;
|
|
707
701
|
}
|
|
708
|
-
return
|
|
702
|
+
return objectProtoToString.call(value) === blobTag;
|
|
709
703
|
}
|
|
710
704
|
|
|
711
705
|
function isBoolean(value) {
|
|
712
|
-
return value === true || value === false ||
|
|
706
|
+
return value === true || value === false || objectProtoToString.call(value) === booleanTag;
|
|
713
707
|
}
|
|
714
708
|
|
|
715
709
|
function isBuffer(value) {
|
|
@@ -723,28 +717,28 @@
|
|
|
723
717
|
}
|
|
724
718
|
|
|
725
719
|
function getRawTag(value) {
|
|
726
|
-
var isOwn =
|
|
727
|
-
var tag = value[
|
|
720
|
+
var isOwn = objectProtoHasOwnProperty.call(value, symbolToStringTag);
|
|
721
|
+
var tag = value[symbolToStringTag];
|
|
728
722
|
var unmasked = false;
|
|
729
723
|
try {
|
|
730
|
-
value[
|
|
724
|
+
value[symbolToStringTag] = undefined;
|
|
731
725
|
unmasked = true;
|
|
732
726
|
}
|
|
733
727
|
catch (e) {
|
|
734
728
|
}
|
|
735
|
-
var result =
|
|
729
|
+
var result = objectProtoToString.call(value);
|
|
736
730
|
if (unmasked) {
|
|
737
731
|
if (isOwn) {
|
|
738
|
-
value[
|
|
732
|
+
value[symbolToStringTag] = tag;
|
|
739
733
|
}
|
|
740
734
|
else {
|
|
741
|
-
delete value[
|
|
735
|
+
delete value[symbolToStringTag];
|
|
742
736
|
}
|
|
743
737
|
}
|
|
744
738
|
return result;
|
|
745
739
|
}
|
|
746
740
|
function getTag(value) {
|
|
747
|
-
return
|
|
741
|
+
return symbolToStringTag && symbolToStringTag in Object(value) ? getRawTag(value) : objectProtoToString.call(value);
|
|
748
742
|
}
|
|
749
743
|
|
|
750
744
|
var dataViewExisted = typeof DataView !== 'undefined';
|
|
@@ -758,11 +752,11 @@
|
|
|
758
752
|
var setCtorString = toSource(Set);
|
|
759
753
|
var weakMapCtorString = toSource(WeakMap);
|
|
760
754
|
var getTagWithBugfix = getTag;
|
|
761
|
-
if ((dataViewExisted &&
|
|
762
|
-
(mapExisted &&
|
|
763
|
-
(promiseExisted &&
|
|
764
|
-
(setExisted &&
|
|
765
|
-
(weakMapExisted &&
|
|
755
|
+
if ((dataViewExisted && objectProtoToString.call(new DataView(new ArrayBuffer(1))) !== dataViewTag) ||
|
|
756
|
+
(mapExisted && objectProtoToString.call(new Map()) !== mapTag) ||
|
|
757
|
+
(promiseExisted && objectProtoToString.call(Promise.resolve()) !== promiseTag) ||
|
|
758
|
+
(setExisted && objectProtoToString.call(new Set()) !== setTag) ||
|
|
759
|
+
(weakMapExisted && objectProtoToString.call(new WeakMap()) !== weakMapTag)) {
|
|
766
760
|
getTagWithBugfix = function (value) {
|
|
767
761
|
var result = getTag(value);
|
|
768
762
|
var Ctor = result === objectTag ? value.constructor : undefined;
|
|
@@ -791,10 +785,10 @@
|
|
|
791
785
|
}
|
|
792
786
|
|
|
793
787
|
function isDate(value) {
|
|
794
|
-
return nodeIsDate ? nodeIsDate(value) :
|
|
788
|
+
return nodeIsDate ? nodeIsDate(value) : objectProtoToString.call(value) === dateTag;
|
|
795
789
|
}
|
|
796
790
|
|
|
797
|
-
var objectCtorString =
|
|
791
|
+
var objectCtorString = functionProtoToString.call(Object);
|
|
798
792
|
function isPlainObject(value) {
|
|
799
793
|
if (!isObjectLike(value) || getTag(value) !== objectTag) {
|
|
800
794
|
return false;
|
|
@@ -803,8 +797,8 @@
|
|
|
803
797
|
if (proto === null) {
|
|
804
798
|
return true;
|
|
805
799
|
}
|
|
806
|
-
var Ctor =
|
|
807
|
-
return typeof Ctor === 'function' && Ctor instanceof Ctor &&
|
|
800
|
+
var Ctor = objectProtoHasOwnProperty.call(proto, 'constructor') && proto.constructor;
|
|
801
|
+
return typeof Ctor === 'function' && Ctor instanceof Ctor && functionProtoToString.call(Ctor) === objectCtorString;
|
|
808
802
|
}
|
|
809
803
|
|
|
810
804
|
function isElement(value) {
|
|
@@ -826,7 +820,7 @@
|
|
|
826
820
|
}
|
|
827
821
|
var result = [];
|
|
828
822
|
for (var key in Object(value)) {
|
|
829
|
-
if (
|
|
823
|
+
if (objectProtoHasOwnProperty.call(value, key) && key !== 'constructor') {
|
|
830
824
|
result.push(key);
|
|
831
825
|
}
|
|
832
826
|
}
|
|
@@ -864,7 +858,7 @@
|
|
|
864
858
|
if (!objectGetOwnPropertySymbols || object === null) {
|
|
865
859
|
return [];
|
|
866
860
|
}
|
|
867
|
-
return objectGetOwnPropertySymbols(object).filter(function (item) { return
|
|
861
|
+
return objectGetOwnPropertySymbols(object).filter(function (item) { return objectProtoPropertyIsEnumerable.call(object, item); });
|
|
868
862
|
}
|
|
869
863
|
|
|
870
864
|
function allKeys(object) {
|
|
@@ -883,7 +877,7 @@
|
|
|
883
877
|
return nodeIsTypedArray(value);
|
|
884
878
|
}
|
|
885
879
|
if (isObjectLike(value) && isLength(value.length)) {
|
|
886
|
-
var tag_1 =
|
|
880
|
+
var tag_1 = objectProtoToString.call(value);
|
|
887
881
|
return typedArrayTags.some(function (item) { return item === tag_1; });
|
|
888
882
|
}
|
|
889
883
|
return false;
|
|
@@ -905,7 +899,7 @@
|
|
|
905
899
|
return orderBy(result);
|
|
906
900
|
}
|
|
907
901
|
function argToArray(arg) {
|
|
908
|
-
return
|
|
902
|
+
return arrayProtoSlice.call(arg);
|
|
909
903
|
}
|
|
910
904
|
function toBufferView(bufferSource) {
|
|
911
905
|
return new Uint8Array(bufferSource.buffer || bufferSource, bufferSource.byteOffset || 0, bufferSource.byteLength);
|
|
@@ -1032,7 +1026,7 @@
|
|
|
1032
1026
|
continue;
|
|
1033
1027
|
}
|
|
1034
1028
|
}
|
|
1035
|
-
if (!(
|
|
1029
|
+
if (!(objectProtoHasOwnProperty.call(other, key) && isEqualDeep(value[key], other[key], customizer, strictCheck, valueStack, otherStack))) {
|
|
1036
1030
|
return false;
|
|
1037
1031
|
}
|
|
1038
1032
|
if (!skipCtor && key === 'constructor') {
|
|
@@ -1072,10 +1066,15 @@
|
|
|
1072
1066
|
if (value instanceof Error) {
|
|
1073
1067
|
return true;
|
|
1074
1068
|
}
|
|
1075
|
-
var tag =
|
|
1069
|
+
var tag = objectProtoToString.call(value);
|
|
1076
1070
|
return tag === errorTag || tag === domExceptionTag;
|
|
1077
1071
|
}
|
|
1078
1072
|
|
|
1073
|
+
var freeGlobalThis = typeof globalThis === 'object' && globalThis && globalThis.Object === Object && globalThis;
|
|
1074
|
+
var freeGlobal = typeof global === 'object' && global && global.Object === Object && global;
|
|
1075
|
+
var freeSelf = typeof self === 'object' && self && self.Object === Object && self;
|
|
1076
|
+
var root = freeGlobalThis || freeGlobal || freeSelf || Function('return this')() || {};
|
|
1077
|
+
|
|
1079
1078
|
function isFinite(value) {
|
|
1080
1079
|
return numberIsFinite ? numberIsFinite(value) : typeof value === 'number' && root.isFinite(value);
|
|
1081
1080
|
}
|
|
@@ -1085,7 +1084,7 @@
|
|
|
1085
1084
|
}
|
|
1086
1085
|
|
|
1087
1086
|
function isDeepComparable(object, source) {
|
|
1088
|
-
return
|
|
1087
|
+
return objectProtoToString.call(object) === objectTag && objectProtoToString.call(source) === objectTag;
|
|
1089
1088
|
}
|
|
1090
1089
|
function baseIsMatch(object, source, customizer, strictCheck, objStack, srcStack, executedCustomizer) {
|
|
1091
1090
|
if (executedCustomizer === void 0) { executedCustomizer = false; }
|
|
@@ -1151,7 +1150,7 @@
|
|
|
1151
1150
|
}
|
|
1152
1151
|
|
|
1153
1152
|
function isNumber(value) {
|
|
1154
|
-
return typeof value === 'number' ||
|
|
1153
|
+
return typeof value === 'number' || objectProtoToString.call(value) === numberTag;
|
|
1155
1154
|
}
|
|
1156
1155
|
|
|
1157
1156
|
function isNaN(value) {
|
|
@@ -1167,7 +1166,7 @@
|
|
|
1167
1166
|
}
|
|
1168
1167
|
|
|
1169
1168
|
function isRegExp(value) {
|
|
1170
|
-
return nodeIsRegExp ? nodeIsRegExp(value) :
|
|
1169
|
+
return nodeIsRegExp ? nodeIsRegExp(value) : objectProtoToString.call(value) === regExpTag;
|
|
1171
1170
|
}
|
|
1172
1171
|
|
|
1173
1172
|
function isSafeInteger(value) {
|
|
@@ -1175,7 +1174,7 @@
|
|
|
1175
1174
|
}
|
|
1176
1175
|
|
|
1177
1176
|
function isString(value) {
|
|
1178
|
-
return typeof value === 'string' ||
|
|
1177
|
+
return typeof value === 'string' || objectProtoToString.call(value) === stringTag;
|
|
1179
1178
|
}
|
|
1180
1179
|
|
|
1181
1180
|
function isUndefined(value) {
|
|
@@ -1187,7 +1186,7 @@
|
|
|
1187
1186
|
}
|
|
1188
1187
|
|
|
1189
1188
|
function isWeakSet(value) {
|
|
1190
|
-
return
|
|
1189
|
+
return objectProtoToString.call(value) === weakSetTag;
|
|
1191
1190
|
}
|
|
1192
1191
|
|
|
1193
1192
|
function decimalAdjust(type, value, precision) {
|