-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #187 from DavidVujic/node_12_support
Add Node 12 support
- Loading branch information
Showing
10 changed files
with
320 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#include <v8.h> | ||
#include "nan.h" | ||
|
||
using namespace v8; | ||
|
||
namespace nodezk { | ||
Local<Object> toLocalObj(Local<Value> val) { | ||
return Nan::To<Object>(val).ToLocalChecked(); | ||
} | ||
|
||
Local<Value> toLocalVal(Local<Object> arg, Local<String> propertyName) { | ||
Local<Value> val_local = arg->Get(Nan::GetCurrentContext(), propertyName).ToLocalChecked(); | ||
return val_local; | ||
} | ||
|
||
int32_t toInt(Local<Value> val_local) { | ||
int32_t val = val_local->Int32Value(Nan::GetCurrentContext()).FromJust(); | ||
|
||
return val; | ||
} | ||
|
||
int32_t toInt(Local<Object> arg, Local<String> propertyName) { | ||
Local<Value> val_local = toLocalVal(arg, propertyName); | ||
|
||
return toInt(val_local); | ||
} | ||
|
||
bool toBool(Local<Value> val_local) { | ||
return Nan::To<bool>(val_local).FromJust(); | ||
} | ||
|
||
bool toBool(Local<Object> arg, Local<String> propertyName) { | ||
Local<Value> val_local = toLocalVal(arg, propertyName); | ||
|
||
return toBool(val_local); | ||
} | ||
|
||
Local<Value> convertUnixTimeToDate(double time) { | ||
return Date::New(Isolate::GetCurrent()->GetCurrentContext(), time).ToLocalChecked(); | ||
} | ||
|
||
Local<String> toString(Local<Value> val) { | ||
return val->ToString(Nan::GetCurrentContext()).FromMaybe(Local<String>()); | ||
} | ||
|
||
uint32_t toUint(Local<Value> val) { | ||
return val->Uint32Value(Nan::GetCurrentContext()).FromJust(); | ||
} | ||
} |
Oops, something went wrong.