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

Function TestCreateSharedArrayBuffer

test/shared_array_buffer.cc:18–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16}
17
18Value TestCreateSharedArrayBuffer(const CallbackInfo& info) {
19 if (info.Length() < 1) {
20 Error::New(info.Env(), "Wrong number of arguments")
21 .ThrowAsJavaScriptException();
22 return Value();
23 } else if (!info[0].IsNumber()) {
24 Error::New(info.Env(),
25 "Wrong type of arguments. Expects a number as first argument.")
26 .ThrowAsJavaScriptException();
27 return Value();
28 }
29
30 auto byte_length = info[0].As<Number>().Uint32Value();
31 if (byte_length == 0) {
32 Error::New(info.Env(),
33 "Invalid byte length. Expects a non-negative integer.")
34 .ThrowAsJavaScriptException();
35 return Value();
36 }
37
38 return SharedArrayBuffer::New(info.Env(), byte_length);
39}
40
41Value TestGetSharedArrayBufferInfo(const CallbackInfo& info) {
42 if (info.Length() < 1) {

Callers

nothing calls this directly

Calls 4

LengthMethod · 0.80
EnvMethod · 0.80
ValueClass · 0.50

Tested by

no test coverage detected