vm2
vm2 copied to clipboard
inconsistent inspect behaviors between host objects and decontextified objects
const { VM } = require('vm2')
const vm = new VM()
console.log(new Date())) // Fri Aug 07 2020 23:39:04 GMT+0800 (中国标准时间)
console.log(vm.run('new Date()')) // Date {}
This is a problem with node's inspect method. There is noting I can really do.
I think since we can attach toStringTag parameter to instance method, there is chance that we can attach a inspectCustom parameter to it as well (maybe through tough work though).
That is certainly possible. However, custom inspect needs to be enabled and I am not sure if it is by default.
Can I have a try on this issue?
If you want you can try it.
I just came up with another idea which may solve this issue: #315