UNPKG

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.

29 lines 1.37 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ATypedTupleFactory = void 0; const is_little_endian_js_1 = require("../../web-assembly/util/is-little-endian.js"); class ATypedTupleFactory { constructor(elementCount, bytesPerElement, dataView) { this.elementCount = elementCount; this.bytesPerElement = bytesPerElement; this.dataView = dataView; } copyFromBuffer(memoryDataView, pointer, writeTo = this.createOneEmpty(), littleEndian = ATypedTupleFactory.littleEndian) { const bytesPerElement = this.bytesPerElement; for (let i = 0, iEnd = this.elementCount; i < iEnd; ++i) { writeTo[i] = this.dataView.getValue(memoryDataView, pointer, littleEndian); pointer += bytesPerElement; } return writeTo; } copyToBuffer(memoryDataView, writeFrom, pointer, littleEndian = ATypedTupleFactory.littleEndian) { const bytesPerElement = this.bytesPerElement; for (let i = 0, iEnd = this.elementCount; i < iEnd; ++i) { this.dataView.setValue(memoryDataView, pointer, writeFrom[i], littleEndian); pointer += bytesPerElement; } } } exports.ATypedTupleFactory = ATypedTupleFactory; ATypedTupleFactory.littleEndian = is_little_endian_js_1.isLittleEndian; //# sourceMappingURL=a-typed-tuple-factory.js.map