Merge branch 'louislam:master' into master

This commit is contained in:
Ponkhy
2021-08-17 02:55:41 +02:00
committed by GitHub
11 changed files with 104 additions and 45 deletions

View File

@@ -1,6 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.polyfill = exports.debug = exports.ucfirst = exports.sleep = exports.flipStatus = exports.PENDING = exports.UP = exports.DOWN = exports.appName = void 0;
exports.TimeLogger = exports.polyfill = exports.debug = exports.ucfirst = exports.sleep = exports.flipStatus = exports.PENDING = exports.UP = exports.DOWN = exports.appName = exports.isDev = void 0;
const dayjs = require("dayjs");
exports.isDev = process.env.NODE_ENV === "development";
exports.appName = "Uptime Kuma";
exports.DOWN = 0;
exports.UP = 1;
@@ -28,7 +30,7 @@ function ucfirst(str) {
}
exports.ucfirst = ucfirst;
function debug(msg) {
if (process.env.NODE_ENV === "development") {
if (exports.isDev) {
console.log(msg);
}
}
@@ -44,3 +46,14 @@ function polyfill() {
}
}
exports.polyfill = polyfill;
class TimeLogger {
constructor() {
this.startTime = dayjs().valueOf();
}
print(name) {
if (exports.isDev) {
console.log(name + ": " + (dayjs().valueOf() - this.startTime) + "ms");
}
}
}
exports.TimeLogger = TimeLogger;

View File

@@ -4,6 +4,9 @@
// Frontend uses util.ts
// Need to run "tsc" to compile if there are any changes.
import * as dayjs from "dayjs";
export const isDev = process.env.NODE_ENV === "development";
export const appName = "Uptime Kuma";
export const DOWN = 0;
export const UP = 1;
@@ -39,7 +42,7 @@ export function ucfirst(str) {
}
export function debug(msg) {
if (process.env.NODE_ENV === "development") {
if (isDev) {
console.log(msg);
}
}
@@ -52,7 +55,7 @@ export function polyfill() {
* @license MIT
*/
if (!String.prototype.replaceAll) {
String.prototype.replaceAll = function(str, newStr) {
String.prototype.replaceAll = function (str, newStr) {
// If a regex pattern
if (Object.prototype.toString.call(str).toLowerCase() === "[object regexp]") {
@@ -65,3 +68,15 @@ export function polyfill() {
};
}
}
export class TimeLogger {
constructor() {
this.startTime = dayjs().valueOf();
}
print(name) {
if (isDev) {
console.log(name + ": " + (dayjs().valueOf() - this.startTime) + "ms")
}
}
}