| 4 | using namespace Napi; |
| 5 | |
| 6 | class FuncRefObject : public Napi::ObjectWrap<FuncRefObject> { |
| 7 | public: |
| 8 | FuncRefObject(const Napi::CallbackInfo& info) |
| 9 | : Napi::ObjectWrap<FuncRefObject>(info) { |
| 10 | Napi::Env env = info.Env(); |
| 11 | int argLen = info.Length(); |
| 12 | if (argLen <= 0 || !info[0].IsNumber()) { |
| 13 | Napi::TypeError::New(env, "First param should be a number") |
| 14 | .ThrowAsJavaScriptException(); |
| 15 | return; |
| 16 | } |
| 17 | Napi::Number value = info[0].As<Napi::Number>(); |
| 18 | this->_value = value.Int32Value(); |
| 19 | } |
| 20 | |
| 21 | Napi::Value GetValue(const Napi::CallbackInfo& info) { |
| 22 | int value = this->_value; |
| 23 | return Napi::Number::New(info.Env(), value); |
| 24 | } |
| 25 | |
| 26 | private: |
| 27 | int _value; |
| 28 | }; |
| 29 | |
| 30 | namespace { |
| 31 |
nothing calls this directly
no outgoing calls
no test coverage detected