@yelon/util 12.0.10 → 12.0.11
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +21 -21
- package/array/array-type.service.d.ts +68 -68
- package/array/array.service.d.ts +75 -75
- package/array/index.d.ts +2 -2
- package/array/yelon-util-array.d.ts +4 -4
- package/browser/browser.d.ts +4 -4
- package/browser/cookie.service.d.ts +64 -64
- package/browser/copy.d.ts +6 -6
- package/browser/index.d.ts +5 -5
- package/browser/is-empty.d.ts +6 -6
- package/browser/scroll.service.d.ts +34 -34
- package/browser/style.d.ts +21 -21
- package/bundles/browser.umd.js +275 -275
- package/bundles/yelon-util-array.umd.js +602 -602
- package/bundles/yelon-util-config.umd.js +366 -366
- package/bundles/yelon-util-date-time.umd.js +216 -216
- package/bundles/yelon-util-decorator.umd.js +437 -437
- package/bundles/yelon-util-form.umd.js +116 -116
- package/bundles/yelon-util-format.umd.js +726 -726
- package/bundles/yelon-util-math.umd.js +83 -83
- package/bundles/yelon-util-other.umd.js +655 -655
- package/bundles/yelon-util-pipes-currency.umd.js +83 -83
- package/bundles/yelon-util-pipes-filter.umd.js +353 -353
- package/bundles/yelon-util-pipes-format.umd.js +47 -47
- package/bundles/yelon-util-pipes.umd.js +7 -7
- package/bundles/yelon-util-token.umd.js +30 -30
- package/bundles/yelon-util.umd.js +7 -7
- package/config/abc/date-picker.type.d.ts +52 -52
- package/config/abc/error-collect.type.d.ts +10 -10
- package/config/abc/image.type.d.ts +15 -15
- package/config/abc/index.d.ts +16 -16
- package/config/abc/loading.type.d.ts +31 -31
- package/config/abc/lodop.type.d.ts +33 -33
- package/config/abc/media.type.d.ts +11 -11
- package/config/abc/onboarding.type.d.ts +4 -4
- package/config/abc/page-header.type.d.ts +39 -39
- package/config/abc/pdf.type.d.ts +35 -35
- package/config/abc/qr.type.d.ts +25 -25
- package/config/abc/se.type.d.ts +32 -32
- package/config/abc/sg.type.d.ts +10 -10
- package/config/abc/st.type.d.ts +431 -431
- package/config/abc/sv.type.d.ts +14 -14
- package/config/abc/xlsx.type.d.ts +12 -12
- package/config/abc/zip.type.d.ts +10 -10
- package/config/acl/acl.type.d.ts +32 -32
- package/config/auth/auth.type.d.ts +55 -55
- package/config/bis/bis.type.d.ts +7 -7
- package/config/cache/cache.type.d.ts +40 -40
- package/config/chart/chart.type.d.ts +33 -33
- package/config/config.service.d.ts +10 -10
- package/config/config.types.d.ts +49 -49
- package/config/index.d.ts +14 -14
- package/config/mock/mock.type.d.ts +18 -18
- package/config/sf/sf.type.d.ts +127 -127
- package/config/stomp/stomp.type.d.ts +2 -2
- package/config/theme/http.type.d.ts +14 -14
- package/config/theme/i18n.type.d.ts +8 -8
- package/config/theme/index.d.ts +3 -3
- package/config/theme/responsive.type.d.ts +12 -12
- package/config/util/array.type.d.ts +22 -22
- package/config/util/currency.type.d.ts +39 -39
- package/config/yelon-util-config.d.ts +4 -4
- package/date-time/index.d.ts +2 -2
- package/date-time/picker.d.ts +68 -68
- package/date-time/time.d.ts +26 -26
- package/date-time/yelon-util-date-time.d.ts +4 -4
- package/decorator/convert.d.ts +24 -24
- package/decorator/index.d.ts +2 -2
- package/decorator/yelon-util-decorator.d.ts +4 -4
- package/decorator/zone-outside.d.ts +35 -35
- package/esm2015/array/array-type.service.js +1 -1
- package/esm2015/array/array.service.js +249 -249
- package/esm2015/array/index.js +2 -2
- package/esm2015/array/yelon-util-array.js +4 -4
- package/esm2015/browser/browser.js +4 -4
- package/esm2015/browser/cookie.service.js +103 -103
- package/esm2015/browser/copy.js +26 -26
- package/esm2015/browser/index.js +5 -5
- package/esm2015/browser/is-empty.js +18 -18
- package/esm2015/browser/scroll.service.js +88 -88
- package/esm2015/browser/style.js +37 -37
- package/esm2015/config/abc/date-picker.type.js +1 -1
- package/esm2015/config/abc/error-collect.type.js +1 -1
- package/esm2015/config/abc/image.type.js +1 -1
- package/esm2015/config/abc/index.js +16 -16
- package/esm2015/config/abc/loading.type.js +1 -1
- package/esm2015/config/abc/lodop.type.js +1 -1
- package/esm2015/config/abc/media.type.js +1 -1
- package/esm2015/config/abc/onboarding.type.js +1 -1
- package/esm2015/config/abc/page-header.type.js +1 -1
- package/esm2015/config/abc/pdf.type.js +1 -1
- package/esm2015/config/abc/qr.type.js +1 -1
- package/esm2015/config/abc/se.type.js +1 -1
- package/esm2015/config/abc/sg.type.js +1 -1
- package/esm2015/config/abc/st.type.js +1 -1
- package/esm2015/config/abc/sv.type.js +2 -2
- package/esm2015/config/abc/xlsx.type.js +1 -1
- package/esm2015/config/abc/zip.type.js +1 -1
- package/esm2015/config/acl/acl.type.js +1 -1
- package/esm2015/config/auth/auth.type.js +1 -1
- package/esm2015/config/bis/bis.type.js +1 -1
- package/esm2015/config/cache/cache.type.js +1 -1
- package/esm2015/config/chart/chart.type.js +1 -1
- package/esm2015/config/config.service.js +33 -33
- package/esm2015/config/config.types.js +8 -8
- package/esm2015/config/index.js +14 -14
- package/esm2015/config/mock/mock.type.js +1 -1
- package/esm2015/config/sf/sf.type.js +1 -1
- package/esm2015/config/stomp/stomp.type.js +1 -1
- package/esm2015/config/theme/http.type.js +1 -1
- package/esm2015/config/theme/i18n.type.js +1 -1
- package/esm2015/config/theme/index.js +3 -3
- package/esm2015/config/theme/responsive.type.js +1 -1
- package/esm2015/config/util/array.type.js +1 -1
- package/esm2015/config/util/currency.type.js +1 -1
- package/esm2015/config/yelon-util-config.js +4 -4
- package/esm2015/date-time/index.js +2 -2
- package/esm2015/date-time/picker.js +115 -115
- package/esm2015/date-time/time.js +83 -83
- package/esm2015/date-time/yelon-util-date-time.js +4 -4
- package/esm2015/decorator/convert.js +55 -55
- package/esm2015/decorator/index.js +2 -2
- package/esm2015/decorator/yelon-util-decorator.js +4 -4
- package/esm2015/decorator/zone-outside.js +54 -54
- package/esm2015/form/index.js +2 -2
- package/esm2015/form/match-control.js +29 -29
- package/esm2015/form/validators.js +80 -80
- package/esm2015/form/yelon-util-form.js +4 -4
- package/esm2015/format/currency.service.js +224 -224
- package/esm2015/format/currency.types.js +7 -7
- package/esm2015/format/index.js +4 -4
- package/esm2015/format/string.js +75 -75
- package/esm2015/format/validate.js +93 -93
- package/esm2015/format/yelon-util-format.js +4 -4
- package/esm2015/index.js +11 -11
- package/esm2015/math/in-range.js +24 -24
- package/esm2015/math/index.js +2 -2
- package/esm2015/math/round.js +52 -52
- package/esm2015/math/yelon-util-math.js +4 -4
- package/esm2015/other/assert.js +66 -66
- package/esm2015/other/deep.js +75 -75
- package/esm2015/other/index.js +4 -4
- package/esm2015/other/lazy.service.js +117 -117
- package/esm2015/other/logger.js +35 -35
- package/esm2015/other/yelon-util-other.js +4 -4
- package/esm2015/pipes/currency/cny.pipe.js +21 -21
- package/esm2015/pipes/currency/index.js +3 -3
- package/esm2015/pipes/currency/mega.pipe.js +25 -25
- package/esm2015/pipes/currency/module.js +13 -13
- package/esm2015/pipes/currency/price.pipe.js +25 -25
- package/esm2015/pipes/currency/yelon-util-pipes-currency.js +5 -5
- package/esm2015/pipes/filter/filter.pipe.js +14 -14
- package/esm2015/pipes/filter/index.js +2 -2
- package/esm2015/pipes/filter/module.js +11 -11
- package/esm2015/pipes/filter/yelon-util-pipes-filter.js +4 -4
- package/esm2015/pipes/format/index.js +2 -2
- package/esm2015/pipes/format/mask.pipe.js +29 -29
- package/esm2015/pipes/format/module.js +11 -11
- package/esm2015/pipes/format/yelon-util-pipes-format.js +4 -4
- package/esm2015/pipes/index.js +3 -3
- package/esm2015/pipes/yelon-util-pipes.js +4 -4
- package/esm2015/token/index.js +2 -2
- package/esm2015/token/page-visibility.js +15 -15
- package/esm2015/token/window.js +16 -16
- package/esm2015/token/yelon-util-token.js +4 -4
- package/esm2015/yelon-util.js +4 -4
- package/fesm2015/browser.js +257 -257
- package/fesm2015/yelon-util-array.js +245 -245
- package/fesm2015/yelon-util-config.js +36 -36
- package/fesm2015/yelon-util-date-time.js +196 -196
- package/fesm2015/yelon-util-decorator.js +107 -107
- package/fesm2015/yelon-util-form.js +108 -108
- package/fesm2015/yelon-util-format.js +390 -390
- package/fesm2015/yelon-util-math.js +75 -75
- package/fesm2015/yelon-util-other.js +283 -283
- package/fesm2015/yelon-util-pipes-currency.js +72 -72
- package/fesm2015/yelon-util-pipes-filter.js +22 -22
- package/fesm2015/yelon-util-pipes-format.js +36 -36
- package/fesm2015/yelon-util-pipes.js +2 -2
- package/fesm2015/yelon-util-token.js +25 -25
- package/fesm2015/yelon-util.js +2 -2
- package/form/index.d.ts +2 -2
- package/form/match-control.d.ts +15 -15
- package/form/validators.d.ts +62 -62
- package/form/yelon-util-form.d.ts +4 -4
- package/format/currency.service.d.ts +34 -34
- package/format/currency.types.d.ts +77 -77
- package/format/index.d.ts +4 -4
- package/format/string.d.ts +44 -44
- package/format/validate.d.ts +72 -72
- package/format/yelon-util-format.d.ts +4 -4
- package/index.d.ts +11 -11
- package/math/in-range.d.ts +14 -14
- package/math/index.d.ts +2 -2
- package/math/round.d.ts +33 -33
- package/math/yelon-util-math.d.ts +4 -4
- package/other/assert.d.ts +36 -36
- package/other/deep.d.ts +33 -33
- package/other/index.d.ts +4 -4
- package/other/lazy.service.d.ts +22 -22
- package/other/logger.d.ts +6 -6
- package/other/yelon-util-other.d.ts +4 -4
- package/package.json +1 -1
- package/pipes/currency/cny.pipe.d.ts +12 -12
- package/pipes/currency/index.d.ts +3 -3
- package/pipes/currency/mega.pipe.d.ts +13 -13
- package/pipes/currency/module.d.ts +2 -2
- package/pipes/currency/price.pipe.d.ts +16 -16
- package/pipes/currency/yelon-util-pipes-currency.d.ts +5 -5
- package/pipes/filter/filter.pipe.d.ts +10 -10
- package/pipes/filter/index.d.ts +2 -2
- package/pipes/filter/module.d.ts +2 -2
- package/pipes/filter/yelon-util-pipes-filter.d.ts +4 -4
- package/pipes/format/index.d.ts +2 -2
- package/pipes/format/mask.pipe.d.ts +24 -24
- package/pipes/format/module.d.ts +2 -2
- package/pipes/format/yelon-util-pipes-format.d.ts +4 -4
- package/pipes/index.d.ts +3 -3
- package/pipes/yelon-util-pipes.d.ts +4 -4
- package/token/index.d.ts +2 -2
- package/token/page-visibility.d.ts +8 -8
- package/token/window.d.ts +7 -7
- package/token/yelon-util-token.d.ts +4 -4
- package/yelon-util.d.ts +4 -4
package/esm2015/format/string.js
CHANGED
@@ -1,76 +1,76 @@
|
|
1
|
-
import { deepGet } from '@yelon/util/other';
|
2
|
-
/**
|
3
|
-
* String formatting
|
4
|
-
*
|
5
|
-
* 字符串格式化
|
6
|
-
* ```
|
7
|
-
* format('this is ${name}', { name: 'asdf' })
|
8
|
-
* // output: this is asdf
|
9
|
-
* format('this is ${user.name}', { user: { name: 'asdf' } }, true)
|
10
|
-
* // output: this is asdf
|
11
|
-
* ```
|
12
|
-
*/
|
13
|
-
export function format(str, obj, needDeepGet = false) {
|
14
|
-
return (str || '').replace(/\${([^}]+)}/g, (_work, key) => needDeepGet ? deepGet(obj, key.split('.'), '') : (obj || {})[key] || '');
|
15
|
-
}
|
16
|
-
/**
|
17
|
-
* Format mask
|
18
|
-
*
|
19
|
-
* 格式化掩码
|
20
|
-
*
|
21
|
-
* | 字符 | 描述 |
|
22
|
-
* | --- | --- |
|
23
|
-
* | `0` | 任意数字,若该位置字符不符合,则默认为 `0` 填充 |
|
24
|
-
* | `9` | 任意数字 |
|
25
|
-
* | `#` | 任意字符 |
|
26
|
-
* | `U` | 转换大写 |
|
27
|
-
* | `L` | 转换小写 |
|
28
|
-
* | `*` | 转换为 `*` 字符 |
|
29
|
-
*
|
30
|
-
* ```ts
|
31
|
-
* formatMask('123', '(###)') => (123)
|
32
|
-
* formatMask('15900000000', '999****9999') => 159****0000
|
33
|
-
* ```
|
34
|
-
*/
|
35
|
-
export function formatMask(value, option) {
|
36
|
-
if (!value) {
|
37
|
-
return '';
|
38
|
-
}
|
39
|
-
const opt = Object.assign({}, (typeof option === 'string' ? { mask: option } : option));
|
40
|
-
const tokens = Object.assign({ '0': { pattern: /\d/, default: '0' }, '9': { pattern: /\d/ }, '#': { pattern: /[a-zA-Z0-9]/ }, U: {
|
41
|
-
pattern: /[a-zA-Z]/,
|
42
|
-
transform: char => char.toLocaleUpperCase()
|
43
|
-
}, L: {
|
44
|
-
pattern: /[a-zA-Z]/,
|
45
|
-
transform: char => char.toLocaleLowerCase()
|
46
|
-
}, '*': {
|
47
|
-
pattern: /.*/,
|
48
|
-
transform: _ => `*`
|
49
|
-
} }, opt.tokens);
|
50
|
-
const splitValue = value.split('');
|
51
|
-
return opt.mask
|
52
|
-
.split('')
|
53
|
-
.reduce((res, cur) => {
|
54
|
-
var _a;
|
55
|
-
const token = tokens[cur];
|
56
|
-
if (!token) {
|
57
|
-
res.push(cur);
|
58
|
-
return res;
|
59
|
-
}
|
60
|
-
const value = (_a = splitValue.shift()) !== null && _a !== void 0 ? _a : '';
|
61
|
-
if (!token.pattern.test(value)) {
|
62
|
-
if (token.default)
|
63
|
-
res.push(token.default);
|
64
|
-
return res;
|
65
|
-
}
|
66
|
-
if (typeof token.transform === 'function') {
|
67
|
-
res.push(token.transform(value));
|
68
|
-
}
|
69
|
-
else {
|
70
|
-
res.push(value);
|
71
|
-
}
|
72
|
-
return res;
|
73
|
-
}, [])
|
74
|
-
.join('');
|
75
|
-
}
|
1
|
+
import { deepGet } from '@yelon/util/other';
|
2
|
+
/**
|
3
|
+
* String formatting
|
4
|
+
*
|
5
|
+
* 字符串格式化
|
6
|
+
* ```
|
7
|
+
* format('this is ${name}', { name: 'asdf' })
|
8
|
+
* // output: this is asdf
|
9
|
+
* format('this is ${user.name}', { user: { name: 'asdf' } }, true)
|
10
|
+
* // output: this is asdf
|
11
|
+
* ```
|
12
|
+
*/
|
13
|
+
export function format(str, obj, needDeepGet = false) {
|
14
|
+
return (str || '').replace(/\${([^}]+)}/g, (_work, key) => needDeepGet ? deepGet(obj, key.split('.'), '') : (obj || {})[key] || '');
|
15
|
+
}
|
16
|
+
/**
|
17
|
+
* Format mask
|
18
|
+
*
|
19
|
+
* 格式化掩码
|
20
|
+
*
|
21
|
+
* | 字符 | 描述 |
|
22
|
+
* | --- | --- |
|
23
|
+
* | `0` | 任意数字,若该位置字符不符合,则默认为 `0` 填充 |
|
24
|
+
* | `9` | 任意数字 |
|
25
|
+
* | `#` | 任意字符 |
|
26
|
+
* | `U` | 转换大写 |
|
27
|
+
* | `L` | 转换小写 |
|
28
|
+
* | `*` | 转换为 `*` 字符 |
|
29
|
+
*
|
30
|
+
* ```ts
|
31
|
+
* formatMask('123', '(###)') => (123)
|
32
|
+
* formatMask('15900000000', '999****9999') => 159****0000
|
33
|
+
* ```
|
34
|
+
*/
|
35
|
+
export function formatMask(value, option) {
|
36
|
+
if (!value) {
|
37
|
+
return '';
|
38
|
+
}
|
39
|
+
const opt = Object.assign({}, (typeof option === 'string' ? { mask: option } : option));
|
40
|
+
const tokens = Object.assign({ '0': { pattern: /\d/, default: '0' }, '9': { pattern: /\d/ }, '#': { pattern: /[a-zA-Z0-9]/ }, U: {
|
41
|
+
pattern: /[a-zA-Z]/,
|
42
|
+
transform: char => char.toLocaleUpperCase()
|
43
|
+
}, L: {
|
44
|
+
pattern: /[a-zA-Z]/,
|
45
|
+
transform: char => char.toLocaleLowerCase()
|
46
|
+
}, '*': {
|
47
|
+
pattern: /.*/,
|
48
|
+
transform: _ => `*`
|
49
|
+
} }, opt.tokens);
|
50
|
+
const splitValue = value.split('');
|
51
|
+
return opt.mask
|
52
|
+
.split('')
|
53
|
+
.reduce((res, cur) => {
|
54
|
+
var _a;
|
55
|
+
const token = tokens[cur];
|
56
|
+
if (!token) {
|
57
|
+
res.push(cur);
|
58
|
+
return res;
|
59
|
+
}
|
60
|
+
const value = (_a = splitValue.shift()) !== null && _a !== void 0 ? _a : '';
|
61
|
+
if (!token.pattern.test(value)) {
|
62
|
+
if (token.default)
|
63
|
+
res.push(token.default);
|
64
|
+
return res;
|
65
|
+
}
|
66
|
+
if (typeof token.transform === 'function') {
|
67
|
+
res.push(token.transform(value));
|
68
|
+
}
|
69
|
+
else {
|
70
|
+
res.push(value);
|
71
|
+
}
|
72
|
+
return res;
|
73
|
+
}, [])
|
74
|
+
.join('');
|
75
|
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JyonOiB7XG4gICAgICBwYXR0ZXJuOiAvLiovLFxuICAgICAgdHJhbnNmb3JtOiBfID0+IGAqYFxuICAgIH0sXG4gICAgLi4ub3B0LnRva2Vuc1xuICB9O1xuXG4gIGNvbnN0IHNwbGl0VmFsdWUgPSB2YWx1ZS5zcGxpdCgnJyk7XG4gIHJldHVybiBvcHQubWFza1xuICAgIC5zcGxpdCgnJylcbiAgICAucmVkdWNlKChyZXMsIGN1cikgPT4ge1xuICAgICAgY29uc3QgdG9rZW4gPSB0b2tlbnNbY3VyXTtcbiAgICAgIGlmICghdG9rZW4pIHtcbiAgICAgICAgcmVzLnB1c2goY3VyKTtcbiAgICAgICAgcmV0dXJuIHJlcztcbiAgICAgIH1cblxuICAgICAgY29uc3QgdmFsdWUgPSBzcGxpdFZhbHVlLnNoaWZ0KCkgPz8gJyc7XG4gICAgICBpZiAoIXRva2VuLnBhdHRlcm4udGVzdCh2YWx1ZSkpIHtcbiAgICAgICAgaWYgKHRva2VuLmRlZmF1bHQpIHJlcy5wdXNoKHRva2VuLmRlZmF1bHQpO1xuICAgICAgICByZXR1cm4gcmVzO1xuICAgICAgfVxuXG4gICAgICBpZiAodHlwZW9mIHRva2VuLnRyYW5zZm9ybSA9PT0gJ2Z1bmN0aW9uJykge1xuICAgICAgICByZXMucHVzaCh0b2tlbi50cmFuc2Zvcm0odmFsdWUpKTtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIHJlcy5wdXNoKHZhbHVlKTtcbiAgICAgIH1cbiAgICAgIHJldHVybiByZXM7XG4gICAgfSwgW10gYXMgc3RyaW5nW10pXG4gICAgLmpvaW4oJycpO1xufVxuIl19
|
@@ -1,94 +1,94 @@
|
|
1
|
-
export const REGEX_STR = {
|
2
|
-
num: `((-?\\d+\\.\\d+)|(-?\\d+)|(-?\\.\\d+))`,
|
3
|
-
idCard: `(^\\d{15}$)|(^\\d{17}(?:[0-9]|X)$)`,
|
4
|
-
mobile: `^(0|\\+?86|17951)?1[0-9]{10}$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:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,5}|:)|(?:[a-fA-F\\d]{1,4}:){1}(?:(?::[a-fA-F\\d]{1,4}){0,4}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,6}|:)|(?::(?:(?::[a-fA-F\\d]{1,4}){0,5}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,7}|:)))(?:%[0-9a-zA-Z]{1,})?$)`,
|
7
|
-
color: `(?:#|0x)(?:[a-f0-9]{3}|[a-f0-9]{6})\\b|(?:rgb|hsl)a?\\([^\\)]*\\)`,
|
8
|
-
chinese: `[\u4e00-\u9fa5]+`
|
9
|
-
};
|
10
|
-
function genRegex(str, flags) {
|
11
|
-
return new RegExp(`^${str}$`, flags);
|
12
|
-
}
|
13
|
-
export const REGEX = {
|
14
|
-
num: genRegex(REGEX_STR.num),
|
15
|
-
idCard: genRegex(REGEX_STR.idCard, 'i'),
|
16
|
-
mobile: genRegex(REGEX_STR.mobile),
|
17
|
-
url: genRegex(REGEX_STR.url),
|
18
|
-
ip: genRegex(REGEX_STR.ip),
|
19
|
-
color: genRegex(REGEX_STR.color),
|
20
|
-
chinese: genRegex(REGEX_STR.chinese)
|
21
|
-
};
|
22
|
-
/**
|
23
|
-
* Wheter is number
|
24
|
-
*
|
25
|
-
* 是否为数字
|
26
|
-
*/
|
27
|
-
export function isNum(value) {
|
28
|
-
return REGEX.num.test(value.toString());
|
29
|
-
}
|
30
|
-
/**
|
31
|
-
* Wheter is integer
|
32
|
-
*
|
33
|
-
* 是否为整数
|
34
|
-
*/
|
35
|
-
export function isInt(value) {
|
36
|
-
return isNum(value) && parseInt(value.toString(), 10).toString() === value.toString();
|
37
|
-
}
|
38
|
-
/**
|
39
|
-
* Wheter is decimal
|
40
|
-
*
|
41
|
-
* 是否为小数点数值
|
42
|
-
*/
|
43
|
-
export function isDecimal(value) {
|
44
|
-
return isNum(value) && !isInt(value);
|
45
|
-
}
|
46
|
-
/**
|
47
|
-
* Wheter is People's Republic of China identity card
|
48
|
-
*
|
49
|
-
* 是否为中华人民共和国居民身份证
|
50
|
-
*/
|
51
|
-
export function isIdCard(value) {
|
52
|
-
return REGEX.idCard.test(value);
|
53
|
-
}
|
54
|
-
/**
|
55
|
-
* Wheter is china mobile (China)
|
56
|
-
*
|
57
|
-
* 是否为手机号(中国)
|
58
|
-
*/
|
59
|
-
export function isMobile(value) {
|
60
|
-
return REGEX.mobile.test(value);
|
61
|
-
}
|
62
|
-
/**
|
63
|
-
* Wheter is url address
|
64
|
-
*
|
65
|
-
* 是否URL地址
|
66
|
-
*/
|
67
|
-
export function isUrl(url) {
|
68
|
-
return REGEX.url.test(url);
|
69
|
-
}
|
70
|
-
/**
|
71
|
-
* Wheter is IPv4 address (Support v4, v6)
|
72
|
-
*
|
73
|
-
* 是否IP4地址(支持v4、v6)
|
74
|
-
*/
|
75
|
-
export function isIp(ip) {
|
76
|
-
return REGEX.ip.test(ip);
|
77
|
-
}
|
78
|
-
/**
|
79
|
-
* Wheter is color
|
80
|
-
*
|
81
|
-
* 是否颜色代码值
|
82
|
-
*/
|
83
|
-
export function isColor(color) {
|
84
|
-
return REGEX.color.test(color);
|
85
|
-
}
|
86
|
-
/**
|
87
|
-
* Wheter is chinese
|
88
|
-
*
|
89
|
-
* 是否中文
|
90
|
-
*/
|
91
|
-
export function isChinese(value) {
|
92
|
-
return REGEX.chinese.test(value);
|
93
|
-
}
|
1
|
+
export const REGEX_STR = {
|
2
|
+
num: `((-?\\d+\\.\\d+)|(-?\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|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,4}|:)|(?:[a-fA-F\\d]{1,4}:){2}(?:(?::[a-fA-F\\d]{1,4}){0,3}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,5}|:)|(?:[a-fA-F\\d]{1,4}:){1}(?:(?::[a-fA-F\\d]{1,4}){0,4}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,6}|:)|(?::(?:(?::[a-fA-F\\d]{1,4}){0,5}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,7}|:)))(?:%[0-9a-zA-Z]{1,})?$)`,
|
7
|
+
color: `(?:#|0x)(?:[a-f0-9]{3}|[a-f0-9]{6})\\b|(?:rgb|hsl)a?\\([^\\)]*\\)`,
|
8
|
+
chinese: `[\u4e00-\u9fa5]+`
|
9
|
+
};
|
10
|
+
function genRegex(str, flags) {
|
11
|
+
return new RegExp(`^${str}$`, flags);
|
12
|
+
}
|
13
|
+
export const REGEX = {
|
14
|
+
num: genRegex(REGEX_STR.num),
|
15
|
+
idCard: genRegex(REGEX_STR.idCard, 'i'),
|
16
|
+
mobile: genRegex(REGEX_STR.mobile),
|
17
|
+
url: genRegex(REGEX_STR.url),
|
18
|
+
ip: genRegex(REGEX_STR.ip),
|
19
|
+
color: genRegex(REGEX_STR.color),
|
20
|
+
chinese: genRegex(REGEX_STR.chinese)
|
21
|
+
};
|
22
|
+
/**
|
23
|
+
* Wheter is number
|
24
|
+
*
|
25
|
+
* 是否为数字
|
26
|
+
*/
|
27
|
+
export function isNum(value) {
|
28
|
+
return REGEX.num.test(value.toString());
|
29
|
+
}
|
30
|
+
/**
|
31
|
+
* Wheter is integer
|
32
|
+
*
|
33
|
+
* 是否为整数
|
34
|
+
*/
|
35
|
+
export function isInt(value) {
|
36
|
+
return isNum(value) && parseInt(value.toString(), 10).toString() === value.toString();
|
37
|
+
}
|
38
|
+
/**
|
39
|
+
* Wheter is decimal
|
40
|
+
*
|
41
|
+
* 是否为小数点数值
|
42
|
+
*/
|
43
|
+
export function isDecimal(value) {
|
44
|
+
return isNum(value) && !isInt(value);
|
45
|
+
}
|
46
|
+
/**
|
47
|
+
* Wheter is People's Republic of China identity card
|
48
|
+
*
|
49
|
+
* 是否为中华人民共和国居民身份证
|
50
|
+
*/
|
51
|
+
export function isIdCard(value) {
|
52
|
+
return REGEX.idCard.test(value);
|
53
|
+
}
|
54
|
+
/**
|
55
|
+
* Wheter is china mobile (China)
|
56
|
+
*
|
57
|
+
* 是否为手机号(中国)
|
58
|
+
*/
|
59
|
+
export function isMobile(value) {
|
60
|
+
return REGEX.mobile.test(value);
|
61
|
+
}
|
62
|
+
/**
|
63
|
+
* Wheter is url address
|
64
|
+
*
|
65
|
+
* 是否URL地址
|
66
|
+
*/
|
67
|
+
export function isUrl(url) {
|
68
|
+
return REGEX.url.test(url);
|
69
|
+
}
|
70
|
+
/**
|
71
|
+
* Wheter is IPv4 address (Support v4, v6)
|
72
|
+
*
|
73
|
+
* 是否IP4地址(支持v4、v6)
|
74
|
+
*/
|
75
|
+
export function isIp(ip) {
|
76
|
+
return REGEX.ip.test(ip);
|
77
|
+
}
|
78
|
+
/**
|
79
|
+
* Wheter is color
|
80
|
+
*
|
81
|
+
* 是否颜色代码值
|
82
|
+
*/
|
83
|
+
export function isColor(color) {
|
84
|
+
return REGEX.color.test(color);
|
85
|
+
}
|
86
|
+
/**
|
87
|
+
* Wheter is chinese
|
88
|
+
*
|
89
|
+
* 是否中文
|
90
|
+
*/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BhZGRyZXNzIChTdXBwb3J0IHY0LCB2NilcbiAqXG4gKiDmmK/lkKZJUDTlnLDlnYDvvIjmlK/mjIF2NOOAgXY277yJXG4gKi9cbmV4cG9ydCBmdW5jdGlvbiBpc0lwKGlwOiBzdHJpbmcpOiBib29sZWFuIHtcbiAgcmV0dXJuIFJFR0VYLmlwLnRlc3QoaXApO1xufVxuXG4vKipcbiAqIFdoZXRlciBpcyBjb2xvclxuICpcbiAqIOaYr+WQpuminOiJsuS7o+eggeWAvFxuICovXG5leHBvcnQgZnVuY3Rpb24gaXNDb2xvcihjb2xvcjogc3RyaW5nKTogYm9vbGVhbiB7XG4gIHJldHVybiBSRUdFWC5jb2xvci50ZXN0KGNvbG9yKTtcbn1cblxuLyoqXG4gKiBXaGV0ZXIgaXMgY2hpbmVzZVxuICpcbiAqIOaYr+WQpuS4reaWh1xuICovXG5leHBvcnQgZnVuY3Rpb24gaXNDaGluZXNlKHZhbHVlOiBzdHJpbmcpOiBib29sZWFuIHtcbiAgcmV0dXJuIFJFR0VYLmNoaW5lc2UudGVzdCh2YWx1ZSk7XG59XG4iXX0=
|
@@ -1,5 +1,5 @@
|
|
1
|
-
/**
|
2
|
-
* Generated bundle index. Do not edit.
|
3
|
-
*/
|
4
|
-
export * from './index';
|
1
|
+
/**
|
2
|
+
* Generated bundle index. Do not edit.
|
3
|
+
*/
|
4
|
+
export * from './index';
|
5
5
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoieWVsb24tdXRpbC1mb3JtYXQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy91dGlsL2Zvcm1hdC95ZWxvbi11dGlsLWZvcm1hdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7R0FFRztBQUVILGNBQWMsU0FBUyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBHZW5lcmF0ZWQgYnVuZGxlIGluZGV4LiBEbyBub3QgZWRpdC5cbiAqL1xuXG5leHBvcnQgKiBmcm9tICcuL2luZGV4JztcbiJdfQ==
|
package/esm2015/index.js
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
export * from '@yelon/util/array';
|
2
|
-
export * from '@yelon/util/browser';
|
3
|
-
export * from '@yelon/util/config';
|
4
|
-
export * from '@yelon/util/date-time';
|
5
|
-
export * from '@yelon/util/form';
|
6
|
-
export * from '@yelon/util/format';
|
7
|
-
export * from '@yelon/util/math';
|
8
|
-
export * from '@yelon/util/decorator';
|
9
|
-
export * from '@yelon/util/other';
|
10
|
-
export * from '@yelon/util/pipes';
|
11
|
-
export * from '@yelon/util/token';
|
1
|
+
export * from '@yelon/util/array';
|
2
|
+
export * from '@yelon/util/browser';
|
3
|
+
export * from '@yelon/util/config';
|
4
|
+
export * from '@yelon/util/date-time';
|
5
|
+
export * from '@yelon/util/form';
|
6
|
+
export * from '@yelon/util/format';
|
7
|
+
export * from '@yelon/util/math';
|
8
|
+
export * from '@yelon/util/decorator';
|
9
|
+
export * from '@yelon/util/other';
|
10
|
+
export * from '@yelon/util/pipes';
|
11
|
+
export * from '@yelon/util/token';
|
12
12
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9wYWNrYWdlcy91dGlsL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMsbUJBQW1CLENBQUM7QUFDbEMsY0FBYyxxQkFBcUIsQ0FBQztBQUNwQyxjQUFjLG9CQUFvQixDQUFDO0FBQ25DLGNBQWMsdUJBQXVCLENBQUM7QUFDdEMsY0FBYyxrQkFBa0IsQ0FBQztBQUNqQyxjQUFjLG9CQUFvQixDQUFDO0FBQ25DLGNBQWMsa0JBQWtCLENBQUM7QUFDakMsY0FBYyx1QkFBdUIsQ0FBQztBQUN0QyxjQUFjLG1CQUFtQixDQUFDO0FBQ2xDLGNBQWMsbUJBQW1CLENBQUM7QUFDbEMsY0FBYyxtQkFBbUIsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCAqIGZyb20gJ0B5ZWxvbi91dGlsL2FycmF5JztcbmV4cG9ydCAqIGZyb20gJ0B5ZWxvbi91dGlsL2Jyb3dzZXInO1xuZXhwb3J0ICogZnJvbSAnQHllbG9uL3V0aWwvY29uZmlnJztcbmV4cG9ydCAqIGZyb20gJ0B5ZWxvbi91dGlsL2RhdGUtdGltZSc7XG5leHBvcnQgKiBmcm9tICdAeWVsb24vdXRpbC9mb3JtJztcbmV4cG9ydCAqIGZyb20gJ0B5ZWxvbi91dGlsL2Zvcm1hdCc7XG5leHBvcnQgKiBmcm9tICdAeWVsb24vdXRpbC9tYXRoJztcbmV4cG9ydCAqIGZyb20gJ0B5ZWxvbi91dGlsL2RlY29yYXRvcic7XG5leHBvcnQgKiBmcm9tICdAeWVsb24vdXRpbC9vdGhlcic7XG5leHBvcnQgKiBmcm9tICdAeWVsb24vdXRpbC9waXBlcyc7XG5leHBvcnQgKiBmcm9tICdAeWVsb24vdXRpbC90b2tlbic7XG4iXX0=
|
package/esm2015/math/in-range.js
CHANGED
@@ -1,25 +1,25 @@
|
|
1
|
-
import { assertNumber } from '@yelon/util/other';
|
2
|
-
/**
|
3
|
-
* Checks if `value` is between `start` and `end` to, but not including `end`. If `end` is not specified, it's set to start with `start` then set to `0`. If `start` is greater than `end` the params are swapped to support negative ranges.
|
4
|
-
*
|
5
|
-
* 检查 `value` 是否在 `start` 与 `end` 之间,但不包括 `end`。 如果 `end` 没有指定,那么 `start` 设置为 `0`。 如果 `start` 大于 `end`,那么参数会交换以便支持负范围。
|
6
|
-
* ```ts
|
7
|
-
* inRange(3, 2, 4); // true
|
8
|
-
* inRange(4, 8); // true
|
9
|
-
* inRange(4, 2); // false
|
10
|
-
* inRange(2, 2); // false
|
11
|
-
* inRange(1.2, 2); // true
|
12
|
-
* inRange(-3, -2, -6); // true
|
13
|
-
* ```
|
14
|
-
*/
|
15
|
-
export function inRange(value, start, end) {
|
16
|
-
if (end === undefined) {
|
17
|
-
end = start;
|
18
|
-
start = 0;
|
19
|
-
}
|
20
|
-
assertNumber(value);
|
21
|
-
assertNumber(start);
|
22
|
-
assertNumber(end);
|
23
|
-
return value >= Math.min(start, end) && value < Math.max(start, end);
|
24
|
-
}
|
1
|
+
import { assertNumber } from '@yelon/util/other';
|
2
|
+
/**
|
3
|
+
* Checks if `value` is between `start` and `end` to, but not including `end`. If `end` is not specified, it's set to start with `start` then set to `0`. If `start` is greater than `end` the params are swapped to support negative ranges.
|
4
|
+
*
|
5
|
+
* 检查 `value` 是否在 `start` 与 `end` 之间,但不包括 `end`。 如果 `end` 没有指定,那么 `start` 设置为 `0`。 如果 `start` 大于 `end`,那么参数会交换以便支持负范围。
|
6
|
+
* ```ts
|
7
|
+
* inRange(3, 2, 4); // true
|
8
|
+
* inRange(4, 8); // true
|
9
|
+
* inRange(4, 2); // false
|
10
|
+
* inRange(2, 2); // false
|
11
|
+
* inRange(1.2, 2); // true
|
12
|
+
* inRange(-3, -2, -6); // true
|
13
|
+
* ```
|
14
|
+
*/
|
15
|
+
export function inRange(value, start, end) {
|
16
|
+
if (end === undefined) {
|
17
|
+
end = start;
|
18
|
+
start = 0;
|
19
|
+
}
|
20
|
+
assertNumber(value);
|
21
|
+
assertNumber(start);
|
22
|
+
assertNumber(end);
|
23
|
+
return value >= Math.min(start, end) && value < Math.max(start, end);
|
24
|
+
}
|
25
25
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW4tcmFuZ2UuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy91dGlsL21hdGgvaW4tcmFuZ2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQU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lbmRgIOS5i+mXtO+8jOS9huS4jeWMheaLrCBgZW5kYOOAgiDlpoLmnpwgYGVuZGAg5rKh5pyJ5oyH5a6a77yM6YKj5LmIIGBzdGFydGAg6K6+572u5Li6IGAwYOOAgiDlpoLmnpwgYHN0YXJ0YCDlpKfkuo4gYGVuZGDvvIzpgqPkuYjlj4LmlbDkvJrkuqTmjaLku6Xkvr/mlK/mjIHotJ/ojIPlm7TjgIJcbiAqIGBgYHRzXG4gKiBpblJhbmdlKDMsIDIsIDQpOyAvLyB0cnVlXG4gKiBpblJhbmdlKDQsIDgpOyAvLyB0cnVlXG4gKiBpblJhbmdlKDQsIDIpOyAvLyBmYWxzZVxuICogaW5SYW5nZSgyLCAyKTsgLy8gZmFsc2VcbiAqIGluUmFuZ2UoMS4yLCAyKTsgLy8gdHJ1ZVxuICogaW5SYW5nZSgtMywgLTIsIC02KTsgLy8gdHJ1ZVxuICogYGBgXG4gKi9cbmV4cG9ydCBmdW5jdGlvbiBpblJhbmdlKHZhbHVlOiBudW1iZXIsIHN0YXJ0OiBudW1iZXIsIGVuZD86IG51bWJlcik6IGJvb2xlYW4ge1xuICBpZiAoZW5kID09PSB1bmRlZmluZWQpIHtcbiAgICBlbmQgPSBzdGFydDtcbiAgICBzdGFydCA9IDA7XG4gIH1cbiAgYXNzZXJ0TnVtYmVyKHZhbHVlKTtcbiAgYXNzZXJ0TnVtYmVyKHN0YXJ0KTtcbiAgYXNzZXJ0TnVtYmVyKGVuZCk7XG4gIHJldHVybiB2YWx1ZSA+PSBNYXRoLm1pbihzdGFydCwgZW5kKSAmJiB2YWx1ZSA8IE1hdGgubWF4KHN0YXJ0LCBlbmQpO1xufVxuIl19
|
package/esm2015/math/index.js
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
export * from './in-range';
|
2
|
-
export * from './round';
|
1
|
+
export * from './in-range';
|
2
|
+
export * from './round';
|
3
3
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy91dGlsL21hdGgvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYyxZQUFZLENBQUM7QUFDM0IsY0FBYyxTQUFTLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgKiBmcm9tICcuL2luLXJhbmdlJztcbmV4cG9ydCAqIGZyb20gJy4vcm91bmQnO1xuIl19
|
package/esm2015/math/round.js
CHANGED
@@ -1,53 +1,53 @@
|
|
1
|
-
/**
|
2
|
-
* Computes `number` rounded up to `precision`.
|
3
|
-
*
|
4
|
-
* 根据 `precision`(精度) 向上舍入 `number`。
|
5
|
-
* ```ts
|
6
|
-
* ceil(4.006); // 5
|
7
|
-
* ceil(6.004, 2); // 6.01
|
8
|
-
* ceil(6040, -2); // 6100
|
9
|
-
* ```
|
10
|
-
*/
|
11
|
-
export function ceil(number, precision = 0) {
|
12
|
-
return createRound(number, precision, 'ceil');
|
13
|
-
}
|
14
|
-
/**
|
15
|
-
* Computes `number` rounded down to `precision`.
|
16
|
-
*
|
17
|
-
* 根据 `precision`(精度) 向下舍入 `number`。
|
18
|
-
* ```ts
|
19
|
-
* floor(4.006); // 4
|
20
|
-
* floor(0.046, 2); // 0.04
|
21
|
-
* floor(4060, -2); // 4000
|
22
|
-
* ```
|
23
|
-
*/
|
24
|
-
export function floor(number, precision = 0) {
|
25
|
-
return createRound(number, precision, 'floor');
|
26
|
-
}
|
27
|
-
/**
|
28
|
-
* Computes `number` rounded to `precision`.
|
29
|
-
*
|
30
|
-
* 根据 `precision`(精度) 四舍五入 `number`。
|
31
|
-
* ```ts
|
32
|
-
* round(4.006); // 4
|
33
|
-
* round(4.006, 2); // 4.01
|
34
|
-
* round(4060, -2); // 4100
|
35
|
-
* ```
|
36
|
-
*/
|
37
|
-
export function round(number, precision = 0) {
|
38
|
-
return createRound(number, precision, 'round');
|
39
|
-
}
|
40
|
-
function createRound(number, precision, methodName) {
|
41
|
-
const func = Math[methodName];
|
42
|
-
precision = precision == null ? 0 : Math.min(precision, 292);
|
43
|
-
if (!precision) {
|
44
|
-
return func(number);
|
45
|
-
}
|
46
|
-
// Shift with exponential notation to avoid floating-point issues.
|
47
|
-
// See [MDN](https://mdn.io/round#Examples) for more details.
|
48
|
-
let pair = `${number}e`.split('e');
|
49
|
-
const value = func(Number(`${pair[0]}e${Number(pair[1]) + precision}`));
|
50
|
-
pair = `${value}e`.split('e');
|
51
|
-
return Number(`${pair[0]}e${Number(pair[1]) - precision}`);
|
52
|
-
}
|
1
|
+
/**
|
2
|
+
* Computes `number` rounded up to `precision`.
|
3
|
+
*
|
4
|
+
* 根据 `precision`(精度) 向上舍入 `number`。
|
5
|
+
* ```ts
|
6
|
+
* ceil(4.006); // 5
|
7
|
+
* ceil(6.004, 2); // 6.01
|
8
|
+
* ceil(6040, -2); // 6100
|
9
|
+
* ```
|
10
|
+
*/
|
11
|
+
export function ceil(number, precision = 0) {
|
12
|
+
return createRound(number, precision, 'ceil');
|
13
|
+
}
|
14
|
+
/**
|
15
|
+
* Computes `number` rounded down to `precision`.
|
16
|
+
*
|
17
|
+
* 根据 `precision`(精度) 向下舍入 `number`。
|
18
|
+
* ```ts
|
19
|
+
* floor(4.006); // 4
|
20
|
+
* floor(0.046, 2); // 0.04
|
21
|
+
* floor(4060, -2); // 4000
|
22
|
+
* ```
|
23
|
+
*/
|
24
|
+
export function floor(number, precision = 0) {
|
25
|
+
return createRound(number, precision, 'floor');
|
26
|
+
}
|
27
|
+
/**
|
28
|
+
* Computes `number` rounded to `precision`.
|
29
|
+
*
|
30
|
+
* 根据 `precision`(精度) 四舍五入 `number`。
|
31
|
+
* ```ts
|
32
|
+
* round(4.006); // 4
|
33
|
+
* round(4.006, 2); // 4.01
|
34
|
+
* round(4060, -2); // 4100
|
35
|
+
* ```
|
36
|
+
*/
|
37
|
+
export function round(number, precision = 0) {
|
38
|
+
return createRound(number, precision, 'round');
|
39
|
+
}
|
40
|
+
function createRound(number, precision, methodName) {
|
41
|
+
const func = Math[methodName];
|
42
|
+
precision = precision == null ? 0 : Math.min(precision, 292);
|
43
|
+
if (!precision) {
|
44
|
+
return func(number);
|
45
|
+
}
|
46
|
+
// Shift with exponential notation to avoid floating-point issues.
|
47
|
+
// See [MDN](https://mdn.io/round#Examples) for more details.
|
48
|
+
let pair = `${number}e`.split('e');
|
49
|
+
const value = func(Number(`${pair[0]}e${Number(pair[1]) + precision}`));
|
50
|
+
pair = `${value}e`.split('e');
|
51
|
+
return Number(`${pair[0]}e${Number(pair[1]) - precision}`);
|
52
|
+
}
|
53
53
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicm91bmQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy91dGlsL21hdGgvcm91bmQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7Ozs7OztHQVNHO0FBQ0gsTUFBTSxVQUFVLElBQUksQ0FBQyxNQUFjLEVBQUUsWUFBb0IsQ0FBQztJQUN4RCxPQUFPLFdBQVcsQ0FBQyxNQUFNLEVBQUUsU0FBUyxFQUFFLE1BQU0sQ0FBQyxDQUFDO0FBQ2hELENBQUM7QUFFRDs7Ozs7Ozs7O0dBU0c7QUFDSCxNQUFNLFVBQVUsS0FBSyxDQUFDLE1BQWMsRUFBRSxZQUFvQixDQUFDO0lBQ3pELE9BQU8sV0FBVyxDQUFDLE1BQU0sRUFBRSxTQUFTLEVBQUUsT0FBTyxDQUFDLENBQUM7QUFDakQsQ0FBQztBQUVEOzs7Ozs7Ozs7R0FTRztBQUNILE1BQU0sVUFBVSxLQUFLLENBQUMsTUFBYyxFQUFFLFlBQW9CLENBQUM7SUFDekQsT0FBTyxXQUFXLENBQUMsTUFBTSxFQUFFLFNBQVMsRUFBR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-
* Generated bundle index. Do not edit.
|
3
|
-
*/
|
4
|
-
export * from './index';
|
1
|
+
/**
|
2
|
+
* Generated bundle index. Do not edit.
|
3
|
+
*/
|
4
|
+
export * from './index';
|
5
5
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoieWVsb24tdXRpbC1tYXRoLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvdXRpbC9tYXRoL3llbG9uLXV0aWwtbWF0aC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7R0FFRztBQUVILGNBQWMsU0FBUyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBHZW5lcmF0ZWQgYnVuZGxlIGluZGV4LiBEbyBub3QgZWRpdC5cbiAqL1xuXG5leHBvcnQgKiBmcm9tICcuL2luZGV4JztcbiJdfQ==
|