forked from mongo-express/mongo-express
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfilters.js
More file actions
23 lines (21 loc) · 680 Bytes
/
Copy pathfilters.js
File metadata and controls
23 lines (21 loc) · 680 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
exports.json = function(input) {
return JSON.stringify(input, null, ' ');
};
exports.convertBytes = function(input) {
input = parseInt(input, 10);
if (input < 1024) {
return input.toString() + ' Bytes';
} else if (input < 1024 * 1024) {
//Convert to KB and keep 2 decimal values
input = Math.round((input / 1024) * 100) / 100;
return input.toString() + ' KB';
} else if (input < 1024 * 1024 * 1024) {
input = Math.round((input / (1024 * 1024)) * 100) / 100;
return input.toString() + ' MB';
} else {
return input.toString() + ' Bytes';
}
};
exports.to_string = function (input) {
return input != null ? input.toString() : "";
};