util-helpers 4.15.3 → 4.16.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 (53) hide show
  1. package/README.md +6 -5
  2. package/dist/util-helpers.js +452 -48
  3. package/dist/util-helpers.js.map +1 -1
  4. package/dist/util-helpers.min.js +1 -1
  5. package/dist/util-helpers.min.js.map +1 -1
  6. package/esm/ajax.js +149 -0
  7. package/esm/blobToDataURL.js +8 -12
  8. package/esm/dataURLToBlob.js +6 -5
  9. package/esm/download.js +156 -0
  10. package/esm/fileReader.js +67 -0
  11. package/esm/index.js +4 -1
  12. package/esm/interface.doc.js +124 -0
  13. package/esm/numberToChinese.js +3 -2
  14. package/esm/parseIdCard.js +1 -1
  15. package/esm/safeDate.js +26 -9
  16. package/esm/transformFieldNames.js +2 -3
  17. package/esm/utils/config.js +1 -1
  18. package/esm/utils/type/index.js +3 -1
  19. package/esm/utils/type/isArrayBuffer.js +25 -0
  20. package/esm/utils/type/isBlob.js +27 -0
  21. package/lib/ajax.js +156 -0
  22. package/lib/blobToDataURL.js +8 -12
  23. package/lib/dataURLToBlob.js +6 -5
  24. package/lib/download.js +161 -0
  25. package/lib/fileReader.js +74 -0
  26. package/lib/index.js +22 -1
  27. package/lib/interface.doc.js +126 -0
  28. package/lib/numberToChinese.js +3 -2
  29. package/lib/parseIdCard.js +1 -1
  30. package/lib/safeDate.js +27 -10
  31. package/lib/transformFieldNames.js +1 -1
  32. package/lib/utils/config.js +1 -1
  33. package/lib/utils/type/index.js +14 -0
  34. package/lib/utils/type/isArrayBuffer.js +32 -0
  35. package/lib/utils/type/isBlob.js +34 -0
  36. package/package.json +2 -2
  37. package/types/ajax.d.ts +121 -0
  38. package/types/blobToDataURL.d.ts +5 -1
  39. package/types/download.d.ts +77 -0
  40. package/types/fileReader.d.ts +3 -0
  41. package/types/index.d.ts +4 -1
  42. package/types/numberToChinese.d.ts +3 -2
  43. package/types/parseIdCard.d.ts +2 -2
  44. package/types/safeDate.d.ts +3 -23
  45. package/types/transformFieldNames.d.ts +2 -2
  46. package/types/utils/type/index.d.ts +21 -19
  47. package/types/utils/type/isArrayBuffer.d.ts +21 -0
  48. package/types/utils/type/isBlob.d.ts +23 -0
  49. package/esm/transformFieldNames.doc.js +0 -35
  50. package/lib/transformFieldNames.doc.js +0 -42
  51. /package/esm/{transformFieldNames.type.js → interface.type.js} +0 -0
  52. /package/lib/{transformFieldNames.type.js → interface.type.js} +0 -0
  53. /package/types/{transformFieldNames.type.d.ts → interface.type.d.ts} +0 -0
@@ -12,7 +12,7 @@ export default transformFieldNames;
12
12
  * @param {F} fieldNames 字段名映射
13
13
  * @param {C} [childrenField] 子级数据字段名
14
14
  * @param {'spread'|'self'} [nodeAssign='spread'] 节点赋值方式。spread表示使用展开运算符创建新值,self表示使用自身对象。
15
- * @returns {import('./transformFieldNames.type.js').TransformFieldNames<D, F, C>}
15
+ * @returns {import('./interface.type.js').TransformFieldNames<D, F, C>}
16
16
  * @example
17
17
  *
18
18
  * const options = [{code: '1', name: 'one'},{code:'2', name:'two'}];
@@ -32,4 +32,4 @@ export default transformFieldNames;
32
32
  * const newOptions4 = transformFieldNames(options3, {label: 'name', value: 'code', children: 'childs'}, 'childs');
33
33
  * // [{value: '1', label: 'one'},{value:'2', label:'two', children: [{value: '2-1', label:'two-one'}]}]
34
34
  */
35
- declare function transformFieldNames<D extends unknown, F extends Record<string, keyof D>, C extends string>(data: D[], fieldNames: F, childrenField?: C | undefined, nodeAssign?: "spread" | "self" | undefined): import("./transformFieldNames.type.js").TransformFieldNames<D, F, C>;
35
+ declare function transformFieldNames<D extends unknown, F extends Record<string, keyof D>, C extends string>(data: D[], fieldNames: F, childrenField?: C | undefined, nodeAssign?: "spread" | "self" | undefined): import("./interface.type.js").TransformFieldNames<D, F, C>;
@@ -1,19 +1,21 @@
1
- import isArguments from "./isArguments";
2
- import isArray from "./isArray";
3
- import isBoolean from "./isBoolean";
4
- import isDate from "./isDate";
5
- import isError from "./isError";
6
- import isFunction from "./isFunction";
7
- import isObject from "./isObject";
8
- import isNull from "./isNull";
9
- import isNaN from "./isNaN";
10
- import isNumber from "./isNumber";
11
- import isRegExp from "./isRegExp";
12
- import isString from "./isString";
13
- import isSymbol from "./isSymbol";
14
- import isMap from "./isMap";
15
- import isWeakMap from "./isWeakMap";
16
- import isSet from "./isSet";
17
- import isWeakSet from "./isWeakSet";
18
- import isUndefined from "./isUndefined";
19
- export { isArguments, isArray, isBoolean, isDate, isError, isFunction, isObject, isNull, isNaN, isNumber, isRegExp, isString, isSymbol, isMap, isWeakMap, isSet, isWeakSet, isUndefined };
1
+ import isArguments from './isArguments';
2
+ import isArray from './isArray';
3
+ import isArrayBuffer from './isArrayBuffer';
4
+ import isBlob from './isBlob';
5
+ import isBoolean from './isBoolean';
6
+ import isDate from './isDate';
7
+ import isError from './isError';
8
+ import isFunction from './isFunction';
9
+ import isObject from './isObject';
10
+ import isNull from './isNull';
11
+ import isNaN from './isNaN';
12
+ import isNumber from './isNumber';
13
+ import isRegExp from './isRegExp';
14
+ import isString from './isString';
15
+ import isSymbol from './isSymbol';
16
+ import isMap from './isMap';
17
+ import isWeakMap from './isWeakMap';
18
+ import isSet from './isSet';
19
+ import isWeakSet from './isWeakSet';
20
+ import isUndefined from './isUndefined';
21
+ export { isArguments, isArray, isArrayBuffer, isBlob, isBoolean, isDate, isError, isFunction, isObject, isNull, isNaN, isNumber, isRegExp, isString, isSymbol, isMap, isWeakMap, isSet, isWeakSet, isUndefined };
@@ -0,0 +1,21 @@
1
+ export default isArrayBuffer;
2
+ /**
3
+ * 检查值是否为ArrayBuffer对象
4
+ *
5
+ * @static
6
+ * @alias module:Type.isArrayBuffer
7
+ * @since 4.16.0
8
+ * @param {*} value 检查值
9
+ * @returns {boolean} 是否为ArrayBuffer对象
10
+ * @example
11
+ *
12
+ * isArrayBuffer(new ArrayBuffer(8))
13
+ * // => true
14
+ *
15
+ * isArrayBuffer({})
16
+ * // => false
17
+ *
18
+ * isArrayBuffer('2012')
19
+ * // => false
20
+ */
21
+ declare function isArrayBuffer(value: any): boolean;
@@ -0,0 +1,23 @@
1
+ export default isBlob;
2
+ /**
3
+ * 检查值是否为Blob对象<br/><br/>
4
+ *
5
+ * <em style="font-weight: bold;">注意:该方法仅适用于浏览器端。</em>
6
+ *
7
+ * @static
8
+ * @alias module:Type.isBlob
9
+ * @since 4.16.0
10
+ * @param {*} value 检查值
11
+ * @returns {boolean} 是否为Blob对象
12
+ * @example
13
+ *
14
+ * isBlob(new Blob(['a']))
15
+ * // => true
16
+ *
17
+ * isBlob({})
18
+ * // => false
19
+ *
20
+ * isBlob('2012')
21
+ * // => false
22
+ */
23
+ declare function isBlob(value: any): boolean;
@@ -1,35 +0,0 @@
1
- /* eslint-disable no-unused-vars */
2
- // 该文件用于 jsdoc 生成文件。因为一些 typescript 语法, jsdoc 不支持,导致生成文档报错。
3
-
4
- /**
5
- * 转换字段名,返回一个转换字段后的值,不改变原值。
6
- *
7
- * @static
8
- * @alias module:Tree.transformFieldNames
9
- * @since 4.14.0
10
- * @param {object[]} data 对象数组。如果是树结构数据,需要指定第三个参数 childrenField
11
- * @param {object} fieldNames 字段名映射
12
- * @param {string} [childrenField] 子级数据字段名
13
- * @param {'spread'|'self'} [nodeAssign='spread'] 节点赋值方式。spread表示使用展开运算符创建新值,self表示使用自身对象。
14
- * @returns {object[]}
15
- * @example
16
- *
17
- * const options = [{code: '1', name: 'one'},{code:'2', name:'two'}];
18
- * const newOptions = transformFieldNames(options, {label: 'name', value: 'code'});
19
- * // [{value: '1', label: 'one'},{value:'2', label:'two'}]
20
- *
21
- * // 嵌套数据,指定子级字段名 children
22
- * const options2 = [{code: '1', name: 'one'},{code:'2', name:'two', children: [{code:'2-1', name:'two-one', children: [{code: '2-1-1', name:'two-one-one'}]}]}];
23
- * const newOptions2 = transformFieldNames(options2, {label: 'name', value: 'code'}, 'children');
24
- * // [{value: '1', label: 'one'},{value:'2', label:'two', children: [{value: '2-1', label:'two-one', children: [{value: '2-1-1', label:'two-one-one'}]}]}]
25
- *
26
- * const options3 = [{code: '1', name: 'one'},{code:'2', name:'two', childs: [{code:'2-1', name:'two-one'}]}];
27
- * const newOptions3 = transformFieldNames(options3, {label: 'name', value: 'code'}, 'childs');
28
- * // [{value: '1', label: 'one'},{value:'2', label:'two', childs: [{value: '2-1', label:'two-one'}]}]
29
- *
30
- * // 嵌套数据,并替换子集字段名
31
- * const newOptions4 = transformFieldNames(options3, {label: 'name', value: 'code', children: 'childs'}, 'childs');
32
- * // [{value: '1', label: 'one'},{value:'2', label:'two', children: [{value: '2-1', label:'two-one'}]}]
33
- */
34
- function transformFieldNames(data, fieldNames, childrenField) {}
35
- export default transformFieldNames;
@@ -1,42 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- /* eslint-disable no-unused-vars */
8
- // 该文件用于 jsdoc 生成文件。因为一些 typescript 语法, jsdoc 不支持,导致生成文档报错。
9
-
10
- /**
11
- * 转换字段名,返回一个转换字段后的值,不改变原值。
12
- *
13
- * @static
14
- * @alias module:Tree.transformFieldNames
15
- * @since 4.14.0
16
- * @param {object[]} data 对象数组。如果是树结构数据,需要指定第三个参数 childrenField
17
- * @param {object} fieldNames 字段名映射
18
- * @param {string} [childrenField] 子级数据字段名
19
- * @param {'spread'|'self'} [nodeAssign='spread'] 节点赋值方式。spread表示使用展开运算符创建新值,self表示使用自身对象。
20
- * @returns {object[]}
21
- * @example
22
- *
23
- * const options = [{code: '1', name: 'one'},{code:'2', name:'two'}];
24
- * const newOptions = transformFieldNames(options, {label: 'name', value: 'code'});
25
- * // [{value: '1', label: 'one'},{value:'2', label:'two'}]
26
- *
27
- * // 嵌套数据,指定子级字段名 children
28
- * const options2 = [{code: '1', name: 'one'},{code:'2', name:'two', children: [{code:'2-1', name:'two-one', children: [{code: '2-1-1', name:'two-one-one'}]}]}];
29
- * const newOptions2 = transformFieldNames(options2, {label: 'name', value: 'code'}, 'children');
30
- * // [{value: '1', label: 'one'},{value:'2', label:'two', children: [{value: '2-1', label:'two-one', children: [{value: '2-1-1', label:'two-one-one'}]}]}]
31
- *
32
- * const options3 = [{code: '1', name: 'one'},{code:'2', name:'two', childs: [{code:'2-1', name:'two-one'}]}];
33
- * const newOptions3 = transformFieldNames(options3, {label: 'name', value: 'code'}, 'childs');
34
- * // [{value: '1', label: 'one'},{value:'2', label:'two', childs: [{value: '2-1', label:'two-one'}]}]
35
- *
36
- * // 嵌套数据,并替换子集字段名
37
- * const newOptions4 = transformFieldNames(options3, {label: 'name', value: 'code', children: 'childs'}, 'childs');
38
- * // [{value: '1', label: 'one'},{value:'2', label:'two', children: [{value: '2-1', label:'two-one'}]}]
39
- */
40
- function transformFieldNames(data, fieldNames, childrenField) {}
41
- var _default = transformFieldNames;
42
- exports["default"] = _default;