Skip to content

Instantly share code, notes, and snippets.

View junaid-A-khan's full-sized avatar

Junaid Khan junaid-A-khan

View GitHub Profile
@james2doyle
james2doyle / vue.pretty-bytes.filter.js
Last active November 28, 2021 01:07
Vue.js pretty bytes filter. This filter formats bytes into human readable formats
// usage: {{ file.size | prettyBytes }}
Vue.filter('prettyBytes', function (num) {
// jacked from: https://github.com/sindresorhus/pretty-bytes
if (typeof num !== 'number' || isNaN(num)) {
throw new TypeError('Expected a number');
}
var exponent;
var unit;
var neg = num < 0;