ut2 1.9.2 → 1.9.3

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.
@@ -1,7 +1,7 @@
1
1
  import getTag from './getTag.js';
2
2
  import { argumentsTag, functionProtoToString } from './native.js';
3
3
 
4
- var VERSION = "1.9.2";
4
+ var VERSION = "1.9.3";
5
5
  var supportedArgumentsType = getTag((function () { return arguments; })()) === argumentsTag;
6
6
  var FUNC_ERROR_TEXT = 'Expected a function';
7
7
  function toSource(func) {
@@ -40,7 +40,6 @@ var errorTag = '[object Error]';
40
40
  var arrayBufferTag = '[object ArrayBuffer]';
41
41
  var argumentsTag = '[object Arguments]';
42
42
  var arrayTag = '[object Array]';
43
- var typedArrayTags = ['Float32Array', 'Float64Array', 'Int8Array', 'Int16Array', 'Int32Array', 'Uint8Array', 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'BigInt64Array', 'BigUint64Array'].map(function (item) { return '[object ' + item + ']'; });
44
43
  var functionTags = ['Function', 'AsyncFunction', 'GeneratorFunction', 'Proxy'].map(function (item) { return '[object ' + item + ']'; });
45
44
  var weakSetTag = '[object WeakSet]';
46
45
  var blobTag = '[object Blob]';
@@ -52,4 +51,4 @@ var promiseTag = '[object Promise]';
52
51
  var setTag = '[object Set]';
53
52
  var weakMapTag = '[object WeakMap]';
54
53
 
55
- export { MAX_ARRAY_LENGTH, MAX_SAFE_INTEGER, MIN_SAFE_INTEGER, argumentsTag, arrayBufferTag, arrayProto, arrayProtoSlice, arrayTag, bigIntTag, blobTag, booleanTag, dataViewTag, dateTag, domExceptionTag, errorTag, functionProto, functionProtoToString, functionTags, globalExisted, globalThisExisted, mapTag, mathAbs, mathCeil, mathFloor, mathMax, mathMin, mathRandom, nativeUndefined, numberIsFinite, numberIsInteger, numberIsSafeInteger, numberTag, objectGetOwnPropertySymbols, objectGetPrototypeOf, objectKeys, objectProto, objectProtoHasOwnProperty, objectProtoPropertyIsEnumerable, objectProtoToString, objectTag, promiseTag, regExpTag, selfExisted, setTag, stringObject, stringTag, stringUndefined, symbolProto, symbolTag, typedArrayTags, weakMapTag, weakSetTag };
54
+ export { MAX_ARRAY_LENGTH, MAX_SAFE_INTEGER, MIN_SAFE_INTEGER, argumentsTag, arrayBufferTag, arrayProto, arrayProtoSlice, arrayTag, bigIntTag, blobTag, booleanTag, dataViewTag, dateTag, domExceptionTag, errorTag, functionProto, functionProtoToString, functionTags, globalExisted, globalThisExisted, mapTag, mathAbs, mathCeil, mathFloor, mathMax, mathMin, mathRandom, nativeUndefined, numberIsFinite, numberIsInteger, numberIsSafeInteger, numberTag, objectGetOwnPropertySymbols, objectGetPrototypeOf, objectKeys, objectProto, objectProtoHasOwnProperty, objectProtoPropertyIsEnumerable, objectProtoToString, objectTag, promiseTag, regExpTag, selfExisted, setTag, stringObject, stringTag, stringUndefined, symbolProto, symbolTag, weakMapTag, weakSetTag };
package/es/isObject.js CHANGED
@@ -1,6 +1,7 @@
1
+ import isObjectLike from './isObjectLike.js';
2
+
1
3
  function isObject(value) {
2
- var type = typeof value;
3
- return type === 'function' || (type === 'object' && !!value);
4
+ return typeof value === 'function' || isObjectLike(value);
4
5
  }
5
6
 
6
7
  export { isObject as default };
@@ -1,16 +1,15 @@
1
1
  import getTag from './internals/getTag.js';
2
- import { typedArrayTags } from './internals/native.js';
3
2
  import { nodeIsTypedArray } from './internals/nodeUtil.js';
4
3
  import isLength from './isLength.js';
5
4
  import isObjectLike from './isObjectLike.js';
6
5
 
6
+ var typedArrayPattern = /\[object ((I|Ui)nt(8|16|32)|Float(32|64)|Uint8Clamped|Big(I|Ui)nt64)Array\]/;
7
7
  function isTypedArray(value) {
8
8
  if (nodeIsTypedArray) {
9
9
  return nodeIsTypedArray(value);
10
10
  }
11
11
  if (isObjectLike(value) && isLength(value.length)) {
12
- var tag_1 = getTag(value);
13
- return typedArrayTags.some(function (item) { return item === tag_1; });
12
+ return typedArrayPattern.test(getTag(value));
14
13
  }
15
14
  return false;
16
15
  }
package/es/uniqueId.js CHANGED
@@ -1,5 +1,7 @@
1
+ import { mathRandom } from './internals/native.js';
2
+
1
3
  var idCounter = 0;
2
- var defaultPrefix = '_' + Math.random().toString(36).substring(2, 4);
4
+ var defaultPrefix = '_' + mathRandom().toString(36).substring(2, 4);
3
5
  function uniqueId(prefix) {
4
6
  if (prefix === void 0) { prefix = defaultPrefix; }
5
7
  return '' + prefix + ++idCounter;
@@ -3,7 +3,7 @@
3
3
  var getTag = require('./getTag.js');
4
4
  var native = require('./native.js');
5
5
 
6
- var VERSION = "1.9.2";
6
+ var VERSION = "1.9.3";
7
7
  var supportedArgumentsType = getTag((function () { return arguments; })()) === native.argumentsTag;
8
8
  var FUNC_ERROR_TEXT = 'Expected a function';
9
9
  function toSource(func) {
@@ -42,7 +42,6 @@ var errorTag = '[object Error]';
42
42
  var arrayBufferTag = '[object ArrayBuffer]';
43
43
  var argumentsTag = '[object Arguments]';
44
44
  var arrayTag = '[object Array]';
45
- var typedArrayTags = ['Float32Array', 'Float64Array', 'Int8Array', 'Int16Array', 'Int32Array', 'Uint8Array', 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'BigInt64Array', 'BigUint64Array'].map(function (item) { return '[object ' + item + ']'; });
46
45
  var functionTags = ['Function', 'AsyncFunction', 'GeneratorFunction', 'Proxy'].map(function (item) { return '[object ' + item + ']'; });
47
46
  var weakSetTag = '[object WeakSet]';
48
47
  var blobTag = '[object Blob]';
@@ -103,6 +102,5 @@ exports.stringTag = stringTag;
103
102
  exports.stringUndefined = stringUndefined;
104
103
  exports.symbolProto = symbolProto;
105
104
  exports.symbolTag = symbolTag;
106
- exports.typedArrayTags = typedArrayTags;
107
105
  exports.weakMapTag = weakMapTag;
108
106
  exports.weakSetTag = weakSetTag;
package/lib/isObject.js CHANGED
@@ -1,8 +1,9 @@
1
1
  'use strict';
2
2
 
3
+ var isObjectLike = require('./isObjectLike.js');
4
+
3
5
  function isObject(value) {
4
- var type = typeof value;
5
- return type === 'function' || (type === 'object' && !!value);
6
+ return typeof value === 'function' || isObjectLike(value);
6
7
  }
7
8
 
8
9
  module.exports = isObject;
@@ -1,18 +1,17 @@
1
1
  'use strict';
2
2
 
3
3
  var getTag = require('./internals/getTag.js');
4
- var native = require('./internals/native.js');
5
4
  var nodeUtil = require('./internals/nodeUtil.js');
6
5
  var isLength = require('./isLength.js');
7
6
  var isObjectLike = require('./isObjectLike.js');
8
7
 
8
+ var typedArrayPattern = /\[object ((I|Ui)nt(8|16|32)|Float(32|64)|Uint8Clamped|Big(I|Ui)nt64)Array\]/;
9
9
  function isTypedArray(value) {
10
10
  if (nodeUtil.nodeIsTypedArray) {
11
11
  return nodeUtil.nodeIsTypedArray(value);
12
12
  }
13
13
  if (isObjectLike(value) && isLength(value.length)) {
14
- var tag_1 = getTag(value);
15
- return native.typedArrayTags.some(function (item) { return item === tag_1; });
14
+ return typedArrayPattern.test(getTag(value));
16
15
  }
17
16
  return false;
18
17
  }
package/lib/uniqueId.js CHANGED
@@ -1,7 +1,9 @@
1
1
  'use strict';
2
2
 
3
+ var native = require('./internals/native.js');
4
+
3
5
  var idCounter = 0;
4
- var defaultPrefix = '_' + Math.random().toString(36).substring(2, 4);
6
+ var defaultPrefix = '_' + native.mathRandom().toString(36).substring(2, 4);
5
7
  function uniqueId(prefix) {
6
8
  if (prefix === void 0) { prefix = defaultPrefix; }
7
9
  return '' + prefix + ++idCounter;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ut2",
3
- "version": "1.9.2",
3
+ "version": "1.9.3",
4
4
  "author": "caijf",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",
@@ -20,7 +20,7 @@
20
20
  "build:doc": "npm run doc",
21
21
  "doc": "rm -rf docs && rm -rf docs-src && tsc -p tsconfig.build.json -t esnext --outDir docs-src && jsdoc -c conf.json && rm -rf docs-src",
22
22
  "doc:open": "open ./docs/index.html",
23
- "lint": "eslint --ext .js,.jsx,.ts,.tsx",
23
+ "lint": "eslint . --ext .js,.jsx,.ts,.tsx",
24
24
  "lint:fix": "npm run lint:js -- --fix",
25
25
  "prettier": "prettier --write **/*",
26
26
  "commit": "cz",
@@ -61,36 +61,36 @@
61
61
  "registry": "https://registry.npmjs.org/"
62
62
  },
63
63
  "devDependencies": {
64
- "@commitlint/cli": "^19.2.1",
65
- "@commitlint/config-conventional": "^19.1.0",
64
+ "@commitlint/cli": "^19.3.0",
65
+ "@commitlint/config-conventional": "^19.2.2",
66
66
  "@commitlint/cz-commitlint": "^19.2.0",
67
- "@rollup/plugin-commonjs": "^25.0.7",
67
+ "@rollup/plugin-commonjs": "^25.0.8",
68
68
  "@rollup/plugin-node-resolve": "^15.2.3",
69
- "@rollup/plugin-replace": "^5.0.5",
69
+ "@rollup/plugin-replace": "^5.0.7",
70
70
  "@rollup/plugin-terser": "^0.4.4",
71
71
  "@rollup/plugin-typescript": "^11.1.6",
72
72
  "@types/jest": "^29.5.12",
73
- "@types/node": "^20.11.30",
74
- "@typescript-eslint/eslint-plugin": "^7.3.1",
75
- "@typescript-eslint/parser": "^7.3.1",
73
+ "@types/node": "^20.14.9",
74
+ "@typescript-eslint/eslint-plugin": "^7.14.1",
75
+ "@typescript-eslint/parser": "^7.14.1",
76
76
  "benchmark": "^2.1.4",
77
77
  "commitizen": "^4.3.0",
78
78
  "cross-env": "^7.0.3",
79
- "dayjs": "^1.11.10",
79
+ "dayjs": "^1.11.11",
80
80
  "docdash": "^2.0.2",
81
81
  "eslint": "^8.57.0",
82
82
  "husky": "^9.0.11",
83
- "inquirer": "9",
83
+ "inquirer": "^9.3.2",
84
84
  "jest": "^29.7.0",
85
85
  "jest-environment-jsdom": "^29.7.0",
86
- "jsdoc": "^4.0.2",
87
- "lint-staged": "^15.2.2",
86
+ "jsdoc": "^4.0.3",
87
+ "lint-staged": "^15.2.7",
88
88
  "lodash": "^4.17.21",
89
- "prettier": "^3.2.5",
90
- "rollup": "^4.13.0",
91
- "ts-jest": "^29.1.2",
92
- "tslib": "^2.6.2",
93
- "typescript": "^5.4.3",
89
+ "prettier": "^3.3.2",
90
+ "rollup": "^4.18.0",
91
+ "ts-jest": "^29.1.5",
92
+ "tslib": "^2.6.3",
93
+ "typescript": "^5.5.2",
94
94
  "underscore": "^1.13.6"
95
95
  },
96
96
  "engines": {
package/types/delay.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { FunctionAny } from './internals/types';
3
2
  /**
4
3
  * 延迟 `wait` 毫秒后调用 `func` 。
@@ -15,7 +15,7 @@ export declare const functionProto: Function;
15
15
  export declare const functionProtoToString: () => string;
16
16
  export declare const symbolProto: Symbol | undefined;
17
17
  export declare const arrayProto: any[];
18
- export declare const arrayProtoSlice: (start?: number | undefined, end?: number | undefined) => any[];
18
+ export declare const arrayProtoSlice: (start?: number, end?: number) => any[];
19
19
  export declare const mathMin: (...values: number[]) => number;
20
20
  export declare const mathMax: (...values: number[]) => number;
21
21
  export declare const mathRandom: () => number;
@@ -63,7 +63,6 @@ export declare const errorTag = "[object Error]";
63
63
  export declare const arrayBufferTag = "[object ArrayBuffer]";
64
64
  export declare const argumentsTag = "[object Arguments]";
65
65
  export declare const arrayTag = "[object Array]";
66
- export declare const typedArrayTags: string[];
67
66
  export declare const functionTags: string[];
68
67
  export declare const weakSetTag = "[object WeakSet]";
69
68
  export declare const blobTag = "[object Blob]";
@@ -17,5 +17,5 @@
17
17
  * isArrayLikeObject(()=>{}); // false
18
18
  *
19
19
  */
20
- declare function isArrayLikeObject(value: any): boolean;
20
+ declare function isArrayLikeObject(value: any): value is ArrayLike<any>;
21
21
  export default isArrayLikeObject;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  /**
3
2
  * 检查值是否为 `buffer` 。
4
3
  *
@@ -13,5 +13,5 @@
13
13
  * isElement('<body>'); // false
14
14
  *
15
15
  */
16
- declare function isElement(value: any): boolean;
16
+ declare function isElement(value: any): value is Element;
17
17
  export default isElement;
@@ -1,3 +1,4 @@
1
+ import { FunctionAny } from './internals/types';
1
2
  /**
2
3
  * 检查值是否为对象。(例如,数组、函数、对象、正则表达式、new Number(0) 和 new String(''))。
3
4
  *
@@ -18,5 +19,5 @@
18
19
  * isObject(null); // false
19
20
  *
20
21
  */
21
- declare function isObject(value: any): boolean;
22
+ declare function isObject(value: any): value is object | FunctionAny;
22
23
  export default isObject;
@@ -19,5 +19,5 @@
19
19
  * isObjectLike(null); // false
20
20
  *
21
21
  */
22
- declare function isObjectLike(value: any): boolean;
22
+ declare function isObjectLike(value: any): value is object;
23
23
  export default isObjectLike;
@@ -21,5 +21,5 @@
21
21
  * isPlainObject(Object.create(null)); // true
22
22
  *
23
23
  */
24
- declare function isPlainObject(value: any): boolean;
24
+ declare function isPlainObject(value: any): value is object;
25
25
  export default isPlainObject;
@@ -1,3 +1,8 @@
1
+ import { FunctionAny } from './internals/types';
2
+ type PromiseLikeObject = {
3
+ then: FunctionAny;
4
+ [x: string]: any;
5
+ };
1
6
  /**
2
7
  * 检测值是否类似 `Promise` 对象。
3
8
  *
@@ -17,5 +22,5 @@
17
22
  * isPromiseLike([]); // false
18
23
  *
19
24
  */
20
- declare function isPromiseLike(value: any): boolean;
25
+ declare function isPromiseLike(value: any): value is Promise<any> | PromiseLikeObject;
21
26
  export default isPromiseLike;