MCPcopy Create free account
hub / github.com/buke/quickjs-go / NewArrayBuffer

Method NewArrayBuffer

context.go:469–474  ·  view source on GitHub ↗

NewArrayBuffer returns a ArrayBuffer value with given binary data.

(binaryData []byte)

Source from the content-addressed store, hash-verified

467
468// NewArrayBuffer returns a ArrayBuffer value with given binary data.
469func (ctx *Context) NewArrayBuffer(binaryData []byte) *Value {
470 if len(binaryData) == 0 {
471 return &Value{ctx: ctx, ref: C.JS_NewArrayBufferCopy(ctx.ref, nil, 0)}
472 }
473 return &Value{ctx: ctx, ref: C.JS_NewArrayBufferCopy(ctx.ref, (*C.uchar)(&binaryData[0]), C.size_t(len(binaryData)))}
474}
475
476// ArrayBuffer returns a ArrayBuffer value with given binary data.
477// Deprecated: Use NewArrayBuffer() instead.

Callers 15

TestContextBasicsFunction · 0.95
TestContextTypedArraysFunction · 0.95
marshalSliceMethod · 0.95
marshalInt8ArrayMethod · 0.95
marshalInt16ArrayMethod · 0.95
marshalUint16ArrayMethod · 0.95
marshalInt32ArrayMethod · 0.95
marshalUint32ArrayMethod · 0.95
marshalFloat32ArrayMethod · 0.95
marshalFloat64ArrayMethod · 0.95
marshalBigInt64ArrayMethod · 0.95
marshalBigUint64ArrayMethod · 0.95

Calls

no outgoing calls

Tested by 4

TestContextBasicsFunction · 0.76
TestContextTypedArraysFunction · 0.76
TestUnmarshalInterfaceFunction · 0.76
TestValueArrayBufferFunction · 0.76