vm2 icon indicating copy to clipboard operation
vm2 copied to clipboard

inconsistent inspect behaviors between host objects and decontextified objects

Open shigma opened this issue 5 years ago • 6 comments

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 {}

shigma avatar Aug 07 '20 15:08 shigma

This is a problem with node's inspect method. There is noting I can really do.

XmiliaH avatar Aug 07 '20 15:08 XmiliaH

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).

shigma avatar Aug 07 '20 17:08 shigma

That is certainly possible. However, custom inspect needs to be enabled and I am not sure if it is by default.

XmiliaH avatar Aug 07 '20 17:08 XmiliaH

Can I have a try on this issue?

shigma avatar Aug 07 '20 18:08 shigma

If you want you can try it.

XmiliaH avatar Aug 07 '20 19:08 XmiliaH

I just came up with another idea which may solve this issue: #315

shigma avatar Aug 10 '20 19:08 shigma