MCPcopy Create free account
hub / github.com/WiseLibs/better-sqlite3 / IsInt32

Function IsInt32

src/util/helpers.cpp:26–32  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

24// the range of a 32-bit signed integer, excluding -0), which has no direct
25// Node-API equivalent.
26inline 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
34inline 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));

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected