• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hanazuki / node-jsonnet / 26328644920

23 May 2026 08:56AM UTC coverage: 72.477% (-0.6%) from 73.043%
26328644920

Pull #438

github

web-flow
Merge 8cf1ac9e1 into 0179249da
Pull Request #438: introduce Callback<T> to unify TSFN callbacks

326 of 608 branches covered (53.62%)

Branch coverage included in aggregate %.

76 of 78 new or added lines in 3 files covered. (97.44%)

1 existing line in 1 file now uncovered.

543 of 591 relevant lines covered (91.88%)

211.18 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

69.41
/src/JsonnetImportCallback.cpp
1
// SPDX-License-Identifier: MIT
2
#include "JsonnetImportCallback.hpp"
3
#include <cstring>
4

5
namespace nodejsonnet {
6

7
  namespace detail {
8

9
    ImportCallbackPayload::ImportCallbackPayload(
72✔
10
      std::shared_ptr<JsonnetVm> vm, std::string base, std::string rel)
11
      : CallbackPayload{std::move(vm)}, base{std::move(base)}, rel{std::move(rel)} {}
72!
12

13

14
    std::vector<napi_value> ImportCallbackPayload::makeArgs(Napi::Env env) const {
72✔
15
      return {
216!
16
        Napi::String::New(env, base),
72✔
17
        Napi::String::New(env, rel),
72✔
18
      };
UNCOV
19
    }
×
20

21
    void ImportCallbackPayload::resolveResult(Napi::Value val) {
64✔
22
      auto const obj = val.As<Napi::Object>();
64✔
23
      auto const vm = getVm();
64✔
24

25
      auto const foundHereStr = obj.Get("foundHere").As<Napi::String>().Utf8Value();
64!
26
      auto foundHereBuf = vm->allocBuffer(foundHereStr.size() + 1);
64!
27
      std::memcpy(foundHereBuf.get(), foundHereStr.c_str(), foundHereStr.size() + 1);
64✔
28

29
      auto const contentVal = obj.Get("content");
64!
30
      JsonnetVm::Buffer contentBuf;
64✔
31
      size_t contentLen;
64✔
32

33
      if(contentVal.IsString()) {
64!
34
        auto const str = contentVal.As<Napi::String>().Utf8Value();
48!
35
        contentBuf = vm->allocBuffer(str.size());
48!
36
        std::memcpy(contentBuf.get(), str.data(), str.size());
48✔
37
        contentLen = str.size();
48✔
38
      } else {
48✔
39
        auto const ta = contentVal.As<Napi::TypedArray>();
16!
40
        contentBuf = vm->allocBuffer(ta.ByteLength());
16!
41
        std::memcpy(contentBuf.get(), static_cast<char *>(ta.ArrayBuffer().Data()) + ta.ByteOffset(),
16!
42
          ta.ByteLength());
16!
43
        contentLen = ta.ByteLength();
16!
44
      }
16✔
45

46
      setResult(JsonnetVm::ImportResult{
256!
47
        std::move(foundHereBuf),
64✔
48
        std::move(contentBuf),
64✔
49
        contentLen,
64✔
50
      });
51
    }
64✔
52

53
  }
54

55
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc