Replicates the semantics of v8::Value::IsInt32() (an integral number within the range of a 32-bit signed integer, excluding -0), which has no direct Node-API equivalent.
| 24 | // the range of a 32-bit signed integer, excluding -0), which has no direct |
| 25 | // Node-API equivalent. |
| 26 | inline bool IsInt32(Napi::Value value) { |
| 27 | if (!value.IsNumber()) return false; |
| 28 | double num = value.As<Napi::Number>().DoubleValue(); |
| 29 | if (!(num >= INT_MIN && num <= INT_MAX)) return false; |
| 30 | if (num == 0) return !std::signbit(num); |
| 31 | return static_cast<double>(static_cast<int32_t>(num)) == num; |
| 32 | } |
| 33 | |
| 34 | inline void SetFrozen(Napi::Env env, Napi::Object obj, const Napi::Reference<Napi::String>& key, Napi::Value value) { |
| 35 | obj.DefineProperty(Napi::PropertyDescriptor::Value(key.Value(), value, napi_enumerable)); |
nothing calls this directly
no outgoing calls
no test coverage detected