@solar-taro/core 1.1.13 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/package.json +1 -1
- package/pipes/index.d.ts +1 -1
- package/pipes/index.js +1 -1
- package/pipes/index.js.map +1 -1
- package/pipes/number.d.ts +7 -0
- package/pipes/number.js +19 -0
- package/pipes/number.js.map +1 -0
- package/utils/index.d.ts +0 -1
- package/utils/index.js +0 -1
- package/utils/index.js.map +1 -1
- package/pipes/amount.d.ts +0 -7
- package/pipes/amount.js +0 -24
- package/pipes/amount.js.map +0 -1
- package/utils/math.d.ts +0 -6
- package/utils/math.js +0 -9
- package/utils/math.js.map +0 -1
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/pipes/index.d.ts
CHANGED
package/pipes/index.js
CHANGED
package/pipes/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/core/src/pipes/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/core/src/pipes/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AACtB,cAAc,UAAU,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function number(value: number): string;
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated {@link number}
|
|
4
|
+
*/
|
|
5
|
+
export declare const amount: typeof number;
|
|
6
|
+
export declare function fixed(value: number, fixed?: number): string;
|
|
7
|
+
export declare function currency(value: number): string;
|
package/pipes/number.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const FRACTION_DIGITS = 2;
|
|
2
|
+
export function number(value) {
|
|
3
|
+
const fixedValue = +(value || 0).toFixed(FRACTION_DIGITS);
|
|
4
|
+
return fixedValue.toLocaleString('zh-CN', { minimumFractionDigits: FRACTION_DIGITS, maximumFractionDigits: FRACTION_DIGITS });
|
|
5
|
+
}
|
|
6
|
+
;
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated {@link number}
|
|
9
|
+
*/
|
|
10
|
+
export const amount = number;
|
|
11
|
+
export function fixed(value, fixed = FRACTION_DIGITS) {
|
|
12
|
+
return (value || 0).toFixed(fixed);
|
|
13
|
+
}
|
|
14
|
+
;
|
|
15
|
+
export function currency(value) {
|
|
16
|
+
const fixedValue = +(value || 0).toFixed(FRACTION_DIGITS);
|
|
17
|
+
return fixedValue.toLocaleString('zh-CN', { style: 'currency', currency: 'CNY', minimumFractionDigits: FRACTION_DIGITS, maximumFractionDigits: FRACTION_DIGITS });
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=number.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number.js","sourceRoot":"","sources":["../../../../packages/core/src/pipes/number.ts"],"names":[],"mappings":"AAAA,MAAM,eAAe,GAAG,CAAC,CAAA;AAEzB,MAAM,UAAU,MAAM,CAAC,KAAa;IAClC,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,CAAA;IACzD,OAAO,UAAU,CAAC,cAAc,CAAC,OAAO,EAAE,EAAE,qBAAqB,EAAE,eAAe,EAAE,qBAAqB,EAAE,eAAe,EAAE,CAAC,CAAC;AAChI,CAAC;AAAA,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC;AAE7B,MAAM,UAAU,KAAK,CAAC,KAAa,EAAE,KAAK,GAAG,eAAe;IAC1D,OAAO,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AACrC,CAAC;AAAA,CAAC;AAEF,MAAM,UAAU,QAAQ,CAAC,KAAa;IACpC,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,CAAA;IACzD,OAAO,UAAU,CAAC,cAAc,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,qBAAqB,EAAE,eAAe,EAAE,qBAAqB,EAAE,eAAe,EAAE,CAAC,CAAA;AACnK,CAAC"}
|
package/utils/index.d.ts
CHANGED
package/utils/index.js
CHANGED
package/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/core/src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/core/src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA"}
|
package/pipes/amount.d.ts
DELETED
package/pipes/amount.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 将数字格式化成 1,234 这种带逗号的
|
|
3
|
-
*
|
|
4
|
-
* @param value
|
|
5
|
-
* @param accurate 精准模式,启用后会附加小数点
|
|
6
|
-
*/
|
|
7
|
-
export const amount = (value, accurate = true) => {
|
|
8
|
-
const [integer, decimal] = Math.abs(value || 0).toFixed(2).split('.');
|
|
9
|
-
let str = integer
|
|
10
|
-
.split('')
|
|
11
|
-
.reverse()
|
|
12
|
-
.map((char, index) => char + (index > 0 && index % 3 === 0 ? ',' : '') // 每三个数字就加一逗号
|
|
13
|
-
)
|
|
14
|
-
.reverse()
|
|
15
|
-
.join('');
|
|
16
|
-
if (accurate) {
|
|
17
|
-
str += `.${decimal}`;
|
|
18
|
-
}
|
|
19
|
-
if (value < 0) {
|
|
20
|
-
str = `-${str}`;
|
|
21
|
-
}
|
|
22
|
-
return str;
|
|
23
|
-
};
|
|
24
|
-
//# sourceMappingURL=amount.js.map
|
package/pipes/amount.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"amount.js","sourceRoot":"","sources":["../../../../packages/core/src/pipes/amount.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAa,EAAE,QAAQ,GAAG,IAAI,EAAE,EAAE;IACvD,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAEtE,IAAI,GAAG,GAAG,OAAO;SACd,KAAK,CAAC,EAAE,CAAC;SACT,OAAO,EAAE;SACT,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CACnB,IAAI,GAAG,CAAC,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,aAAa;KAC/D;SACA,OAAO,EAAE;SACT,IAAI,CAAC,EAAE,CAAC,CAAC;IAEZ,IAAI,QAAQ,EAAE,CAAC;QACb,GAAG,IAAI,IAAI,OAAO,EAAE,CAAC;IACvB,CAAC;IAED,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACd,GAAG,GAAG,IAAI,GAAG,EAAE,CAAA;IACjB,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC,CAAC"}
|
package/utils/math.d.ts
DELETED
package/utils/math.js
DELETED
package/utils/math.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"math.js","sourceRoot":"","sources":["../../../../packages/core/src/utils/math.ts"],"names":[],"mappings":"AACA;;;;GAIG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,KAAa,EAAE,KAAK,GAAG,CAAC,EAAE,EAAE;IAChD,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AACvF,CAAC,CAAC"}
|