| 8 | : Napi::ObjectWrap<FunctionTest>(info) {} |
| 9 | |
| 10 | static Napi::Value OnCalledAsFunction(const Napi::CallbackInfo& info) { |
| 11 | // If called with a "true" argument, throw an exeption to test the handling. |
| 12 | if (!info[0].IsUndefined() && MaybeUnwrap(info[0].ToBoolean())) { |
| 13 | NAPI_THROW(Napi::Error::New(info.Env(), "an exception"), Napi::Value()); |
| 14 | } |
| 15 | // Otherwise, act as a factory. |
| 16 | std::vector<napi_value> args; |
| 17 | for (size_t i = 0; i < info.Length(); i++) args.push_back(info[i]); |
| 18 | return MaybeUnwrap(GetConstructor(info.Env()).New(args)); |
| 19 | } |
| 20 | |
| 21 | static void Initialize(Napi::Env env, Napi::Object exports) { |
| 22 | const char* name = "FunctionTest"; |
nothing calls this directly
no test coverage detected