#include "sleep.h" using v8::FunctionTemplate; using v8::String; NAN_METHOD(MUSleep) { Nan::HandleScope scope; if (info.Length() < 1 || !info[0]->IsUint32()) { Nan::ThrowError("Expected number of microseconds"); return; } node_usleep(Nan::To(info[0]).FromJust()); info.GetReturnValue().SetUndefined(); } NAN_MODULE_INIT(init) { Nan::Set(target, Nan::New("usleep").ToLocalChecked(), Nan::GetFunction(Nan::New(MUSleep)).ToLocalChecked()); } NODE_MODULE(node_sleep, init)