service refactor to namespaces

This commit is contained in:
Michael Dausmann
2024-02-17 10:49:23 +11:00
parent d8f20d9896
commit 23c248a08b
10 changed files with 80 additions and 90 deletions

View File

@@ -1,5 +1,5 @@
export class UtilService {
public static addMonths(date: Date, months: number): Date {
export namespace UtilService {
export function addMonths(date: Date, months: number): Date {
const d = date.getDate();
date.setMonth(date.getMonth() + +months);
if (date.getDate() != d) {
@@ -8,12 +8,12 @@ export class UtilService {
return date;
}
public static getErrorMessage(error: unknown) {
export function getErrorMessage(error: unknown) {
if (error instanceof Error) return error.message;
return String(error);
}
public static stringifySafely(obj: any) {
export function stringifySafely(obj: any) {
let cache: any[] = [];
let str = JSON.stringify(obj, function (key, value) {
if (typeof value === 'object' && value !== null) {