MCPcopy Index your code
hub / github.com/nodejs/node-addon-api / OnProgress

Method OnProgress

test/async_progress_worker.cc:264–285  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

262 }
263
264 void OnProgress(const ProgressData* /* data */, size_t count) override {
265 Napi::Env env = Env();
266 {
267 std::lock_guard<std::mutex> lock(_cvm);
268 _test_case_count++;
269 }
270 bool error = false;
271 Napi::String reason = Napi::String::New(env, "No error");
272 if (_test_case_count <= 2 && count != 0) {
273 error = true;
274 reason =
275 Napi::String::New(env, "expect 0 count of data on 1st and 2nd call");
276 }
277 if (_test_case_count > 2 && count != 1) {
278 error = true;
279 reason = Napi::String::New(
280 env, "expect 1 count of data on non-1st and non-2nd call");
281 }
282 _progress.MakeCallback(Receiver().Value(),
283 {Napi::Boolean::New(env, error), reason});
284 _cv.notify_one();
285 }
286
287 private:
288 MalignWorker(Function cb,

Callers

nothing calls this directly

Calls 3

EnvClass · 0.85
MakeCallbackMethod · 0.80
ValueMethod · 0.80

Tested by

no test coverage detected