ut2 1.10.0 → 1.11.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/es/index.js CHANGED
@@ -49,6 +49,7 @@ export { default as isElement } from './isElement.js';
49
49
  export { default as isEmpty } from './isEmpty.js';
50
50
  export { default as isEqual } from './isEqual.js';
51
51
  export { default as isError } from './isError.js';
52
+ export { default as isFile } from './isFile.js';
52
53
  export { default as isFinite } from './isFinite.js';
53
54
  export { default as isFunction } from './isFunction.js';
54
55
  export { default as isInteger } from './isInteger.js';
@@ -2,7 +2,7 @@ import isObjectLike from '../isObjectLike.js';
2
2
  import getTag from './getTag.js';
3
3
  import { argumentsTag, stringUndefined, functionProtoToString } from './native.js';
4
4
 
5
- var VERSION = "1.10.0";
5
+ var VERSION = "1.11.0";
6
6
  var isBrowser = typeof window !== stringUndefined && isObjectLike(window) && typeof document !== stringUndefined && isObjectLike(document) && window.document === document;
7
7
  var supportedArgumentsType = getTag((function () { return arguments; })()) === argumentsTag;
8
8
  var FUNC_ERROR_TEXT = 'Expected a function';
@@ -43,6 +43,7 @@ var arrayTag = '[object Array]';
43
43
  var functionTags = ['Function', 'AsyncFunction', 'GeneratorFunction', 'Proxy'].map(function (item) { return '[object ' + item + ']'; });
44
44
  var weakSetTag = '[object WeakSet]';
45
45
  var blobTag = '[object Blob]';
46
+ var fileTag = '[object File]';
46
47
  var domExceptionTag = '[object DOMException]';
47
48
  var objectTag = '[object Object]';
48
49
  var dataViewTag = '[object DataView]';
@@ -52,4 +53,4 @@ var setTag = '[object Set]';
52
53
  var weakMapTag = '[object WeakMap]';
53
54
  var windowTag = '[object Window]';
54
55
 
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, weakMapTag, weakSetTag, windowTag };
56
+ export { MAX_ARRAY_LENGTH, MAX_SAFE_INTEGER, MIN_SAFE_INTEGER, argumentsTag, arrayBufferTag, arrayProto, arrayProtoSlice, arrayTag, bigIntTag, blobTag, booleanTag, dataViewTag, dateTag, domExceptionTag, errorTag, fileTag, 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, windowTag };
package/es/isFile.js ADDED
@@ -0,0 +1,12 @@
1
+ import getTag from './internals/getTag.js';
2
+ import { fileTag, stringUndefined } from './internals/native.js';
3
+
4
+ var fileExisted = typeof File !== stringUndefined;
5
+ function isFile(value) {
6
+ if (fileExisted && value instanceof File) {
7
+ return true;
8
+ }
9
+ return getTag(value) === fileTag;
10
+ }
11
+
12
+ export { isFile as default };
package/es/merge.js CHANGED
@@ -51,5 +51,6 @@ function merge(object, source, customizer, getKeys) {
51
51
  if (getKeys === void 0) { getKeys = allKeys; }
52
52
  return baseMerge(object, source, getKeys, customizer);
53
53
  }
54
+ merge.NOT_MERGE_ARRAYS = function (objValue, srcValue) { return (isArray(srcValue) ? srcValue : undefined); };
54
55
 
55
56
  export { merge as default };
package/lib/index.js CHANGED
@@ -51,6 +51,7 @@ var isElement = require('./isElement.js');
51
51
  var isEmpty = require('./isEmpty.js');
52
52
  var isEqual = require('./isEqual.js');
53
53
  var isError = require('./isError.js');
54
+ var isFile = require('./isFile.js');
54
55
  var isFinite = require('./isFinite.js');
55
56
  var isFunction = require('./isFunction.js');
56
57
  var isInteger = require('./isInteger.js');
@@ -187,6 +188,7 @@ exports.isElement = isElement;
187
188
  exports.isEmpty = isEmpty;
188
189
  exports.isEqual = isEqual;
189
190
  exports.isError = isError;
191
+ exports.isFile = isFile;
190
192
  exports.isFinite = isFinite;
191
193
  exports.isFunction = isFunction;
192
194
  exports.isInteger = isInteger;
@@ -4,7 +4,7 @@ var isObjectLike = require('../isObjectLike.js');
4
4
  var getTag = require('./getTag.js');
5
5
  var native = require('./native.js');
6
6
 
7
- var VERSION = "1.10.0";
7
+ var VERSION = "1.11.0";
8
8
  var isBrowser = typeof window !== native.stringUndefined && isObjectLike(window) && typeof document !== native.stringUndefined && isObjectLike(document) && window.document === document;
9
9
  var supportedArgumentsType = getTag((function () { return arguments; })()) === native.argumentsTag;
10
10
  var FUNC_ERROR_TEXT = 'Expected a function';
@@ -45,6 +45,7 @@ var arrayTag = '[object Array]';
45
45
  var functionTags = ['Function', 'AsyncFunction', 'GeneratorFunction', 'Proxy'].map(function (item) { return '[object ' + item + ']'; });
46
46
  var weakSetTag = '[object WeakSet]';
47
47
  var blobTag = '[object Blob]';
48
+ var fileTag = '[object File]';
48
49
  var domExceptionTag = '[object DOMException]';
49
50
  var objectTag = '[object Object]';
50
51
  var dataViewTag = '[object DataView]';
@@ -69,6 +70,7 @@ exports.dataViewTag = dataViewTag;
69
70
  exports.dateTag = dateTag;
70
71
  exports.domExceptionTag = domExceptionTag;
71
72
  exports.errorTag = errorTag;
73
+ exports.fileTag = fileTag;
72
74
  exports.functionProto = functionProto;
73
75
  exports.functionProtoToString = functionProtoToString;
74
76
  exports.functionTags = functionTags;
package/lib/isFile.js ADDED
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ var getTag = require('./internals/getTag.js');
4
+ var native = require('./internals/native.js');
5
+
6
+ var fileExisted = typeof File !== native.stringUndefined;
7
+ function isFile(value) {
8
+ if (fileExisted && value instanceof File) {
9
+ return true;
10
+ }
11
+ return getTag(value) === native.fileTag;
12
+ }
13
+
14
+ module.exports = isFile;
package/lib/merge.js CHANGED
@@ -53,5 +53,6 @@ function merge(object, source, customizer, getKeys) {
53
53
  if (getKeys === void 0) { getKeys = allKeys; }
54
54
  return baseMerge(object, source, getKeys, customizer);
55
55
  }
56
+ merge.NOT_MERGE_ARRAYS = function (objValue, srcValue) { return (isArray(srcValue) ? srcValue : undefined); };
56
57
 
57
58
  module.exports = merge;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ut2",
3
- "version": "1.10.0",
3
+ "version": "1.11.0",
4
4
  "author": "caijf",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",
package/types/index.d.ts CHANGED
@@ -73,6 +73,7 @@ export { default as isElement } from './isElement';
73
73
  export { default as isEmpty } from './isEmpty';
74
74
  export { default as isEqual } from './isEqual';
75
75
  export { default as isError } from './isError';
76
+ export { default as isFile } from './isFile';
76
77
  export { default as isFinite } from './isFinite';
77
78
  export { default as isFunction } from './isFunction';
78
79
  export { default as isInteger } from './isInteger';
@@ -66,6 +66,7 @@ export declare const arrayTag = "[object Array]";
66
66
  export declare const functionTags: string[];
67
67
  export declare const weakSetTag = "[object WeakSet]";
68
68
  export declare const blobTag = "[object Blob]";
69
+ export declare const fileTag = "[object File]";
69
70
  export declare const domExceptionTag = "[object DOMException]";
70
71
  export declare const objectTag = "[object Object]";
71
72
  export declare const dataViewTag = "[object DataView]";
package/types/isBlob.d.ts CHANGED
@@ -14,6 +14,8 @@
14
14
  *
15
15
  * isBlob(new Blob(['a'])); // true
16
16
  *
17
+ * isBlob(new File([], 'test.txt')); // true
18
+ *
17
19
  * isBlob({}); // false
18
20
  *
19
21
  * isBlob('2012'); // false
@@ -0,0 +1,24 @@
1
+ /**
2
+ * 检查值是否为 `File` 对象。
3
+ *
4
+ * 浏览器环境的 `File` 对象,或其他继承自 `File` 的实例,都将返回 `true`。
5
+ *
6
+ * @static
7
+ * @alias module:Language.isFile
8
+ * @since 1.11.0
9
+ * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/API/File File}
10
+ * @param {*} value 要检查的值。
11
+ * @returns {boolean} 如果值为 `File` 对象,返回 `true`,否则返回 `false`。
12
+ * @example
13
+ *
14
+ * isFile(new File([], 'test.txt')); // true
15
+ *
16
+ * isBlob(new Blob(['a'])); // false
17
+ *
18
+ * isFile({}); // false
19
+ *
20
+ * isFile('2012'); // false
21
+ *
22
+ */
23
+ declare function isFile(value: any): value is File;
24
+ export default isFile;
@@ -1,8 +1,3 @@
1
- import { FunctionAny } from './internals/types';
2
- type PromiseLikeObject = {
3
- then: FunctionAny;
4
- [x: string]: any;
5
- };
6
1
  /**
7
2
  * 检测值是否类似 `Promise` 对象。
8
3
  *
@@ -22,5 +17,5 @@ type PromiseLikeObject = {
22
17
  * isPromiseLike([]); // false
23
18
  *
24
19
  */
25
- declare function isPromiseLike(value: any): value is Promise<any> | PromiseLikeObject;
20
+ declare function isPromiseLike(value: any): value is Promise<any> | PromiseLike<any>;
26
21
  export default isPromiseLike;
package/types/merge.d.ts CHANGED
@@ -5,7 +5,9 @@ type Customizer = (objValue: any, srcValue: any, key: string | symbol, object: a
5
5
  *
6
6
  * 如果目标值存在,被解析为 `undefined` 的 `source` 来源对象属性将被跳过。数组和普通对象会递归合并,其他对象和值会被直接分配覆盖。
7
7
  *
8
- * 如果你需要合并继承的属性,第四个参数传入 {@link https://caijf.github.io/ut2/module-Object.html#.allKeysIn allKeysIn} 方法, `merge(object, source, undefined, allKeysIn)`。
8
+ * 如果不需要合并数组,第三个参数传入 `merge.NOT_MERGE_ARRAYS`
9
+ *
10
+ * 如果需要合并继承的属性,第四个参数传入 {@link https://caijf.github.io/ut2/module-Object.html#.allKeysIn allKeysIn} 方法, `merge(object, source, undefined, allKeysIn)`。
9
11
  *
10
12
  * @static
11
13
  * @alias module:Object.merge
@@ -17,18 +19,27 @@ type Customizer = (objValue: any, srcValue: any, key: string | symbol, object: a
17
19
  * @returns {Object} 目标对象。
18
20
  * @example
19
21
  *
22
+ * merge({c: 3}, {e: 5}); // { c: 3, e: 5 }
23
+ * merge({ a: 1 }, { a: undefined, b: undefined }); // { a: 1, b: undefined }
24
+ *
20
25
  * const object = {
21
26
  * a: [{b: 2}, {d: 4}]
22
27
  * }
23
- *
24
28
  * const other = {
25
29
  * a: [{c: 3},{e: 5}]
26
30
  * }
27
31
  *
28
32
  * merge(object, other); // { a: [{b: 2, c: 3}, {d: 4, e: 5}] }
29
33
  *
30
- * // 自定义,数组不合并
34
+ * // 数组不合并
35
+ * merge(object, other, merge.NOT_MERGE_ARRAYS); // { a: [{c: 3},{e: 5}] }
36
+ *
37
+ * // 或自定义数组不合并方法
31
38
  * merge(object, other, (objValue, srcValue) => isArray(srcValue) ? srcValue : undefined); // { a: [{c: 3},{e: 5}] }
39
+ *
32
40
  */
33
41
  declare function merge<TObject, TSource>(object: TObject, source: TSource, customizer?: Customizer, getKeys?: GetKeysMethod): TObject & TSource;
42
+ declare namespace merge {
43
+ var NOT_MERGE_ARRAYS: (objValue: any, srcValue: any) => any[] | undefined;
44
+ }
34
45
  export default merge;