Created
September 10, 2018 08:37
-
-
Save NickNaso/7bcf6a19d71adffa26d93866795c7adc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| Napi::Value value; | |
| Napi::Function dateFunc = value.Env().Global().Get("Date").As<Napi::Function>(); | |
| if (value.As<Napi::Object>().InstanceOf(dateFunc)) { | |
| // it is a date | |
| } | |
| Napi::Function isIntegerFunction = value.Env().Global().Get("Number").As<Napi::Object>().Get("IsInteger").As<Napi::Function>(); | |
| bool isInt = isIntegerFunction.Call({value}).ToBoolean().Value(); | |
| double orig_val = source.As<Napi::Number>().DoubleValue(); | |
| int32_t int_val = source.As<Napi::Number>().Int32Value(); | |
| if ((int32_t)orig_val != orig_val) // or std::trunc(orig_val) == orig_val; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment