rc-js-util
Version:
A collection of TS and C++ utilities to help writing performant and correct applications, achieved through strict typing and (removable) invariant checking.
28 lines • 1.12 kB
JavaScript
import { SharedMemoryBlock } from "../../web-assembly/shared-memory/shared-memory-block.js";
import { isLittleEndian } from "../../web-assembly/util/is-little-endian.js";
/**
@public
{@inheritDoc ISharedTypedArrayTuple}
*/
export class SharedTypedArrayTuple {
static createOne(typedArrayCtor, bindToReference, wrapper) {
const byteSize = typedArrayCtor.BYTES_PER_ELEMENT * typedArrayCtor.factory.elementCount;
const block = SharedMemoryBlock.createOne(wrapper, bindToReference, byteSize);
return new SharedTypedArrayTuple(block);
}
getWrapper() {
return this.memory.getWrapper();
}
copyToBuffer(readFrom) {
readFrom.copyToBuffer(this.memory.getDataView(), 0, SharedTypedArrayTuple.littleEndian);
}
copyFromBuffer(writeTo) {
writeTo.copyFromBuffer(this.memory.getDataView(), 0, SharedTypedArrayTuple.littleEndian);
}
constructor(memory) {
this.memory = memory;
this.resourceHandle = memory.resourceHandle;
}
}
SharedTypedArrayTuple.littleEndian = isLittleEndian;
//# sourceMappingURL=shared-typed-array-tuple.js.map