UNPKG

saven

Version:
49 lines (48 loc) 1.37 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const path = require("path"); const isEmptyObject = function (obj) { if (obj == null) { return true; } for (const key in obj) { if (obj.hasOwnProperty(key)) { return false; } } return true; }; exports.isEmptyObject = isEmptyObject; const getRootPath = function () { return path.resolve(__dirname, '../../'); }; exports.getRootPath = getRootPath; const zeroPad = function (num, places) { const zero = places - num.toString().length + 1; return Array(+(zero > 0 && zero)).join('0') + num; }; exports.zeroPad = zeroPad; const formatTime = function (date) { if (!date) { date = new Date(); } else if (!(date instanceof Date)) { date = new Date(date); } const year = date.getFullYear(); const month = date.getMonth() + 1; const day = date.getDate(); const hour = date.getHours(); const minute = date.getMinutes(); return `${year}-${zeroPad(month, 2)}-${zeroPad(day, 2)} ${zeroPad(hour, 2)}:${zeroPad(minute, 2)}`; }; exports.formatTime = formatTime; const appPath = process.cwd(); exports.appPath = appPath; const emptyObj = {}; exports.emptyObj = emptyObj; const emptyTogglableObj = { enable: false, config: {} }; exports.emptyTogglableObj = emptyTogglableObj;