1
0
Fork 0
mirror of https://github.com/Ylianst/MeshCentral.git synced 2025-03-09 15:40:18 +00:00

Use structuredClone instead of parse/stringify

This commit is contained in:
PTR-inc 2025-02-18 14:46:32 +01:00
parent c90fa55c99
commit aeb3013d7e

12
db.js
View file

@ -699,9 +699,15 @@ module.exports.CreateDB = function (parent, func) {
return r;
}
// Clone an object (TODO: Make this more efficient)
function Clone(v) { return JSON.parse(JSON.stringify(v)); }
// Clone an object (TODO: Make this more efficient) >> Use StructuredClone from v17 onward
let Clone;
if (process.versions.node.split('.')[0] >= '17'){
Clone = function (v) { return structuredClone(v); }
}
else {
Clone = function (v) { return JSON.parse(JSON.stringify(v)); }
}
// Read expiration time from configuration file
if (typeof parent.args.dbexpire == 'object') {
if (typeof parent.args.dbexpire.events == 'number') { expireEventsSeconds = parent.args.dbexpire.events; }