Is it possible to read function closure via V8 addon?

16 views
Skip to first unread message

Moshe Simantov

unread,
Sep 9, 2016, 6:42:03 PM9/9/16
to nodejs
Please see the original question here: http://stackoverflow.com/questions/39399717/is-it-possible-to-read-function-closure-via-v8-addo

I want to write a Node.js V8 addon in C++ that will give me access to functions closures.


Something like this:


const myAddon = require('./build/Release/addon');

const counter = (() => {
  let i
= 0;
 
return () => ++i;
})();

counter
(); // 1
counter
(); // 2

const closure = myAddon(counter);
console
.log(closure.i); // prints "3"

Is it possible? Where this information stored on the V8 engine?


Reply all
Reply to author
Forward
0 new messages