| 23 | namespace NNodeCatBoost { |
| 24 | |
| 25 | TModel::TModel(const Napi::CallbackInfo& info): Napi::ObjectWrap<TModel>(info) { |
| 26 | Napi::Env env = info.Env(); |
| 27 | |
| 28 | this->Handle = ModelCalcerCreate(); |
| 29 | NHelper::CheckNotNullHandle(env, this->Handle); |
| 30 | |
| 31 | if (info.Length() == 0) { |
| 32 | return; |
| 33 | } |
| 34 | |
| 35 | NHelper::Check(env, info[0].IsString(), "File name argument should be a string"); |
| 36 | const bool status = LoadFullModelFromFile( |
| 37 | this->Handle, |
| 38 | info[0].As<Napi::String>().Utf8Value().c_str() |
| 39 | ); |
| 40 | // Even if it fails, this check schedules NodeJS exception, not C++ one. |
| 41 | // The C++ object is considered to be successfully created and will be destroyed by Node runtime |
| 42 | // later as usual. |
| 43 | NHelper::CheckStatus(env, status); |
| 44 | if (status) { |
| 45 | this->ModelLoaded = true; |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | TModel::~TModel() { |
| 50 | if (this->Handle != nullptr) { |
nothing calls this directly
no test coverage detected