File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -132,7 +132,15 @@ NAN_GETTER(KerberosServer::ContextCompleteGetter) {
132132NAN_METHOD (TestMethod) {
133133 std::string string (*Nan::Utf8String (info[0 ]));
134134 bool shouldError = info[1 ]->BooleanValue ();
135- Nan::Callback* callback = new Nan::Callback (Nan::To<v8::Function>(info[2 ]).ToLocalChecked ());
135+
136+ std::string optionalString;
137+ Nan::Callback* callback;
138+ if (info[2 ]->IsFunction ()) {
139+ callback = new Nan::Callback (Nan::To<v8::Function>(info[2 ]).ToLocalChecked ());
140+ } else {
141+ optionalString = *Nan::Utf8String (info[2 ]);
142+ callback = new Nan::Callback (Nan::To<v8::Function>(info[3 ]).ToLocalChecked ());
143+ }
136144
137145 KerberosWorker::Run (callback, " kerberos:TestMethod" , [=](KerberosWorker::SetOnFinishedHandler onFinished) {
138146 return onFinished ([=](KerberosWorker* worker) {
@@ -141,7 +149,7 @@ NAN_METHOD(TestMethod) {
141149 v8::Local<v8::Value> argv[] = {Nan::Error (" an error occurred" ), Nan::Null ()};
142150 worker->Call (2 , argv);
143151 } else {
144- v8::Local<v8::Value> argv[] = {Nan::Null (), Nan::Null ()};
152+ v8::Local<v8::Value> argv[] = {Nan::Null (), Nan::New (optionalString. c_str ()). ToLocalChecked ()};
145153 worker->Call (2 , argv);
146154 }
147155 });
You can’t perform that action at this time.
0 commit comments