util-helpers 4.17.3 → 4.18.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 (159) hide show
  1. package/README.md +1 -1
  2. package/dist/util-helpers.js +305 -186
  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/VERSION.js +4 -0
  7. package/esm/calculateCursorPosition.js +3 -3
  8. package/esm/divide.js +2 -2
  9. package/esm/download.js +1 -2
  10. package/esm/filterTree.js +1 -1
  11. package/esm/findTreeNode.js +1 -1
  12. package/esm/findTreeNodes.js +1 -1
  13. package/esm/findTreeSelect.js +1 -1
  14. package/esm/formatBankCard.js +2 -2
  15. package/esm/formatMobile.js +2 -2
  16. package/esm/formatMoney.js +3 -3
  17. package/esm/index.js +6 -1
  18. package/esm/isBankCard.js +2 -2
  19. package/esm/isBusinessLicense.js +2 -2
  20. package/esm/isChinese.js +2 -2
  21. package/esm/isEmail.js +2 -2
  22. package/esm/isHMCard.js +2 -2
  23. package/esm/isIPv4.js +2 -2
  24. package/esm/isIPv6.js +2 -2
  25. package/esm/isIdCard.js +2 -2
  26. package/esm/isMobile.js +2 -2
  27. package/esm/isPassport.js +2 -2
  28. package/esm/isPostcode.js +2 -2
  29. package/esm/isPromiseLike.js +3 -1
  30. package/esm/isQQ.js +2 -2
  31. package/esm/isSocialCreditCode.js +2 -2
  32. package/esm/isSwiftCode.js +2 -2
  33. package/esm/isTWCard.js +2 -2
  34. package/esm/isTelephone.js +2 -2
  35. package/esm/isUrl.js +2 -2
  36. package/esm/isValidNumber.js +1 -1
  37. package/esm/isVehicle.js +2 -2
  38. package/esm/isWX.js +2 -2
  39. package/esm/listToTree.js +1 -1
  40. package/esm/minus.js +2 -2
  41. package/esm/normalizeString.js +2 -6
  42. package/esm/padZero.js +2 -2
  43. package/esm/plus.js +2 -2
  44. package/esm/replaceChar.js +2 -2
  45. package/esm/round.js +2 -2
  46. package/esm/strlen.js +2 -2
  47. package/esm/times.js +2 -2
  48. package/esm/transformFieldNames.js +1 -1
  49. package/esm/treeToList.js +1 -1
  50. package/esm/utils/config.js +1 -2
  51. package/esm/utils/math.util.js +1 -4
  52. package/esm/waitTime.js +3 -3
  53. package/lib/VERSION.js +6 -0
  54. package/lib/calculateCursorPosition.js +3 -3
  55. package/lib/divide.js +2 -2
  56. package/lib/download.js +4 -5
  57. package/lib/filterTree.js +3 -3
  58. package/lib/findTreeNode.js +2 -2
  59. package/lib/findTreeNodes.js +2 -2
  60. package/lib/findTreeSelect.js +2 -2
  61. package/lib/formatBankCard.js +2 -2
  62. package/lib/formatMobile.js +2 -2
  63. package/lib/formatMoney.js +3 -3
  64. package/lib/index.js +3 -5
  65. package/lib/isBankCard.js +2 -2
  66. package/lib/isBusinessLicense.js +2 -2
  67. package/lib/isChinese.js +2 -2
  68. package/lib/isEmail.js +2 -2
  69. package/lib/isHMCard.js +2 -2
  70. package/lib/isIPv4.js +2 -2
  71. package/lib/isIPv6.js +2 -2
  72. package/lib/isIdCard.js +2 -2
  73. package/lib/isMobile.js +2 -2
  74. package/lib/isPassport.js +2 -2
  75. package/lib/isPostcode.js +2 -2
  76. package/lib/isPromiseLike.js +3 -1
  77. package/lib/isQQ.js +2 -2
  78. package/lib/isSocialCreditCode.js +2 -2
  79. package/lib/isSwiftCode.js +2 -2
  80. package/lib/isTWCard.js +2 -2
  81. package/lib/isTelephone.js +2 -2
  82. package/lib/isUrl.js +2 -2
  83. package/lib/isValidNumber.js +2 -2
  84. package/lib/isVehicle.js +2 -2
  85. package/lib/isWX.js +2 -2
  86. package/lib/listToTree.js +2 -2
  87. package/lib/minus.js +2 -2
  88. package/lib/normalizeString.js +2 -6
  89. package/lib/padZero.js +2 -2
  90. package/lib/plus.js +2 -2
  91. package/lib/replaceChar.js +2 -2
  92. package/lib/round.js +2 -2
  93. package/lib/strlen.js +2 -2
  94. package/lib/times.js +2 -2
  95. package/lib/transformFieldNames.js +2 -2
  96. package/lib/treeToList.js +2 -2
  97. package/lib/utils/config.js +0 -1
  98. package/lib/utils/math.util.js +5 -8
  99. package/lib/waitTime.js +3 -3
  100. package/package.json +3 -2
  101. package/types/VERSION.d.ts +8 -0
  102. package/types/formatBankCard.d.ts +1 -1
  103. package/types/formatMobile.d.ts +1 -1
  104. package/types/index.d.ts +7 -1
  105. package/types/isPromiseLike.d.ts +1 -0
  106. package/types/normalizeString.d.ts +2 -1
  107. package/types/padZero.d.ts +1 -1
  108. package/types/replaceChar.d.ts +4 -1
  109. package/types/utils/config.d.ts +1 -2
  110. package/types/waitTime.d.ts +2 -1
  111. package/esm/utils/constants.js +0 -4
  112. package/esm/utils/convertToString.js +0 -7
  113. package/esm/utils/type/isBlob.js +0 -7
  114. package/esm/utils/type/isNaN.js +0 -7
  115. package/esm/utils/type/isNil.js +0 -8
  116. package/esm/utils/type/isNull.js +0 -5
  117. package/esm/utils/type/isNumber.js +0 -7
  118. package/esm/utils/type/isObject.js +0 -6
  119. package/esm/utils/type/isString.js +0 -7
  120. package/esm/utils/type/isSymbol.js +0 -7
  121. package/esm/utils/type/isType.js +0 -6
  122. package/esm/utils/type/isUndefined.js +0 -5
  123. package/lib/utils/constants.js +0 -4
  124. package/lib/utils/convertToString.js +0 -9
  125. package/lib/utils/type/isBlob.js +0 -9
  126. package/lib/utils/type/isNaN.js +0 -9
  127. package/lib/utils/type/isNil.js +0 -10
  128. package/lib/utils/type/isNull.js +0 -7
  129. package/lib/utils/type/isNumber.js +0 -9
  130. package/lib/utils/type/isObject.js +0 -8
  131. package/lib/utils/type/isString.js +0 -9
  132. package/lib/utils/type/isSymbol.js +0 -9
  133. package/lib/utils/type/isType.js +0 -8
  134. package/lib/utils/type/isUndefined.js +0 -7
  135. package/types/utils/constants.d.ts +0 -2
  136. package/types/utils/convertToString.d.ts +0 -8
  137. package/types/utils/type/index.d.ts +0 -28
  138. package/types/utils/type/isArguments.d.ts +0 -18
  139. package/types/utils/type/isArray.d.ts +0 -18
  140. package/types/utils/type/isArrayBuffer.d.ts +0 -21
  141. package/types/utils/type/isBlob.d.ts +0 -23
  142. package/types/utils/type/isBoolean.d.ts +0 -18
  143. package/types/utils/type/isDate.d.ts +0 -18
  144. package/types/utils/type/isError.d.ts +0 -18
  145. package/types/utils/type/isFunction.d.ts +0 -18
  146. package/types/utils/type/isMap.d.ts +0 -18
  147. package/types/utils/type/isNaN.d.ts +0 -18
  148. package/types/utils/type/isNil.d.ts +0 -11
  149. package/types/utils/type/isNull.d.ts +0 -18
  150. package/types/utils/type/isNumber.d.ts +0 -27
  151. package/types/utils/type/isObject.d.ts +0 -21
  152. package/types/utils/type/isRegExp.d.ts +0 -18
  153. package/types/utils/type/isSet.d.ts +0 -18
  154. package/types/utils/type/isString.d.ts +0 -18
  155. package/types/utils/type/isSymbol.d.ts +0 -18
  156. package/types/utils/type/isType.d.ts +0 -11
  157. package/types/utils/type/isUndefined.d.ts +0 -21
  158. package/types/utils/type/isWeakMap.d.ts +0 -18
  159. package/types/utils/type/isWeakSet.d.ts +0 -18
package/lib/round.js CHANGED
@@ -1,14 +1,14 @@
1
1
  'use strict';
2
2
 
3
+ var ut2 = require('ut2');
3
4
  var divide = require('./divide.js');
4
5
  var times = require('./times.js');
5
6
  var math_util = require('./utils/math.util.js');
6
- var isNaN = require('./utils/type/isNaN.js');
7
7
 
8
8
  function round(num, precision) {
9
9
  if (precision === void 0) { precision = 0; }
10
10
  num = math_util.transformEffectiveNumber(num);
11
- if (isNaN(num)) {
11
+ if (ut2.isNaN(num)) {
12
12
  return Number.NaN;
13
13
  }
14
14
  var base = Math.pow(10, precision);
package/lib/strlen.js CHANGED
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var normalizeString = require('./normalizeString.js');
3
+ var ut2 = require('ut2');
4
4
 
5
5
  function strlen(str) {
6
- var realStr = normalizeString(str);
6
+ var realStr = ut2.toString(str);
7
7
  var len = 0;
8
8
  for (var i = 0; i < realStr.length; i++) {
9
9
  var c = realStr.charCodeAt(i);
package/lib/times.js CHANGED
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  var tslib = require('tslib');
4
+ var ut2 = require('ut2');
4
5
  var math_util = require('./utils/math.util.js');
5
- var isNaN = require('./utils/type/isNaN.js');
6
6
 
7
7
  function times() {
8
8
  var nums = [];
@@ -15,7 +15,7 @@ function times() {
15
15
  }
16
16
  num1 = math_util.transformEffectiveNumber(num1);
17
17
  num2 = math_util.transformEffectiveNumber(num2);
18
- if (isNaN(num1) || isNaN(num2)) {
18
+ if (ut2.isNaN(num1) || ut2.isNaN(num2)) {
19
19
  return Number.NaN;
20
20
  }
21
21
  var num1Changed = math_util.float2Fixed(num1);
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var tslib = require('tslib');
4
- var isObject = require('./utils/type/isObject.js');
4
+ var ut2 = require('ut2');
5
5
 
6
6
  function transformFieldNames(data, fieldNames, childrenField, nodeAssign) {
7
7
  if (nodeAssign === void 0) { nodeAssign = 'spread'; }
@@ -13,7 +13,7 @@ function transformFieldNames(data, fieldNames, childrenField, nodeAssign) {
13
13
  }
14
14
  function recusion(arr) {
15
15
  return arr.map(function (item) {
16
- if (!isObject(item)) {
16
+ if (!ut2.isObject(item)) {
17
17
  return item;
18
18
  }
19
19
  var newItem = nodeAssign === 'spread' ? tslib.__assign({}, item) : item;
package/lib/treeToList.js CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var tslib = require('tslib');
4
- var isObject = require('./utils/type/isObject.js');
4
+ var ut2 = require('ut2');
5
5
 
6
6
  function treeToList(tree, childrenField) {
7
7
  var list = [];
@@ -10,7 +10,7 @@ function treeToList(tree, childrenField) {
10
10
  }
11
11
  function recusion(arr) {
12
12
  arr.forEach(function (item) {
13
- if (isObject(item)) {
13
+ if (ut2.isObject(item)) {
14
14
  var newItem = tslib.__assign({}, item);
15
15
  list.push(newItem);
16
16
  if (newItem[childrenField]) {
@@ -6,6 +6,5 @@ exports.config = {
6
6
  function setDisableWarning(bool) {
7
7
  exports.config.disableWarning = !!bool;
8
8
  }
9
- exports.version = "4.17.3";
10
9
 
11
10
  exports.setDisableWarning = setDisableWarning;
@@ -1,14 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var constants = require('./constants.js');
3
+ var ut2 = require('ut2');
4
4
  var devWarn = require('./devWarn.js');
5
- var isNumber = require('./type/isNumber.js');
6
- var isString = require('./type/isString.js');
7
- var isSymbol = require('./type/isSymbol.js');
8
5
 
9
6
  function transformEffectiveNumber(value) {
10
7
  var ret;
11
- if (isString(value)) {
8
+ if (ut2.isString(value)) {
12
9
  ret = value.trim();
13
10
  if (ret === '') {
14
11
  ret = Number(ret);
@@ -17,10 +14,10 @@ function transformEffectiveNumber(value) {
17
14
  ret = Number.NaN;
18
15
  }
19
16
  }
20
- else if (isSymbol(value)) {
17
+ else if (ut2.isSymbol(value)) {
21
18
  ret = Number.NaN;
22
19
  }
23
- else if (!isNumber(value)) {
20
+ else if (!ut2.isNumber(value)) {
24
21
  ret = Number(value);
25
22
  }
26
23
  else {
@@ -52,7 +49,7 @@ function float2Fixed(num) {
52
49
  return dLen > 0 ? strip(+num * Math.pow(10, dLen)) : +num;
53
50
  }
54
51
  function checkBoundary(num) {
55
- if (+num > constants.MAX_SAFE_INTEGER || +num < constants.MIN_SAFE_INTEGER) {
52
+ if (+num > ut2.MAX_SAFE_INTEGER || +num < ut2.MIN_SAFE_INTEGER) {
56
53
  devWarn("".concat(num, " is beyond boundary when transfer to integer, the results may not be accurate"));
57
54
  }
58
55
  }
package/lib/waitTime.js CHANGED
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
+ var ut2 = require('ut2');
4
+
3
5
  function waitTime(time) {
4
6
  if (time === void 0) { time = 1000; }
5
- return new Promise(function (resolve) {
6
- setTimeout(resolve, time);
7
- });
7
+ return ut2.sleep(time);
8
8
  }
9
9
 
10
10
  module.exports = waitTime;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "util-helpers",
3
- "version": "4.17.3",
3
+ "version": "4.18.0",
4
4
  "description": "一个基于业务场景的工具方法库",
5
5
  "main": "lib/index.js",
6
6
  "module": "esm/index.js",
@@ -96,6 +96,7 @@
96
96
  }
97
97
  },
98
98
  "dependencies": {
99
- "tslib": "^2.5.0"
99
+ "tslib": "^2.5.0",
100
+ "ut2": "^1.0.0"
100
101
  }
101
102
  }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * util-helpers 版本号
3
+ *
4
+ * @static
5
+ * @since 4.18.0
6
+ */
7
+ declare const VERSION: string;
8
+ export default VERSION;
@@ -30,5 +30,5 @@ type Options = {
30
30
  * formatBankCard('6228480402564890', {spaceMark: '-'}); // 6228-4804-0256-4890
31
31
  *
32
32
  */
33
- declare function formatBankCard(bankCardNo?: string, options?: Options): string;
33
+ declare function formatBankCard(bankCardNo?: string, options?: Options): any;
34
34
  export default formatBankCard;
@@ -28,5 +28,5 @@ type Options = {
28
28
  * formatMobile('13345678'); // 133 4567 8
29
29
  *
30
30
  */
31
- declare function formatMobile(mobileNo?: string, options?: Options): string;
31
+ declare function formatMobile(mobileNo?: string, options?: Options): any;
32
32
  export default formatMobile;
package/types/index.d.ts CHANGED
@@ -123,4 +123,10 @@ export { default as findTreeSelect } from './findTreeSelect';
123
123
  * @ignore
124
124
  * @since 3.6.1
125
125
  */
126
- export { setDisableWarning, version } from './utils/config';
126
+ export { setDisableWarning } from './utils/config';
127
+ import VERSION from './VERSION';
128
+ export { VERSION };
129
+ /**
130
+ * @deprecated 即将废弃,请使用 `VERSION`
131
+ */
132
+ export declare const version: string;
@@ -4,6 +4,7 @@
4
4
  * @static
5
5
  * @alias module:Validator.isPromiseLike
6
6
  * @since 3.8.0
7
+ * @deprecated 即将废弃,请使用 `import { isPromiseLike } 'ut2'`
7
8
  * @param {*} obj 要检测的值
8
9
  * @returns {boolean} 是否类似Promise对象
9
10
  * @example
@@ -5,6 +5,7 @@
5
5
  * @alias module:Processor.normalizeString
6
6
  * @since 4.3.0
7
7
  * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/String#string_instances | String}
8
+ * @deprecated 即将废弃,请使用 `import { toString } 'ut2'`
8
9
  * @param {*} value 待处理的值
9
10
  * @returns {string} 规整化的值
10
11
  * @example
@@ -20,5 +21,5 @@
20
21
  * normalizeString('a'); // 'a'
21
22
  *
22
23
  */
23
- declare function normalizeString(value: any): string;
24
+ declare function normalizeString(value: any): any;
24
25
  export default normalizeString;
@@ -21,5 +21,5 @@
21
21
  * padZero('688', 5); // 00688
22
22
  *
23
23
  */
24
- declare function padZero(value: string | number, size?: number): string;
24
+ declare function padZero(value: string | number, size?: number): any;
25
25
  export default padZero;
@@ -24,6 +24,9 @@ type Options = {
24
24
  * // 手机号 前3后4
25
25
  * replaceChar('13000000000'); // 130****0000
26
26
  *
27
+ * // 手机号 前2后4
28
+ * replaceChar('13000000000', { start: 2 }); // 13*****0000
29
+ *
27
30
  * // 身份证 前6后4
28
31
  * replaceChar('130701199310302288', { start: 6, end: -4 }); // 130701********2288
29
32
  *
@@ -50,5 +53,5 @@ type Options = {
50
53
  * replaceChar('林某某某', {start: 1, end: Infinity, repeat: 2}); // 林**
51
54
  *
52
55
  */
53
- declare function replaceChar(str: string, options?: Options): string;
56
+ declare function replaceChar(str: string, options?: Options): any;
54
57
  export default replaceChar;
@@ -9,5 +9,4 @@ declare const config: {
9
9
  * @param {boolean} bool 是否禁止warning提示
10
10
  */
11
11
  declare function setDisableWarning(bool: boolean): void;
12
- declare const version: string;
13
- export { config, setDisableWarning, version };
12
+ export { config, setDisableWarning };
@@ -4,6 +4,7 @@
4
4
  * @static
5
5
  * @alias module:Other.waitTime
6
6
  * @since 4.2.0
7
+ * @deprecated 即将废弃,请使用 `import { sleep } from 'ut2'`
7
8
  * @param {number} [time=1000] 延时时间,单位毫秒
8
9
  * @returns {Promise<void>}
9
10
  * @example
@@ -18,5 +19,5 @@
18
19
  * });
19
20
  *
20
21
  */
21
- declare function waitTime(time?: number): Promise<unknown>;
22
+ declare function waitTime(time?: number): Promise<void>;
22
23
  export default waitTime;
@@ -1,4 +0,0 @@
1
- var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
2
- var MIN_SAFE_INTEGER = Number.MIN_SAFE_INTEGER || -9007199254740991;
3
-
4
- export { MAX_SAFE_INTEGER, MIN_SAFE_INTEGER };
@@ -1,7 +0,0 @@
1
- import isString from './type/isString.js';
2
-
3
- function convertToString(value) {
4
- return isString(value) ? value : String(value);
5
- }
6
-
7
- export { convertToString as default };
@@ -1,7 +0,0 @@
1
- import isType from './isType.js';
2
-
3
- function isBlob(value) {
4
- return isType(value, 'Blob');
5
- }
6
-
7
- export { isBlob as default };
@@ -1,7 +0,0 @@
1
- import isType from './isType.js';
2
-
3
- function _isNaN(value) {
4
- return isType(value, 'Number') && isNaN(value);
5
- }
6
-
7
- export { _isNaN as default };
@@ -1,8 +0,0 @@
1
- import isUndefined from './isUndefined.js';
2
- import isNull from './isNull.js';
3
-
4
- function isNil(value) {
5
- return isUndefined(value) || isNull(value);
6
- }
7
-
8
- export { isNil as default };
@@ -1,5 +0,0 @@
1
- function isNull(value) {
2
- return value === null;
3
- }
4
-
5
- export { isNull as default };
@@ -1,7 +0,0 @@
1
- import isType from './isType.js';
2
-
3
- function isNumber(value) {
4
- return isType(value, 'Number');
5
- }
6
-
7
- export { isNumber as default };
@@ -1,6 +0,0 @@
1
- function isObject(value) {
2
- var type = typeof value;
3
- return value != null && (type === 'object' || type === 'function');
4
- }
5
-
6
- export { isObject as default };
@@ -1,7 +0,0 @@
1
- import isType from './isType.js';
2
-
3
- function isString(value) {
4
- return isType(value, 'String');
5
- }
6
-
7
- export { isString as default };
@@ -1,7 +0,0 @@
1
- import isType from './isType.js';
2
-
3
- function isSymbol(value) {
4
- return isType(value, 'Symbol');
5
- }
6
-
7
- export { isSymbol as default };
@@ -1,6 +0,0 @@
1
- var toString = Object.prototype.toString;
2
- function isType(value, typename) {
3
- return toString.call(value) === "[object ".concat(typename, "]");
4
- }
5
-
6
- export { isType as default };
@@ -1,5 +0,0 @@
1
- function isUndefined(value) {
2
- return value === void 0;
3
- }
4
-
5
- export { isUndefined as default };
@@ -1,4 +0,0 @@
1
- 'use strict';
2
-
3
- exports.MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
4
- exports.MIN_SAFE_INTEGER = Number.MIN_SAFE_INTEGER || -9007199254740991;
@@ -1,9 +0,0 @@
1
- 'use strict';
2
-
3
- var isString = require('./type/isString.js');
4
-
5
- function convertToString(value) {
6
- return isString(value) ? value : String(value);
7
- }
8
-
9
- module.exports = convertToString;
@@ -1,9 +0,0 @@
1
- 'use strict';
2
-
3
- var isType = require('./isType.js');
4
-
5
- function isBlob(value) {
6
- return isType(value, 'Blob');
7
- }
8
-
9
- module.exports = isBlob;
@@ -1,9 +0,0 @@
1
- 'use strict';
2
-
3
- var isType = require('./isType.js');
4
-
5
- function _isNaN(value) {
6
- return isType(value, 'Number') && isNaN(value);
7
- }
8
-
9
- module.exports = _isNaN;
@@ -1,10 +0,0 @@
1
- 'use strict';
2
-
3
- var isUndefined = require('./isUndefined.js');
4
- var isNull = require('./isNull.js');
5
-
6
- function isNil(value) {
7
- return isUndefined(value) || isNull(value);
8
- }
9
-
10
- module.exports = isNil;
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- function isNull(value) {
4
- return value === null;
5
- }
6
-
7
- module.exports = isNull;
@@ -1,9 +0,0 @@
1
- 'use strict';
2
-
3
- var isType = require('./isType.js');
4
-
5
- function isNumber(value) {
6
- return isType(value, 'Number');
7
- }
8
-
9
- module.exports = isNumber;
@@ -1,8 +0,0 @@
1
- 'use strict';
2
-
3
- function isObject(value) {
4
- var type = typeof value;
5
- return value != null && (type === 'object' || type === 'function');
6
- }
7
-
8
- module.exports = isObject;
@@ -1,9 +0,0 @@
1
- 'use strict';
2
-
3
- var isType = require('./isType.js');
4
-
5
- function isString(value) {
6
- return isType(value, 'String');
7
- }
8
-
9
- module.exports = isString;
@@ -1,9 +0,0 @@
1
- 'use strict';
2
-
3
- var isType = require('./isType.js');
4
-
5
- function isSymbol(value) {
6
- return isType(value, 'Symbol');
7
- }
8
-
9
- module.exports = isSymbol;
@@ -1,8 +0,0 @@
1
- 'use strict';
2
-
3
- var toString = Object.prototype.toString;
4
- function isType(value, typename) {
5
- return toString.call(value) === "[object ".concat(typename, "]");
6
- }
7
-
8
- module.exports = isType;
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- function isUndefined(value) {
4
- return value === void 0;
5
- }
6
-
7
- module.exports = isUndefined;
@@ -1,2 +0,0 @@
1
- export declare const MAX_SAFE_INTEGER: number;
2
- export declare const MIN_SAFE_INTEGER: number;
@@ -1,8 +0,0 @@
1
- /**
2
- * 转换为字符串
3
- *
4
- * @param {*} value 值
5
- * @returns {string} 字符串
6
- */
7
- declare function convertToString(value: any): string;
8
- export default convertToString;
@@ -1,28 +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
- * @module Type
25
- * @ignore
26
- * @since 1.1.0
27
- */
28
- export { isArguments, isArray, isArrayBuffer, isBlob, isBoolean, isDate, isError, isFunction, isObject, isNull, isNaN, isNumber, isRegExp, isString, isSymbol, isMap, isWeakMap, isSet, isWeakSet, isUndefined };
@@ -1,18 +0,0 @@
1
- /**
2
- * 检查值是否为Arguments
3
- *
4
- * @static
5
- * @alias module:Type.isArguments
6
- * @since 1.1.0
7
- * @param {*} value 检查值
8
- * @returns {boolean} 是否为Arguments
9
- * @example
10
- *
11
- * isArguments(function() { return arguments }())
12
- * // => true
13
- *
14
- * isArguments([1, 2, 3])
15
- * // => false
16
- */
17
- declare function isArguments(value: any): boolean;
18
- export default isArguments;
@@ -1,18 +0,0 @@
1
- /**
2
- * 检查值是否为Array
3
- *
4
- * @static
5
- * @alias module:Type.isArray
6
- * @since 1.1.0
7
- * @param {*} value 检查值
8
- * @returns {boolean} 是否为Array
9
- * @example
10
- *
11
- * isArray([])
12
- * // => true
13
- *
14
- * isArray(1)
15
- * // => false
16
- */
17
- declare function isArray(value: any): boolean;
18
- export default isArray;
@@ -1,21 +0,0 @@
1
- /**
2
- * 检查值是否为ArrayBuffer对象
3
- *
4
- * @static
5
- * @alias module:Type.isArrayBuffer
6
- * @since 4.16.0
7
- * @param {*} value 检查值
8
- * @returns {boolean} 是否为ArrayBuffer对象
9
- * @example
10
- *
11
- * isArrayBuffer(new ArrayBuffer(8))
12
- * // => true
13
- *
14
- * isArrayBuffer({})
15
- * // => false
16
- *
17
- * isArrayBuffer('2012')
18
- * // => false
19
- */
20
- declare function isArrayBuffer(value: any): boolean;
21
- export default isArrayBuffer;
@@ -1,23 +0,0 @@
1
- /**
2
- * 检查值是否为Blob对象
3
- *
4
- * <em style="font-weight: bold;">注意:该方法仅适用于浏览器端。</em>
5
- *
6
- * @static
7
- * @alias module:Type.isBlob
8
- * @since 4.16.0
9
- * @param {*} value 检查值
10
- * @returns {boolean} 是否为Blob对象
11
- * @example
12
- *
13
- * isBlob(new Blob(['a']))
14
- * // => true
15
- *
16
- * isBlob({})
17
- * // => false
18
- *
19
- * isBlob('2012')
20
- * // => false
21
- */
22
- declare function isBlob(value: any): boolean;
23
- export default isBlob;
@@ -1,18 +0,0 @@
1
- /**
2
- * 检查值是否为Boolean
3
- *
4
- * @static
5
- * @alias module:Type.isBoolean
6
- * @since 1.1.0
7
- * @param {*} value 检查值
8
- * @returns {boolean} 是否为Boolean
9
- * @example
10
- *
11
- * isBoolean(false)
12
- * // => true
13
- *
14
- * isBoolean(null)
15
- * // => false
16
- */
17
- declare function isBoolean(value: any): boolean;
18
- export default isBoolean;