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:
parent
c90fa55c99
commit
aeb3013d7e
1 changed files with 9 additions and 3 deletions
12
db.js
12
db.js
|
@ -699,9 +699,15 @@ module.exports.CreateDB = function (parent, func) {
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clone an object (TODO: Make this more efficient)
|
// Clone an object (TODO: Make this more efficient) >> Use StructuredClone from v17 onward
|
||||||
function Clone(v) { return JSON.parse(JSON.stringify(v)); }
|
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
|
// Read expiration time from configuration file
|
||||||
if (typeof parent.args.dbexpire == 'object') {
|
if (typeof parent.args.dbexpire == 'object') {
|
||||||
if (typeof parent.args.dbexpire.events == 'number') { expireEventsSeconds = parent.args.dbexpire.events; }
|
if (typeof parent.args.dbexpire.events == 'number') { expireEventsSeconds = parent.args.dbexpire.events; }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue