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

Function CheckBuffer

test/buffer.cc:137–157  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

135#include "buffer_new_or_copy-inl.h"
136
137void CheckBuffer(const CallbackInfo& info) {
138 if (!info[0].IsBuffer()) {
139 Error::New(info.Env(), "A buffer was expected.")
140 .ThrowAsJavaScriptException();
141 return;
142 }
143
144 Buffer<uint16_t> buffer = info[0].As<Buffer<uint16_t>>();
145
146 if (buffer.Length() != testLength) {
147 Error::New(info.Env(), "Incorrect buffer length.")
148 .ThrowAsJavaScriptException();
149 return;
150 }
151
152 if (!VerifyData(buffer.Data(), testLength)) {
153 Error::New(info.Env(), "Incorrect buffer data.")
154 .ThrowAsJavaScriptException();
155 return;
156 }
157}
158
159Value GetFinalizeCount(const CallbackInfo& info) {
160 return Number::New(info.Env(), finalizeCount);

Callers

nothing calls this directly

Calls 5

EnvMethod · 0.80
LengthMethod · 0.80
DataMethod · 0.80
VerifyDataFunction · 0.70

Tested by

no test coverage detected