X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Futils%2FUtils.ts;h=5b66368fa87f264dc8a2d93c72c2a6c55ad809cc;hb=d3140adc8c6ad502eb9566aabfc1af8f66d0ef24;hp=1ad1a7924bb0b5e4eb5e8fc7778a9d89f953eda6;hpb=8114d10e3893e96bb725ce2fca9744429ee4b75b;p=e-mobility-charging-stations-simulator.git diff --git a/src/utils/Utils.ts b/src/utils/Utils.ts index 1ad1a792..5b66368f 100644 --- a/src/utils/Utils.ts +++ b/src/utils/Utils.ts @@ -238,4 +238,23 @@ export default class Utils { public static secureRandom(): number { return crypto.randomBytes(4).readUInt32LE() / 0x100000000; } + + public static JSONStringifyWithMapSupport( + obj: Record | Record[], + space?: number + ): string { + return JSON.stringify( + obj, + (key, value: Record) => { + if (value instanceof Map) { + return { + dataType: 'Map', + value: [...value], + }; + } + return value; + }, + space + ); + } }