Spaces:
Running
Running
File size: 529 Bytes
ecdd7f6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | function fixNodeVmObject(obj) {
// Fix for https://github.com/patriksimek/vm2/issues/198
if (!obj) return;
const objKeys = Object.keys(obj);
for (let i = 0; i < objKeys.length; i++) {
const key = objKeys[i];
const val = obj[key];
if (Array.isArray(val)) {
obj[key] = Array.from(val);
obj[key].forEach(arrObj => {
fixNodeVmObject(arrObj);
});
} else if (typeof val === 'object' && val !== null) {
fixNodeVmObject(val);
}
}
}
module.exports = {
fixNodeVmObject,
};
|