mirror of
https://github.com/gnmyt/myspeed.git
synced 2026-02-10 23:58:38 -06:00
17 lines
707 B
JavaScript
17 lines
707 B
JavaScript
module.exports.replaceVariables = (message, variables) => {
|
|
for (const variable in variables)
|
|
message = message.replace(`%${variable}%`, variables[variable]);
|
|
return message;
|
|
}
|
|
|
|
module.exports.mapFixed = (entries, type) => ({
|
|
min: Math.min(...entries.map((entry) => entry[type])),
|
|
max: Math.max(...entries.map((entry) => entry[type])),
|
|
avg: parseFloat((entries.reduce((a, b) => a + b[type], 0) / entries.length).toFixed(2))
|
|
});
|
|
|
|
module.exports.mapRounded = (entries, type) => ({
|
|
min: Math.min(...entries.map((entry) => entry[type])),
|
|
max: Math.max(...entries.map((entry) => entry[type])),
|
|
avg: Math.round(entries.reduce((a, b) => a + b[type], 0) / entries.length)
|
|
}); |