TooTallNate / ref

Turn Buffer instances into "pointers"
http://tootallnate.github.com/ref
451 stars 141 forks source link

Javascript error: deref is not a function (electron v1.6.7 / node 7.9.0) #98

Open nicolas-vergnes-fr opened 6 years ago

nicolas-vergnes-fr commented 6 years ago

Hi,

I already use ref module in a full Node.js (7.9.0) environnement. I do the following thing without any trouble: let size = Buffer.alloc(4, 0); size.type = ref.types.uint; console.log('size:', size.deref());

Now I try to execute the same code in electron runtime (with the same Node version) and I get a different behaviour. This time size.deref is undefined. Indeed there is no deref filed in size.__proto__.

The only difference I could see with console.log is that my buffer instance is a Uint8Array in the electron runtime, but when I check Buffer.isBuffer(size) I get true.

Example: let size: any = Buffer.alloc(4, 0); size.type = ref.types.uint; console.log('size:', size, JSON.stringify(size)); console.log('size.deref:', size.deref); console.log('size.type:', size.type); console.log('isBuffer:', Buffer.isBuffer(size));

screenshot_20171108_174121

Any ideas?

Thanks PS: great job! FFI and REF are really cool!

nicolas-vergnes-fr commented 6 years ago

Nobody meets the same problem? Any ideas?

xmsz-stu commented 10 months ago

any update?