diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/node_util.cc | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/node_util.cc b/src/node_util.cc index 07a7b69dbd9..b9553eaaa67 100644 --- a/src/node_util.cc +++ b/src/node_util.cc @@ -169,6 +169,12 @@ static void SetHiddenValue(const FunctionCallbackInfo<Value>& args) { args.GetReturnValue().Set(maybe_value.FromJust()); } +static void Sleep(const FunctionCallbackInfo<Value>& args) { + CHECK(args[0]->IsUint32()); + uint32_t msec = args[0].As<Uint32>()->Value(); + uv_sleep(msec); +} + void ArrayBufferViewHasBuffer(const FunctionCallbackInfo<Value>& args) { CHECK(args[0]->IsArrayBufferView()); args.GetReturnValue().Set(args[0].As<ArrayBufferView>()->HasBuffer()); @@ -290,6 +296,7 @@ void Initialize(Local<Object> target, env->SetMethodNoSideEffect(target, "getOwnNonIndexProperties", GetOwnNonIndexProperties); env->SetMethodNoSideEffect(target, "getConstructorName", GetConstructorName); + env->SetMethod(target, "sleep", Sleep); env->SetMethod(target, "arrayBufferViewHasBuffer", ArrayBufferViewHasBuffer); Local<Object> constants = Object::New(env->isolate()); |