Skip to content

Commit

Permalink
add Nan::Call overload
Browse files Browse the repository at this point in the history
Add a non-receiver overload for Nan::Call to make it more comparable
to Nan::Callback::Call.
  • Loading branch information
ofrobots authored and kkoopa committed Mar 2, 2018
1 parent 53db685 commit 4482e12
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/maybe_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ Signature:
Nan::MaybeLocal<v8::Value> Nan::Call(v8::Local<v8::Function> fun, v8::Local<v8::Object> recv, int argc, v8::Local<v8::Value> argv[]);
Nan::MaybeLocal<v8::Value> Nan::Call(const Nan::Callback& callback, v8::Local<v8::Object> recv,
int argc, v8::Local<v8::Value> argv[]);
Nan::MaybeLocal<v8::Value> Nan::Call(const Nan::Callback& callback, int argc, v8::Local<v8::Value> argv[]);
```


Expand Down
12 changes: 12 additions & 0 deletions nan.h
Original file line number Diff line number Diff line change
Expand Up @@ -1679,6 +1679,18 @@ inline MaybeLocal<v8::Value> Call(
return Call(*callback, recv, argc, argv);
}

inline MaybeLocal<v8::Value> Call(
const Nan::Callback& callback
, int argc
, v8::Local<v8::Value> argv[]) {
#if NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION
v8::Isolate* isolate = v8::Isolate::GetCurrent();
return Call(*callback, isolate->GetCurrentContext()->Global(), argc, argv);
#else
return Call(*callback, v8::Context::GetCurrent()->Global(), argc, argv);
#endif
}

/* abstract */ class AsyncWorker {
public:
explicit AsyncWorker(Callback *callback_,
Expand Down

0 comments on commit 4482e12

Please sign in to comment.