the-shepherd
Version:
Control a herd of wild processes.
56 lines (44 loc) • 1.16 kB
JavaScript
// Generated by CoffeeScript 2.5.1
(function() {
var days, formatUptime, hours, int, mins, secs, trueFalse, weeks, yesNo;
int = function(n) {
return parseInt(n != null ? n : 0, 10);
};
yesNo = function(v) {
if (v) {
return "yes";
} else {
return "no";
}
};
secs = 1000;
mins = 60 * secs;
hours = 60 * mins;
days = 24 * hours;
weeks = 7 * days;
formatUptime = function(ms) {
var d, h, m, s, t, v, w;
w = Math.floor(ms / weeks);
t = ms - (w * weeks);
d = Math.floor(t / days);
t = t - (d * days);
h = Math.floor(t / hours);
t = t - (h * hours);
m = Math.floor(t / mins);
t = t - (m * mins);
s = Math.floor(t / secs);
t = t - (s * secs);
v = $("w d h m s".split(" ")).weave($(w, d, h, m, s));
(d || w) && v.splice(-2, 2); // omit seconds if there are days
w && v.splice(-2, 2); // omit minutes if there are weeks
return v.join('').replace(/^(0[wdhm])*/, '');
};
trueFalse = function(v) {
if (v) {
return true;
} else {
return false;
}
};
module.exports = {yesNo, formatUptime, trueFalse, int};
}).call(this);