@simplysm/sd-core-common
Advanced tools
Comparing version 12.5.21 to 12.5.22
export declare class FunctionQueue { | ||
private readonly _gap?; | ||
private readonly _delay?; | ||
private readonly _queue; | ||
private _isQueueRunning; | ||
constructor(_gap?: number | undefined); | ||
constructor(_delay?: number | undefined); | ||
run(fn: () => void | Promise<void>): void; | ||
runLast(fn: () => void | Promise<void>): void; | ||
} |
import { Wait } from "./Wait"; | ||
export class FunctionQueue { | ||
constructor(_gap) { | ||
this._gap = _gap; | ||
constructor(_delay) { | ||
this._delay = _delay; | ||
this._queue = []; | ||
@@ -19,4 +19,4 @@ this._isQueueRunning = false; | ||
await runningFn(); | ||
if (this._gap !== undefined && this._gap > 0) { | ||
await Wait.time(this._gap); | ||
if (this._delay !== undefined && this._delay > 0) { | ||
await Wait.time(this._delay); | ||
} | ||
@@ -39,4 +39,4 @@ } | ||
await runningFn(); | ||
if (this._gap !== undefined && this._gap > 0) { | ||
await Wait.time(this._gap); | ||
if (this._delay !== undefined && this._delay > 0) { | ||
await Wait.time(this._delay); | ||
} | ||
@@ -43,0 +43,0 @@ } |
@@ -26,2 +26,8 @@ import { DateTime } from "../types/DateTime"; | ||
} | ||
else if (currValue instanceof Set) { | ||
return { __type__: "Set", data: Array.from(currValue) }; | ||
} | ||
else if (currValue instanceof Map) { | ||
return { __type__: "Map", data: Array.from(currValue.entries()) }; | ||
} | ||
else if (currValue instanceof Error) { | ||
@@ -34,4 +40,4 @@ return { | ||
name: currValue.name, | ||
stack: currValue.stack | ||
} | ||
stack: currValue.stack, | ||
}, | ||
}; | ||
@@ -69,2 +75,8 @@ } | ||
} | ||
else if (typeof value === "object" && value.__type__ === "Set") { | ||
return new Set(value.data); | ||
} | ||
else if (typeof value === "object" && value.__type__ === "Map") { | ||
return new Map(value.data); | ||
} | ||
else if (typeof value === "object" && value.__type__ === "Error") { | ||
@@ -71,0 +83,0 @@ const error = new Error(value.data.message); |
{ | ||
"name": "@simplysm/sd-core-common", | ||
"version": "12.5.21", | ||
"version": "12.5.22", | ||
"description": "심플리즘 패키지 - 코어 모듈 (common)", | ||
@@ -5,0 +5,0 @@ "author": "김석래", |
@@ -7,3 +7,3 @@ import {Wait} from "./Wait"; | ||
public constructor(private readonly _gap?: number) { | ||
public constructor(private readonly _delay?: number) { | ||
} | ||
@@ -21,4 +21,4 @@ | ||
await runningFn(); | ||
if (this._gap !== undefined && this._gap > 0) { | ||
await Wait.time(this._gap); | ||
if (this._delay !== undefined && this._delay > 0) { | ||
await Wait.time(this._delay); | ||
} | ||
@@ -42,4 +42,4 @@ } | ||
await runningFn(); | ||
if (this._gap !== undefined && this._gap > 0) { | ||
await Wait.time(this._gap); | ||
if (this._delay !== undefined && this._delay > 0) { | ||
await Wait.time(this._delay); | ||
} | ||
@@ -46,0 +46,0 @@ } |
@@ -1,33 +0,35 @@ | ||
import {DateTime} from "../types/DateTime"; | ||
import {DateOnly} from "../types/DateOnly"; | ||
import {Time} from "../types/Time"; | ||
import {Uuid} from "../types/Uuid"; | ||
import {ObjectUtil} from "./ObjectUtil"; | ||
import {SdError} from "../errors/SdError"; | ||
import { DateTime } from "../types/DateTime"; | ||
import { DateOnly } from "../types/DateOnly"; | ||
import { Time } from "../types/Time"; | ||
import { Uuid } from "../types/Uuid"; | ||
import { ObjectUtil } from "./ObjectUtil"; | ||
import { SdError } from "../errors/SdError"; | ||
export class JsonConvert { | ||
public static stringify(obj: any, | ||
options?: { | ||
space?: string | number; | ||
replacer?: (key: string | undefined, value: any) => any; | ||
hideBuffer?: boolean; | ||
}): string { | ||
public static stringify( | ||
obj: any, | ||
options?: { | ||
space?: string | number; | ||
replacer?: (key: string | undefined, value: any) => any; | ||
hideBuffer?: boolean; | ||
}, | ||
): string { | ||
const replacer = (key: string | undefined, value: any): any => { | ||
const currValue = options?.replacer !== undefined ? options.replacer(key, value) : value; | ||
if (currValue instanceof Date) { | ||
return {__type__: "Date", data: currValue.toISOString()}; | ||
return { __type__: "Date", data: currValue.toISOString() }; | ||
} | ||
if (currValue instanceof DateTime) { | ||
return {__type__: "DateTime", data: currValue.toString()}; | ||
} | ||
else if (currValue instanceof DateOnly) { | ||
return {__type__: "DateOnly", data: currValue.toString()}; | ||
} | ||
else if (currValue instanceof Time) { | ||
return {__type__: "Time", data: currValue.toString()}; | ||
} | ||
else if (currValue instanceof Uuid) { | ||
return {__type__: "Uuid", data: currValue.toString()}; | ||
} | ||
else if (currValue instanceof Error) { | ||
return { __type__: "DateTime", data: currValue.toString() }; | ||
} else if (currValue instanceof DateOnly) { | ||
return { __type__: "DateOnly", data: currValue.toString() }; | ||
} else if (currValue instanceof Time) { | ||
return { __type__: "Time", data: currValue.toString() }; | ||
} else if (currValue instanceof Uuid) { | ||
return { __type__: "Uuid", data: currValue.toString() }; | ||
} else if (currValue instanceof Set) { | ||
return { __type__: "Set", data: Array.from(currValue) }; | ||
} else if (currValue instanceof Map) { | ||
return { __type__: "Map", data: Array.from(currValue.entries()) }; | ||
} else if (currValue instanceof Error) { | ||
return { | ||
@@ -39,9 +41,8 @@ __type__: "Error", | ||
name: currValue.name, | ||
stack: currValue.stack | ||
} | ||
stack: currValue.stack, | ||
}, | ||
}; | ||
} else if (currValue?.type === "Buffer" && options?.hideBuffer === true) { | ||
return { type: "Buffer", data: "__hidden__" }; | ||
} | ||
else if (currValue?.type === "Buffer" && options?.hideBuffer === true) { | ||
return {type: "Buffer", data: "__hidden__"}; | ||
} | ||
return currValue; | ||
@@ -66,21 +67,19 @@ }; | ||
return new Date(Date.parse(value.data)); | ||
} | ||
else if (typeof value === "object" && value.__type__ === "DateTime") { | ||
} else if (typeof value === "object" && value.__type__ === "DateTime") { | ||
return DateTime.parse(value.data); | ||
} | ||
else if (typeof value === "object" && value.__type__ === "DateOnly") { | ||
} else if (typeof value === "object" && value.__type__ === "DateOnly") { | ||
return DateOnly.parse(value.data); | ||
} | ||
else if (typeof value === "object" && value.__type__ === "Time") { | ||
} else if (typeof value === "object" && value.__type__ === "Time") { | ||
return Time.parse(value.data); | ||
} | ||
else if (typeof value === "object" && value.__type__ === "Uuid") { | ||
} else if (typeof value === "object" && value.__type__ === "Uuid") { | ||
return new Uuid(value.data); | ||
} | ||
else if (typeof value === "object" && value.__type__ === "Error") { | ||
} else if (typeof value === "object" && value.__type__ === "Set") { | ||
return new Set(value.data); | ||
} else if (typeof value === "object" && value.__type__ === "Map") { | ||
return new Map(value.data); | ||
} else if (typeof value === "object" && value.__type__ === "Error") { | ||
const error = new Error(value.data.message); | ||
Object.assign(error, value.data); | ||
return error; | ||
} | ||
else if (typeof value === "object" && value.type === "Buffer") { | ||
} else if (typeof value === "object" && value.type === "Buffer") { | ||
return Buffer.from(value.data); | ||
@@ -91,6 +90,5 @@ } | ||
return value; | ||
}) | ||
}), | ||
); | ||
} | ||
catch (err) { | ||
} catch (err) { | ||
throw new SdError(err, "JSON 파싱 에러: \n" + json); | ||
@@ -97,0 +95,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
298287
5685