1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"use strict";
export const round = (num, places) => {
const factor = Math.pow(10, places);
return Math.round(num * factor) / factor;
};
export const pad = (string, amount) => Array(amount).join('0').substr(0, amount - String(string).length) + string;
export const formatDate = (date) => (
'' +
date.getFullYear() +
'/' +
pad(date.getMonth() + 1, 2) +
'/' +
pad(date.getDate(), 2) +
' ' +
date.getHours() +
':' +
pad(date.getMinutes(), 2)
);
export const weekdays = ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];
export const months = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sept","Oct","Nov","Dec"];
export const get = (obj, path, def) => {
path.forEach(p => {
if (obj) obj = obj[p];
});
return obj || def;
};