util-helpers 4.16.2 → 4.17.1
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/dist/util-helpers.js +1600 -4039
- package/dist/util-helpers.js.map +1 -1
- package/dist/util-helpers.min.js +1 -1
- package/dist/util-helpers.min.js.map +1 -1
- package/esm/ajax.js +50 -146
- package/esm/blobToDataURL.js +4 -34
- package/esm/bytesToSize.js +12 -37
- package/esm/calculateCursorPosition.js +30 -52
- package/esm/dataURLToBlob.js +14 -28
- package/esm/divide.js +24 -48
- package/esm/download.js +83 -164
- package/esm/fileReader.js +18 -64
- package/esm/filterTree.js +25 -55
- package/esm/findTreeNode.js +39 -67
- package/esm/findTreeNodes.js +35 -66
- package/esm/findTreeSelect.js +38 -74
- package/esm/formatBankCard.js +13 -43
- package/esm/formatMobile.js +17 -43
- package/esm/formatMoney.js +59 -139
- package/esm/index.js +55 -130
- package/esm/isBankCard.js +22 -57
- package/esm/isBusinessLicense.js +32 -78
- package/esm/isChinese.js +23 -66
- package/esm/isEmail.js +6 -21
- package/esm/isHMCard.js +5 -28
- package/esm/isIPv4.js +5 -22
- package/esm/isIPv6.js +5 -36
- package/esm/isIdCard.js +27 -66
- package/esm/isMobile.js +5 -20
- package/esm/isPassport.js +5 -22
- package/esm/isPassword.js +7 -48
- package/esm/isPostcode.js +5 -20
- package/esm/isPromiseLike.js +3 -18
- package/esm/isQQ.js +5 -20
- package/esm/isSocialCreditCode.js +28 -83
- package/esm/isSwiftCode.js +6 -25
- package/esm/isTWCard.js +11 -37
- package/esm/isTelephone.js +6 -27
- package/esm/isUrl.js +5 -44
- package/esm/isVehicle.js +5 -28
- package/esm/isWX.js +5 -20
- package/esm/listToTree.js +51 -120
- package/esm/minus.js +21 -39
- package/esm/normalizeString.js +8 -29
- package/esm/numberToChinese.js +96 -215
- package/esm/padZero.js +14 -36
- package/esm/parseIdCard.js +64 -129
- package/esm/plus.js +21 -39
- package/esm/randomString.js +13 -45
- package/esm/replaceChar.js +27 -77
- package/esm/round.js +14 -31
- package/esm/safeDate.js +12 -55
- package/esm/setDataURLPrefix.js +6 -29
- package/esm/strlen.js +14 -30
- package/esm/times.js +24 -42
- package/esm/transformFieldNames.js +37 -93
- package/esm/treeToList.js +25 -84
- package/esm/utils/config.js +4 -14
- package/esm/utils/constants.js +4 -4
- package/esm/utils/convertToString.js +4 -9
- package/esm/utils/devWarn.js +11 -11
- package/esm/utils/math.util.js +95 -181
- package/esm/utils/type/isBlob.js +4 -24
- package/esm/utils/type/isNaN.js +4 -19
- package/esm/utils/type/isNil.js +5 -13
- package/esm/utils/type/isNull.js +3 -18
- package/esm/utils/type/isNumber.js +4 -28
- package/esm/utils/type/isObject.js +4 -23
- package/esm/utils/type/isString.js +4 -19
- package/esm/utils/type/isSymbol.js +4 -19
- package/esm/utils/type/isType.js +3 -12
- package/esm/utils/type/isUndefined.js +3 -21
- package/esm/validatePassword.js +86 -237
- package/esm/waitTime.js +7 -26
- package/lib/ajax.js +51 -152
- package/lib/blobToDataURL.js +5 -40
- package/lib/bytesToSize.js +13 -43
- package/lib/calculateCursorPosition.js +32 -58
- package/lib/dataURLToBlob.js +15 -34
- package/lib/divide.js +26 -60
- package/lib/download.js +85 -169
- package/lib/fileReader.js +19 -70
- package/lib/filterTree.js +27 -66
- package/lib/findTreeNode.js +40 -77
- package/lib/findTreeNodes.js +36 -76
- package/lib/findTreeSelect.js +40 -82
- package/lib/formatBankCard.js +15 -50
- package/lib/formatMobile.js +19 -50
- package/lib/formatMoney.js +60 -150
- package/lib/index.js +117 -395
- package/lib/isBankCard.js +24 -64
- package/lib/isBusinessLicense.js +34 -85
- package/lib/isChinese.js +24 -73
- package/lib/isEmail.js +7 -27
- package/lib/isHMCard.js +7 -35
- package/lib/isIPv4.js +7 -29
- package/lib/isIPv6.js +7 -43
- package/lib/isIdCard.js +29 -73
- package/lib/isMobile.js +7 -27
- package/lib/isPassport.js +7 -29
- package/lib/isPassword.js +9 -55
- package/lib/isPostcode.js +7 -27
- package/lib/isPromiseLike.js +4 -24
- package/lib/isQQ.js +7 -27
- package/lib/isSocialCreditCode.js +30 -90
- package/lib/isSwiftCode.js +7 -32
- package/lib/isTWCard.js +13 -44
- package/lib/isTelephone.js +7 -33
- package/lib/isUrl.js +6 -49
- package/lib/isVehicle.js +7 -35
- package/lib/isWX.js +7 -27
- package/lib/listToTree.js +53 -131
- package/lib/minus.js +23 -51
- package/lib/normalizeString.js +10 -36
- package/lib/numberToChinese.js +98 -222
- package/lib/padZero.js +16 -43
- package/lib/parseIdCard.js +65 -138
- package/lib/plus.js +23 -51
- package/lib/randomString.js +14 -51
- package/lib/replaceChar.js +28 -83
- package/lib/round.js +15 -37
- package/lib/safeDate.js +13 -63
- package/lib/setDataURLPrefix.js +7 -35
- package/lib/strlen.js +16 -37
- package/lib/times.js +26 -53
- package/lib/transformFieldNames.js +38 -101
- package/lib/treeToList.js +27 -94
- package/lib/utils/config.js +6 -23
- package/lib/utils/constants.js +3 -11
- package/lib/utils/convertToString.js +6 -16
- package/lib/utils/devWarn.js +13 -17
- package/lib/utils/math.util.js +95 -185
- package/lib/utils/type/isBlob.js +6 -31
- package/lib/utils/type/isNaN.js +6 -26
- package/lib/utils/type/isNil.js +7 -20
- package/lib/utils/type/isNull.js +4 -24
- package/lib/utils/type/isNumber.js +6 -35
- package/lib/utils/type/isObject.js +5 -29
- package/lib/utils/type/isString.js +6 -26
- package/lib/utils/type/isSymbol.js +6 -26
- package/lib/utils/type/isType.js +4 -18
- package/lib/utils/type/isUndefined.js +4 -27
- package/lib/validatePassword.js +87 -244
- package/lib/waitTime.js +8 -32
- package/package.json +21 -25
- package/types/ajax.d.ts +38 -95
- package/types/blobToDataURL.d.ts +2 -2
- package/types/bytesToSize.d.ts +7 -6
- package/types/calculateCursorPosition.d.ts +10 -9
- package/types/dataURLToBlob.d.ts +5 -5
- package/types/divide.d.ts +2 -2
- package/types/download.d.ts +22 -38
- package/types/fileReader.d.ts +35 -2
- package/types/filterTree.d.ts +6 -7
- package/types/findTreeNode.d.ts +5 -7
- package/types/findTreeNodes.d.ts +5 -7
- package/types/findTreeSelect.d.ts +5 -7
- package/types/formatBankCard.d.ts +8 -5
- package/types/formatMobile.d.ts +7 -4
- package/types/formatMoney.d.ts +8 -7
- package/types/index.d.ts +125 -55
- package/types/isBankCard.d.ts +9 -8
- package/types/isBusinessLicense.d.ts +8 -5
- package/types/isChinese.d.ts +9 -8
- package/types/isEmail.d.ts +1 -1
- package/types/isHMCard.d.ts +2 -2
- package/types/isIPv4.d.ts +1 -1
- package/types/isIPv6.d.ts +1 -1
- package/types/isIdCard.d.ts +8 -7
- package/types/isMobile.d.ts +1 -1
- package/types/isPassport.d.ts +2 -2
- package/types/isPassword.d.ts +4 -7
- package/types/isPostcode.d.ts +1 -1
- package/types/isPromiseLike.d.ts +1 -1
- package/types/isQQ.d.ts +1 -1
- package/types/isSocialCreditCode.d.ts +8 -5
- package/types/isSwiftCode.d.ts +2 -2
- package/types/isTWCard.d.ts +6 -5
- package/types/isTelephone.d.ts +1 -1
- package/types/isUrl.d.ts +2 -2
- package/types/isVehicle.d.ts +2 -2
- package/types/isWX.d.ts +1 -1
- package/types/listToTree.d.ts +12 -12
- package/types/minus.d.ts +3 -2
- package/types/normalizeString.d.ts +2 -2
- package/types/numberToChinese.d.ts +13 -12
- package/types/padZero.d.ts +2 -2
- package/types/parseIdCard.d.ts +17 -56
- package/types/plus.d.ts +3 -2
- package/types/randomString.d.ts +2 -2
- package/types/replaceChar.d.ts +15 -11
- package/types/round.d.ts +2 -2
- package/types/safeDate.d.ts +24 -2
- package/types/setDataURLPrefix.d.ts +5 -5
- package/types/strlen.d.ts +1 -1
- package/types/times.d.ts +3 -2
- package/types/transformFieldNames.d.ts +12 -10
- package/types/treeToList.d.ts +1 -1
- package/types/utils/config.d.ts +6 -5
- package/types/utils/constants.d.ts +2 -2
- package/types/utils/convertToString.d.ts +1 -1
- package/types/utils/devWarn.d.ts +1 -1
- package/types/utils/math.util.d.ts +15 -9
- package/types/utils/type/index.d.ts +7 -0
- package/types/utils/type/isArguments.d.ts +1 -1
- package/types/utils/type/isArray.d.ts +1 -1
- package/types/utils/type/isArrayBuffer.d.ts +1 -1
- package/types/utils/type/isBlob.d.ts +1 -1
- package/types/utils/type/isBoolean.d.ts +1 -1
- package/types/utils/type/isDate.d.ts +1 -1
- package/types/utils/type/isError.d.ts +1 -1
- package/types/utils/type/isFunction.d.ts +1 -1
- package/types/utils/type/isMap.d.ts +1 -1
- package/types/utils/type/isNaN.d.ts +1 -1
- package/types/utils/type/isNil.d.ts +1 -1
- package/types/utils/type/isNull.d.ts +1 -1
- package/types/utils/type/isNumber.d.ts +1 -1
- package/types/utils/type/isObject.d.ts +1 -1
- package/types/utils/type/isRegExp.d.ts +1 -1
- package/types/utils/type/isSet.d.ts +1 -1
- package/types/utils/type/isString.d.ts +1 -1
- package/types/utils/type/isSymbol.d.ts +1 -1
- package/types/utils/type/isType.d.ts +1 -1
- package/types/utils/type/isUndefined.d.ts +1 -1
- package/types/utils/type/isWeakMap.d.ts +1 -1
- package/types/utils/type/isWeakSet.d.ts +1 -1
- package/types/validatePassword.d.ts +17 -48
- package/types/waitTime.d.ts +2 -2
- package/esm/interface.doc.js +0 -125
- package/esm/interface.type.js +0 -17
- package/esm/utils/type/index.js +0 -29
- package/esm/utils/type/isArguments.js +0 -22
- package/esm/utils/type/isArray.js +0 -22
- package/esm/utils/type/isArrayBuffer.js +0 -25
- package/esm/utils/type/isBoolean.js +0 -22
- package/esm/utils/type/isDate.js +0 -22
- package/esm/utils/type/isError.js +0 -22
- package/esm/utils/type/isFunction.js +0 -22
- package/esm/utils/type/isMap.js +0 -22
- package/esm/utils/type/isRegExp.js +0 -22
- package/esm/utils/type/isSet.js +0 -22
- package/esm/utils/type/isWeakMap.js +0 -22
- package/esm/utils/type/isWeakSet.js +0 -22
- package/lib/interface.doc.js +0 -127
- package/lib/interface.type.js +0 -5
- package/lib/utils/type/index.js +0 -146
- package/lib/utils/type/isArguments.js +0 -29
- package/lib/utils/type/isArray.js +0 -29
- package/lib/utils/type/isArrayBuffer.js +0 -32
- package/lib/utils/type/isBoolean.js +0 -29
- package/lib/utils/type/isDate.js +0 -29
- package/lib/utils/type/isError.js +0 -29
- package/lib/utils/type/isFunction.js +0 -29
- package/lib/utils/type/isMap.js +0 -29
- package/lib/utils/type/isRegExp.js +0 -29
- package/lib/utils/type/isSet.js +0 -29
- package/lib/utils/type/isWeakMap.js +0 -29
- package/lib/utils/type/isWeakSet.js +0 -29
- package/types/interface.type.d.ts +0 -2
package/esm/interface.doc.js
DELETED
|
@@ -1,125 +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
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @see {@link https://developer.mozilla.org/zh-CN/docs/Web/API/XMLHttpRequest|XMLHttpRequest}
|
|
38
|
-
* @typedef {Object} AjaxOptions ajax配置项
|
|
39
|
-
* @property {string} [method="get"] 创建请求时使用的方法
|
|
40
|
-
* @property {*} [data=null] 请求体被发送的数据
|
|
41
|
-
* @property {object} [headers] 自定义请求头
|
|
42
|
-
* @property {string} [responseType] 响应类型
|
|
43
|
-
* @property {number} [timeout] 请求超时的毫秒数
|
|
44
|
-
* @property {boolean} [withCredentials=false] 跨域请求时是否需要使用凭证
|
|
45
|
-
* @property {boolean} [async=true] 是否异步执行操作
|
|
46
|
-
* @property {string|null} [user=null] 用户名,用于认证用途
|
|
47
|
-
* @property {string|null} [password=null] 密码,用于认证用途
|
|
48
|
-
* @property {function} [onLoadStart] 接收到响应数据时触发
|
|
49
|
-
* @property {function} [onProgress] 请求接收到更多数据时,周期性地触发
|
|
50
|
-
* @property {function} [onAbort] 当 request 被停止时触发,例如当程序调用 XMLHttpRequest.abort() 时
|
|
51
|
-
* @property {function} [onTimeout] 在预设时间内没有接收到响应时触发
|
|
52
|
-
* @property {function} [onError] 当 request 遭遇错误时触发
|
|
53
|
-
* @property {function} [onLoad] 请求成功完成时触发
|
|
54
|
-
* @property {function} [onLoadEnd] 请求结束时触发,无论请求成功 (load) 还是失败 (abort 或 error)
|
|
55
|
-
*/
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* 请求<br/><br/>
|
|
59
|
-
*
|
|
60
|
-
* <em style="font-weight: bold;">注意:该方法仅适用于浏览器端。</em>
|
|
61
|
-
*
|
|
62
|
-
* @static
|
|
63
|
-
* @alias module:Other.ajax
|
|
64
|
-
* @since 4.16.0
|
|
65
|
-
* @see {@link https://developer.mozilla.org/zh-CN/docs/Web/API/XMLHttpRequest|XMLHttpRequest}
|
|
66
|
-
* @param {string} url 地址
|
|
67
|
-
* @param {AjaxOptions} [options] 配置项
|
|
68
|
-
* @returns {Promise<object>} XHR 事件对象
|
|
69
|
-
* @example
|
|
70
|
-
* ajax('/somefile').then(res=>{
|
|
71
|
-
* // do something
|
|
72
|
-
* });
|
|
73
|
-
*
|
|
74
|
-
* ajax('/api', { method: 'post' }).then(res=>{
|
|
75
|
-
* // do something
|
|
76
|
-
* });
|
|
77
|
-
*/
|
|
78
|
-
function ajax(url, options) {}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* @callback TransformRequest
|
|
82
|
-
* @param {AjaxOptions} options ajax 配置项
|
|
83
|
-
* @returns {AjaxOptions | Promise<AjaxOptions>}
|
|
84
|
-
*/
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* @callback TransformResponse
|
|
88
|
-
* @param {Blob} res 响应的Blob对象。如果你通过 transformRequest 修改了 responseType ,该参数将是该类型响应值。
|
|
89
|
-
* @returns {Blob | Promise<Blob>}
|
|
90
|
-
*/
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* @typedef {Object} DownloadOptions 下载配置项
|
|
94
|
-
* @property {string} [options.fileName] 文件名称
|
|
95
|
-
* @property {string} [options.type] MIME 类型
|
|
96
|
-
* @property {'url'|'text'} [options.dataType] 手动设置数据类型,默认会根据传入的数据判断类型,主要是为了区分 url 和 text 。<br/>如果你要下载的文本是 url ,请设置 'text' ;如果你要下载的 url 是绝对/相对路径,请设置 'url' 。
|
|
97
|
-
* @property {TransformRequest} [options.transformRequest] 请求前触发,XHR 对象或配置调整
|
|
98
|
-
* @property {TransformResponse} [options.transformResponse] 请求成功后触发,在传递给 then/catch 前,允许修改响应数据
|
|
99
|
-
*/
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* 下载<br/><br/>
|
|
103
|
-
*
|
|
104
|
-
* <em style="font-weight: bold;">注意:该方法仅适用于浏览器端,兼容 IE10+ 和现代浏览器。</em>
|
|
105
|
-
*
|
|
106
|
-
* @static
|
|
107
|
-
* @alias module:Other.download
|
|
108
|
-
* @since 4.16.0
|
|
109
|
-
* @see {@link https://zh.wikipedia.org/wiki/多用途互聯網郵件擴展|MIME}
|
|
110
|
-
* @see {@link https://9ykc9s.csb.app/|在线示例}
|
|
111
|
-
* @param {string|Blob|TypedArray} data 字符串、blob数据或url地址
|
|
112
|
-
* @param {string|DownloadOptions} [options] 文件名称 或 配置项
|
|
113
|
-
* @returns {Promise<void>}
|
|
114
|
-
* @example
|
|
115
|
-
* // 文本
|
|
116
|
-
* download('hello world', 'text.txt');
|
|
117
|
-
*
|
|
118
|
-
* // 远程文件
|
|
119
|
-
* download('/xxx.jpg', { dataType: 'url' });
|
|
120
|
-
*
|
|
121
|
-
* // blob文件
|
|
122
|
-
* download(new Blob(['hello world']), 'text.txt');
|
|
123
|
-
*
|
|
124
|
-
*/
|
|
125
|
-
function download(data, fileName, options) {}
|
package/esm/interface.type.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// 交换字段名
|
|
2
|
-
/**
|
|
3
|
-
* @template {*} D
|
|
4
|
-
* @template {Record<string, keyof D>} F
|
|
5
|
-
* @typedef {Omit<D, F[keyof F]> & { [P in keyof F]: D[F[P]] }} ExchangeFieldNames
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
// 交换字段名,支持嵌套
|
|
9
|
-
// 先排除子级字段名,再交换字段名,然后加上子级字段名,再替换一次。
|
|
10
|
-
/**
|
|
11
|
-
* @template {*} D
|
|
12
|
-
* @template {Record<string, any>} F
|
|
13
|
-
* @template {string} C
|
|
14
|
-
* @typedef {(C extends keyof D ? ExchangeFieldNames<Omit<D, C> & Record<C, TransformFieldNames<D, F, C>>, F> : ExchangeFieldNames<D, F>)[]} TransformFieldNames
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
export {};
|
package/esm/utils/type/index.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
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
|
-
|
|
22
|
-
/**
|
|
23
|
-
* 类型检测
|
|
24
|
-
*
|
|
25
|
-
* @module Type
|
|
26
|
-
* @ignore
|
|
27
|
-
* @since 1.1.0
|
|
28
|
-
*/
|
|
29
|
-
export { isArguments, isArray, isArrayBuffer, isBlob, isBoolean, isDate, isError, isFunction, isObject, isNull, isNaN, isNumber, isRegExp, isString, isSymbol, isMap, isWeakMap, isSet, isWeakSet, isUndefined };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import isType from './isType';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 检查值是否为Arguments
|
|
5
|
-
*
|
|
6
|
-
* @static
|
|
7
|
-
* @alias module:Type.isArguments
|
|
8
|
-
* @since 1.1.0
|
|
9
|
-
* @param {*} value 检查值
|
|
10
|
-
* @returns {boolean} 是否为Arguments
|
|
11
|
-
* @example
|
|
12
|
-
*
|
|
13
|
-
* isArguments(function() { return arguments }())
|
|
14
|
-
* // => true
|
|
15
|
-
*
|
|
16
|
-
* isArguments([1, 2, 3])
|
|
17
|
-
* // => false
|
|
18
|
-
*/
|
|
19
|
-
function isArguments(value) {
|
|
20
|
-
return isType(value, 'Arguments');
|
|
21
|
-
}
|
|
22
|
-
export default isArguments;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import isType from './isType';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 检查值是否为Array
|
|
5
|
-
*
|
|
6
|
-
* @static
|
|
7
|
-
* @alias module:Type.isArray
|
|
8
|
-
* @since 1.1.0
|
|
9
|
-
* @param {*} value 检查值
|
|
10
|
-
* @returns {boolean} 是否为Array
|
|
11
|
-
* @example
|
|
12
|
-
*
|
|
13
|
-
* isArray([])
|
|
14
|
-
* // => true
|
|
15
|
-
*
|
|
16
|
-
* isArray(1)
|
|
17
|
-
* // => false
|
|
18
|
-
*/
|
|
19
|
-
function isArray(value) {
|
|
20
|
-
return Array.isArray(value) || isType(value, 'Array');
|
|
21
|
-
}
|
|
22
|
-
export default isArray;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import isType from './isType';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 检查值是否为ArrayBuffer对象
|
|
5
|
-
*
|
|
6
|
-
* @static
|
|
7
|
-
* @alias module:Type.isArrayBuffer
|
|
8
|
-
* @since 4.16.0
|
|
9
|
-
* @param {*} value 检查值
|
|
10
|
-
* @returns {boolean} 是否为ArrayBuffer对象
|
|
11
|
-
* @example
|
|
12
|
-
*
|
|
13
|
-
* isArrayBuffer(new ArrayBuffer(8))
|
|
14
|
-
* // => true
|
|
15
|
-
*
|
|
16
|
-
* isArrayBuffer({})
|
|
17
|
-
* // => false
|
|
18
|
-
*
|
|
19
|
-
* isArrayBuffer('2012')
|
|
20
|
-
* // => false
|
|
21
|
-
*/
|
|
22
|
-
function isArrayBuffer(value) {
|
|
23
|
-
return isType(value, 'ArrayBuffer');
|
|
24
|
-
}
|
|
25
|
-
export default isArrayBuffer;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import isType from './isType';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 检查值是否为Boolean
|
|
5
|
-
*
|
|
6
|
-
* @static
|
|
7
|
-
* @alias module:Type.isBoolean
|
|
8
|
-
* @since 1.1.0
|
|
9
|
-
* @param {*} value 检查值
|
|
10
|
-
* @returns {boolean} 是否为Boolean
|
|
11
|
-
* @example
|
|
12
|
-
*
|
|
13
|
-
* isBoolean(false)
|
|
14
|
-
* // => true
|
|
15
|
-
*
|
|
16
|
-
* isBoolean(null)
|
|
17
|
-
* // => false
|
|
18
|
-
*/
|
|
19
|
-
function isBoolean(value) {
|
|
20
|
-
return value === true || value === false || isType(value, 'Boolean');
|
|
21
|
-
}
|
|
22
|
-
export default isBoolean;
|
package/esm/utils/type/isDate.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import isType from './isType';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 检查值是否为Date
|
|
5
|
-
*
|
|
6
|
-
* @static
|
|
7
|
-
* @alias module:Type.isDate
|
|
8
|
-
* @since 1.1.0
|
|
9
|
-
* @param {*} value 检查值
|
|
10
|
-
* @returns {boolean} 是否为Date
|
|
11
|
-
* @example
|
|
12
|
-
*
|
|
13
|
-
* isDate(new Date)
|
|
14
|
-
* // => true
|
|
15
|
-
*
|
|
16
|
-
* isDate('Mon April 23 2012')
|
|
17
|
-
* // => false
|
|
18
|
-
*/
|
|
19
|
-
function isDate(value) {
|
|
20
|
-
return isType(value, 'Date');
|
|
21
|
-
}
|
|
22
|
-
export default isDate;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import isType from './isType';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 检查值是否为Error、EvalError、RangeError、ReferenceError、SyntaxError、TypeError、URIError|DOMException
|
|
5
|
-
*
|
|
6
|
-
* @static
|
|
7
|
-
* @alias module:Type.isError
|
|
8
|
-
* @since 1.1.0
|
|
9
|
-
* @param {*} value 检查值
|
|
10
|
-
* @returns {boolean} 是否为Error、EvalError、RangeError、ReferenceError、SyntaxError、TypeError、URIError|DOMException
|
|
11
|
-
* @example
|
|
12
|
-
*
|
|
13
|
-
* isError(new Error)
|
|
14
|
-
* // => true
|
|
15
|
-
*
|
|
16
|
-
* isError(Error)
|
|
17
|
-
* // => false
|
|
18
|
-
*/
|
|
19
|
-
function isError(value) {
|
|
20
|
-
return isType(value, 'Error') || isType(value, 'DOMException');
|
|
21
|
-
}
|
|
22
|
-
export default isError;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import isType from './isType';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 检查值是否为Function|AsyncFunction|GeneratorFunction|Proxy
|
|
5
|
-
*
|
|
6
|
-
* @static
|
|
7
|
-
* @alias module:Type.isFunction
|
|
8
|
-
* @since 1.1.0
|
|
9
|
-
* @param {*} value 检查值
|
|
10
|
-
* @returns {boolean} 是否为Function|AsyncFunction|GeneratorFunction|Proxy
|
|
11
|
-
* @example
|
|
12
|
-
*
|
|
13
|
-
* isFunction(()=>{}))
|
|
14
|
-
* // => true
|
|
15
|
-
*
|
|
16
|
-
* isFunction(/abc/)
|
|
17
|
-
* // => false
|
|
18
|
-
*/
|
|
19
|
-
function isFunction(value) {
|
|
20
|
-
return isType(value, 'Function') || isType(value, 'AsyncFunction') || isType(value, 'GeneratorFunction') || isType(value, 'Proxy');
|
|
21
|
-
}
|
|
22
|
-
export default isFunction;
|
package/esm/utils/type/isMap.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import isType from './isType';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 检查值是否为Map
|
|
5
|
-
*
|
|
6
|
-
* @static
|
|
7
|
-
* @alias module:Type.isMap
|
|
8
|
-
* @since 1.1.0
|
|
9
|
-
* @param {*} value 检查值
|
|
10
|
-
* @returns {boolean} 是否为Map
|
|
11
|
-
* @example
|
|
12
|
-
*
|
|
13
|
-
* isMap(new Map)
|
|
14
|
-
* // => true
|
|
15
|
-
*
|
|
16
|
-
* isMap(new WeakMap)
|
|
17
|
-
* // => false
|
|
18
|
-
*/
|
|
19
|
-
function isMap(value) {
|
|
20
|
-
return isType(value, 'Map');
|
|
21
|
-
}
|
|
22
|
-
export default isMap;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import isType from './isType';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 检查值是否为RegExp
|
|
5
|
-
*
|
|
6
|
-
* @static
|
|
7
|
-
* @alias module:Type.isRegExp
|
|
8
|
-
* @since 1.1.0
|
|
9
|
-
* @param {*} value 检查值
|
|
10
|
-
* @returns {boolean} 是否为RegExp
|
|
11
|
-
* @example
|
|
12
|
-
*
|
|
13
|
-
* isRegExp(/abc/)
|
|
14
|
-
* // => true
|
|
15
|
-
*
|
|
16
|
-
* isRegExp('/abc/')
|
|
17
|
-
* // => false
|
|
18
|
-
*/
|
|
19
|
-
function isRegExp(value) {
|
|
20
|
-
return isType(value, 'RegExp');
|
|
21
|
-
}
|
|
22
|
-
export default isRegExp;
|
package/esm/utils/type/isSet.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import isType from './isType';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 检查值是否为Set
|
|
5
|
-
*
|
|
6
|
-
* @static
|
|
7
|
-
* @alias module:Type.isSet
|
|
8
|
-
* @since 1.1.0
|
|
9
|
-
* @param {*} value 检查值
|
|
10
|
-
* @returns {boolean} 是否为Set
|
|
11
|
-
* @example
|
|
12
|
-
*
|
|
13
|
-
* isSet(new Set)
|
|
14
|
-
* // => true
|
|
15
|
-
*
|
|
16
|
-
* isSet(new WeakSet)
|
|
17
|
-
* // => false
|
|
18
|
-
*/
|
|
19
|
-
function isSet(value) {
|
|
20
|
-
return isType(value, 'Set');
|
|
21
|
-
}
|
|
22
|
-
export default isSet;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import isType from './isType';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 检查值是否为WeakMap
|
|
5
|
-
*
|
|
6
|
-
* @static
|
|
7
|
-
* @alias module:Type.isWeakMap
|
|
8
|
-
* @since 1.1.0
|
|
9
|
-
* @param {*} value 检查值
|
|
10
|
-
* @returns {boolean} 是否为WeakMap
|
|
11
|
-
* @example
|
|
12
|
-
*
|
|
13
|
-
* isWeakMap(new WeakMap)
|
|
14
|
-
* // => true
|
|
15
|
-
*
|
|
16
|
-
* isWeakMap(new Map)
|
|
17
|
-
* // => false
|
|
18
|
-
*/
|
|
19
|
-
function isWeakMap(value) {
|
|
20
|
-
return isType(value, 'WeakMap');
|
|
21
|
-
}
|
|
22
|
-
export default isWeakMap;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import isType from './isType';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 检查值是否为WeakSet
|
|
5
|
-
*
|
|
6
|
-
* @static
|
|
7
|
-
* @alias module:Type.isWeakSet
|
|
8
|
-
* @since 1.1.0
|
|
9
|
-
* @param {*} value 检查值
|
|
10
|
-
* @returns {boolean} 是否为WeakSet
|
|
11
|
-
* @example
|
|
12
|
-
*
|
|
13
|
-
* isWeakSet(new WeakSet)
|
|
14
|
-
* // => true
|
|
15
|
-
*
|
|
16
|
-
* isWeakSet(new Set)
|
|
17
|
-
* // => false
|
|
18
|
-
*/
|
|
19
|
-
function isWeakSet(value) {
|
|
20
|
-
return isType(value, 'WeakSet');
|
|
21
|
-
}
|
|
22
|
-
export default isWeakSet;
|
package/lib/interface.doc.js
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/* eslint-disable no-unused-vars */
|
|
4
|
-
// 该文件用于 jsdoc 生成文件。因为一些 typescript 语法, jsdoc 不支持,导致生成文档报错。
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* 转换字段名,返回一个转换字段后的值,不改变原值。
|
|
8
|
-
*
|
|
9
|
-
* @static
|
|
10
|
-
* @alias module:Tree.transformFieldNames
|
|
11
|
-
* @since 4.14.0
|
|
12
|
-
* @param {object[]} data 对象数组。如果是树结构数据,需要指定第三个参数 childrenField
|
|
13
|
-
* @param {object} fieldNames 字段名映射
|
|
14
|
-
* @param {string} [childrenField] 子级数据字段名
|
|
15
|
-
* @param {'spread'|'self'} [nodeAssign='spread'] 节点赋值方式。spread表示使用展开运算符创建新值,self表示使用自身对象。
|
|
16
|
-
* @returns {object[]}
|
|
17
|
-
* @example
|
|
18
|
-
*
|
|
19
|
-
* const options = [{code: '1', name: 'one'},{code:'2', name:'two'}];
|
|
20
|
-
* const newOptions = transformFieldNames(options, {label: 'name', value: 'code'});
|
|
21
|
-
* // [{value: '1', label: 'one'},{value:'2', label:'two'}]
|
|
22
|
-
*
|
|
23
|
-
* // 嵌套数据,指定子级字段名 children
|
|
24
|
-
* 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'}]}]}];
|
|
25
|
-
* const newOptions2 = transformFieldNames(options2, {label: 'name', value: 'code'}, 'children');
|
|
26
|
-
* // [{value: '1', label: 'one'},{value:'2', label:'two', children: [{value: '2-1', label:'two-one', children: [{value: '2-1-1', label:'two-one-one'}]}]}]
|
|
27
|
-
*
|
|
28
|
-
* const options3 = [{code: '1', name: 'one'},{code:'2', name:'two', childs: [{code:'2-1', name:'two-one'}]}];
|
|
29
|
-
* const newOptions3 = transformFieldNames(options3, {label: 'name', value: 'code'}, 'childs');
|
|
30
|
-
* // [{value: '1', label: 'one'},{value:'2', label:'two', childs: [{value: '2-1', label:'two-one'}]}]
|
|
31
|
-
*
|
|
32
|
-
* // 嵌套数据,并替换子集字段名
|
|
33
|
-
* const newOptions4 = transformFieldNames(options3, {label: 'name', value: 'code', children: 'childs'}, 'childs');
|
|
34
|
-
* // [{value: '1', label: 'one'},{value:'2', label:'two', children: [{value: '2-1', label:'two-one'}]}]
|
|
35
|
-
*/
|
|
36
|
-
function transformFieldNames(data, fieldNames, childrenField) {}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* @see {@link https://developer.mozilla.org/zh-CN/docs/Web/API/XMLHttpRequest|XMLHttpRequest}
|
|
40
|
-
* @typedef {Object} AjaxOptions ajax配置项
|
|
41
|
-
* @property {string} [method="get"] 创建请求时使用的方法
|
|
42
|
-
* @property {*} [data=null] 请求体被发送的数据
|
|
43
|
-
* @property {object} [headers] 自定义请求头
|
|
44
|
-
* @property {string} [responseType] 响应类型
|
|
45
|
-
* @property {number} [timeout] 请求超时的毫秒数
|
|
46
|
-
* @property {boolean} [withCredentials=false] 跨域请求时是否需要使用凭证
|
|
47
|
-
* @property {boolean} [async=true] 是否异步执行操作
|
|
48
|
-
* @property {string|null} [user=null] 用户名,用于认证用途
|
|
49
|
-
* @property {string|null} [password=null] 密码,用于认证用途
|
|
50
|
-
* @property {function} [onLoadStart] 接收到响应数据时触发
|
|
51
|
-
* @property {function} [onProgress] 请求接收到更多数据时,周期性地触发
|
|
52
|
-
* @property {function} [onAbort] 当 request 被停止时触发,例如当程序调用 XMLHttpRequest.abort() 时
|
|
53
|
-
* @property {function} [onTimeout] 在预设时间内没有接收到响应时触发
|
|
54
|
-
* @property {function} [onError] 当 request 遭遇错误时触发
|
|
55
|
-
* @property {function} [onLoad] 请求成功完成时触发
|
|
56
|
-
* @property {function} [onLoadEnd] 请求结束时触发,无论请求成功 (load) 还是失败 (abort 或 error)
|
|
57
|
-
*/
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* 请求<br/><br/>
|
|
61
|
-
*
|
|
62
|
-
* <em style="font-weight: bold;">注意:该方法仅适用于浏览器端。</em>
|
|
63
|
-
*
|
|
64
|
-
* @static
|
|
65
|
-
* @alias module:Other.ajax
|
|
66
|
-
* @since 4.16.0
|
|
67
|
-
* @see {@link https://developer.mozilla.org/zh-CN/docs/Web/API/XMLHttpRequest|XMLHttpRequest}
|
|
68
|
-
* @param {string} url 地址
|
|
69
|
-
* @param {AjaxOptions} [options] 配置项
|
|
70
|
-
* @returns {Promise<object>} XHR 事件对象
|
|
71
|
-
* @example
|
|
72
|
-
* ajax('/somefile').then(res=>{
|
|
73
|
-
* // do something
|
|
74
|
-
* });
|
|
75
|
-
*
|
|
76
|
-
* ajax('/api', { method: 'post' }).then(res=>{
|
|
77
|
-
* // do something
|
|
78
|
-
* });
|
|
79
|
-
*/
|
|
80
|
-
function ajax(url, options) {}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* @callback TransformRequest
|
|
84
|
-
* @param {AjaxOptions} options ajax 配置项
|
|
85
|
-
* @returns {AjaxOptions | Promise<AjaxOptions>}
|
|
86
|
-
*/
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* @callback TransformResponse
|
|
90
|
-
* @param {Blob} res 响应的Blob对象。如果你通过 transformRequest 修改了 responseType ,该参数将是该类型响应值。
|
|
91
|
-
* @returns {Blob | Promise<Blob>}
|
|
92
|
-
*/
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* @typedef {Object} DownloadOptions 下载配置项
|
|
96
|
-
* @property {string} [options.fileName] 文件名称
|
|
97
|
-
* @property {string} [options.type] MIME 类型
|
|
98
|
-
* @property {'url'|'text'} [options.dataType] 手动设置数据类型,默认会根据传入的数据判断类型,主要是为了区分 url 和 text 。<br/>如果你要下载的文本是 url ,请设置 'text' ;如果你要下载的 url 是绝对/相对路径,请设置 'url' 。
|
|
99
|
-
* @property {TransformRequest} [options.transformRequest] 请求前触发,XHR 对象或配置调整
|
|
100
|
-
* @property {TransformResponse} [options.transformResponse] 请求成功后触发,在传递给 then/catch 前,允许修改响应数据
|
|
101
|
-
*/
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* 下载<br/><br/>
|
|
105
|
-
*
|
|
106
|
-
* <em style="font-weight: bold;">注意:该方法仅适用于浏览器端,兼容 IE10+ 和现代浏览器。</em>
|
|
107
|
-
*
|
|
108
|
-
* @static
|
|
109
|
-
* @alias module:Other.download
|
|
110
|
-
* @since 4.16.0
|
|
111
|
-
* @see {@link https://zh.wikipedia.org/wiki/多用途互聯網郵件擴展|MIME}
|
|
112
|
-
* @see {@link https://9ykc9s.csb.app/|在线示例}
|
|
113
|
-
* @param {string|Blob|TypedArray} data 字符串、blob数据或url地址
|
|
114
|
-
* @param {string|DownloadOptions} [options] 文件名称 或 配置项
|
|
115
|
-
* @returns {Promise<void>}
|
|
116
|
-
* @example
|
|
117
|
-
* // 文本
|
|
118
|
-
* download('hello world', 'text.txt');
|
|
119
|
-
*
|
|
120
|
-
* // 远程文件
|
|
121
|
-
* download('/xxx.jpg', { dataType: 'url' });
|
|
122
|
-
*
|
|
123
|
-
* // blob文件
|
|
124
|
-
* download(new Blob(['hello world']), 'text.txt');
|
|
125
|
-
*
|
|
126
|
-
*/
|
|
127
|
-
function download(data, fileName, options) {}
|