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

hanazuki / node-jsonnet / 26328715879

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

push

github

web-flow
Merge pull request #438 from hanazuki/refactor-callback

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%)

158.39 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(
54✔
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)} {}
54!
12

13

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

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

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

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

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

46
      setResult(JsonnetVm::ImportResult{
192!
47
        std::move(foundHereBuf),
48✔
48
        std::move(contentBuf),
48✔
49
        contentLen,
48✔
50
      });
51
    }
48✔
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