mirror of
https://github.com/1disk/edp445.git
synced 2024-08-14 22:47:02 +00:00
Changed alot of things.
This commit is contained in:
parent
a5a0523e5a
commit
3513d5390c
2016 changed files with 336930 additions and 9 deletions
24
node_modules/canvacord/plugins/abbrev.js
generated
vendored
Normal file
24
node_modules/canvacord/plugins/abbrev.js
generated
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
module.exports = num => {
|
||||
if (!num || isNaN(num)) return "0";
|
||||
if (typeof num === "string") num = parseInt(num);
|
||||
|
||||
if (typeof Intl !== "undefined") {
|
||||
return new Intl.NumberFormat("en", { notation: "compact" }).format(num);
|
||||
} else {
|
||||
let decPlaces = Math.pow(10, 1);
|
||||
var abbrev = ["K", "M", "B", "T"];
|
||||
for (var i = abbrev.length - 1; i >= 0; i--) {
|
||||
var size = Math.pow(10, (i + 1) * 3);
|
||||
if (size <= num) {
|
||||
num = Math.round((num * decPlaces) / size) / decPlaces;
|
||||
if (num == 1000 && i < abbrev.length - 1) {
|
||||
num = 1;
|
||||
i++;
|
||||
}
|
||||
num += abbrev[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return `${num}`;
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue