From d98516e1c4050975e25f591d0d15dd7d95590bd3 Mon Sep 17 00:00:00 2001 From: Alex Hultman Date: Sat, 21 Dec 2019 19:37:12 +0100 Subject: [PATCH] Wrap setYield --- src/HttpRequestWrapper.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/HttpRequestWrapper.h b/src/HttpRequestWrapper.h index 438e566..2f60d91 100644 --- a/src/HttpRequestWrapper.h +++ b/src/HttpRequestWrapper.h @@ -72,6 +72,18 @@ struct HttpRequestWrapper { } } + /* Takes boolean, returns this */ + static void req_setYield(const FunctionCallbackInfo &args) { + Isolate *isolate = args.GetIsolate(); + auto *req = getHttpRequest(args); + if (req) { + bool yield = BooleanValue(args.GetIsolate(), args[0]); + req->setYield(yield); + + args.GetReturnValue().Set(args.Holder()); + } + } + /* Takes nothing, returns string */ static void req_getMethod(const FunctionCallbackInfo &args) { Isolate *isolate = args.GetIsolate(); @@ -107,6 +119,7 @@ struct HttpRequestWrapper { reqTemplateLocal->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "getMethod", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, req_getMethod)); reqTemplateLocal->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "getQuery", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, req_getQuery)); reqTemplateLocal->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "forEach", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, req_forEach)); + reqTemplateLocal->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "setYield", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, req_setYield)); /* Create the template */ Local reqObjectLocal = reqTemplateLocal->GetFunction(isolate->GetCurrentContext()).ToLocalChecked()->NewInstance(isolate->GetCurrentContext()).ToLocalChecked();