This commit is contained in:
syuilo 2018-02-27 02:17:10 +09:00
parent d3639b2df4
commit 15c94f6b81
5 changed files with 10 additions and 4 deletions

View file

@ -0,0 +1,8 @@
import Vue from 'vue';
Vue.filter('bytes', (v, digits = 0) => {
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
if (v == 0) return '0Byte';
const i = Math.floor(Math.log(v) / Math.log(1024));
return (v / Math.pow(1024, i)).toFixed(digits).replace(/\.0+$/, '') + sizes[i];
});

View file

@ -0,0 +1,2 @@
require('./bytes');
require('./number');

View file

@ -0,0 +1,5 @@
import Vue from 'vue';
Vue.filter('number', (n) => {
return n.toLocaleString();
});