[node] switch to NodeRequest member fn callback

For (hopefully) better performance than creating a new v8::Context to
wrap each callback while still avoiding leaking memory with v8::FunctionTemplate.

Adds a JavaScript shim in front of module.exports.Map to wrap the
req.respond API internally and preserve the public callback-passing
API, while still exporting the correct prototype.
This commit is contained in:
Thiago Marcos P. Santos
2016-06-29 21:35:24 +03:00
committed by Mike Morris
parent d6f667a5e7
commit edec56e6c5
8 changed files with 83 additions and 16 deletions

View File

@@ -43,11 +43,11 @@ static const char* releasedMessage() {
return "Map resources have already been released";
}
NAN_MODULE_INIT(NodeMap::Init) {
void NodeMap::Init(v8::Local<v8::Object> target) {
v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
tpl->InstanceTemplate()->SetInternalFieldCount(2);
tpl->SetClassName(Nan::New("Map").ToLocalChecked());
tpl->InstanceTemplate()->SetInternalFieldCount(2);
Nan::SetPrototypeMethod(tpl, "load", Load);
Nan::SetPrototypeMethod(tpl, "loaded", Loaded);