summaryrefslogtreecommitdiff
path: root/src/node_util.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/node_util.cc')
-rw-r--r--src/node_util.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/node_util.cc b/src/node_util.cc
index 8f261e8989..c183f314a1 100644
--- a/src/node_util.cc
+++ b/src/node_util.cc
@@ -7,8 +7,10 @@ namespace util {
using v8::ALL_PROPERTIES;
using v8::Array;
using v8::Context;
+using v8::Function;
using v8::FunctionCallbackInfo;
using v8::Integer;
+using v8::Isolate;
using v8::Local;
using v8::Object;
using v8::ONLY_CONFIGURABLE;
@@ -172,6 +174,15 @@ void SafeGetenv(const FunctionCallbackInfo<Value>& args) {
v8::NewStringType::kNormal).ToLocalChecked());
}
+void EnqueueMicrotask(const FunctionCallbackInfo<Value>& args) {
+ Environment* env = Environment::GetCurrent(args);
+ Isolate* isolate = env->isolate();
+
+ CHECK(args[0]->IsFunction());
+
+ isolate->EnqueueMicrotask(args[0].As<Function>());
+}
+
void Initialize(Local<Object> target,
Local<Value> unused,
Local<Context> context) {
@@ -219,6 +230,8 @@ void Initialize(Local<Object> target,
env->SetMethod(target, "safeGetenv", SafeGetenv);
+ env->SetMethod(target, "enqueueMicrotask", EnqueueMicrotask);
+
Local<Object> constants = Object::New(env->isolate());
NODE_DEFINE_CONSTANT(constants, ALL_PROPERTIES);
NODE_DEFINE_CONSTANT(constants, ONLY_WRITABLE);