@zohodesk/utils 1.1.1 → 1.3.2
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/es/abbreviateNumber.js +9 -9
- package/es/replaceAtLast.js +1 -1
- package/package.json +2 -2
package/es/abbreviateNumber.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @param {number|string} count
|
|
4
|
-
* @param {object} options
|
|
5
|
-
* @param {string} options.locale
|
|
2
|
+
*
|
|
3
|
+
* @param {number|string} count
|
|
4
|
+
* @param {object} options
|
|
5
|
+
* @param {string} options.locale
|
|
6
6
|
* @param {boolean} options.withAbbr
|
|
7
7
|
* @param {number} options.decimals
|
|
8
|
-
* @returns
|
|
8
|
+
* @returns
|
|
9
9
|
*/
|
|
10
10
|
export default function abbreviateNumber() {
|
|
11
11
|
let count = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
12
12
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
13
|
-
if (typeof count ===
|
|
13
|
+
if (typeof count === 'string') {
|
|
14
14
|
count = parseInt(count);
|
|
15
15
|
}
|
|
16
16
|
if (global.Intl && global.Intl.NumberFormat) {
|
|
17
|
-
let numberFormat = Intl.NumberFormat(options.locale ||
|
|
18
|
-
notation:
|
|
17
|
+
let numberFormat = Intl.NumberFormat(options.locale || 'en', {
|
|
18
|
+
notation: 'compact'
|
|
19
19
|
// compactDisplay: "short",
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
return numberFormat.format(count);
|
|
23
23
|
}
|
|
24
24
|
//Comaptibility
|
|
25
|
-
const COUNT_ABBRS = [
|
|
25
|
+
const COUNT_ABBRS = ['', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'];
|
|
26
26
|
let {
|
|
27
27
|
withAbbr = true,
|
|
28
28
|
decimals = 2
|
package/es/replaceAtLast.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zohodesk/utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "Unified Component Library - Utils",
|
|
5
5
|
"main": "es/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"es",
|
|
32
32
|
"!**/__tests__"
|
|
33
33
|
],
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "2be0000a29c7397a9b24e391b328fbe3ecd13156"
|
|
35
35
|
}
|