Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

multi-buffer-data-view

Package Overview
Dependencies
Maintainers
1
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

multi-buffer-data-view - npm Package Compare versions

Comparing version 1.1.2 to 1.1.3

build/es2018/classes/multi-buffer-data-view.d.ts

29

build/es2018/module.d.ts

@@ -1,29 +0,2 @@

export declare class MultiBufferDataView implements Omit<DataView, 'buffer'> {
private _buffers;
private _byteLength;
private _byteOffset;
private _dataViews;
private _internalBuffer;
constructor(buffers: ArrayBuffer[], byteOffset?: number, byteLength?: number);
get buffers(): ArrayBuffer[];
get byteLength(): number;
get byteOffset(): number;
getFloat32(byteOffset: number, littleEndian?: boolean): number;
getFloat64(byteOffset: number, littleEndian?: boolean): number;
getInt16(byteOffset: number, littleEndian?: boolean): number;
getInt32(byteOffset: number, littleEndian?: boolean): number;
getInt8(byteOffset: number): number;
getUint16(byteOffset: number, littleEndian?: boolean): number;
getUint32(byteOffset: number, littleEndian?: boolean): number;
getUint8(byteOffset: number): number;
setFloat32(byteOffset: number, value: number, littleEndian?: boolean): void;
setFloat64(byteOffset: number, value: number, littleEndian?: boolean): void;
setInt16(byteOffset: number, value: number, littleEndian?: boolean): void;
setInt32(byteOffset: number, value: number, littleEndian?: boolean): void;
setInt8(byteOffset: number, value: number): void;
setUint16(byteOffset: number, value: number, littleEndian?: boolean): void;
setUint32(byteOffset: number, value: number, littleEndian?: boolean): void;
setUint8(byteOffset: number, value: number): void;
private _findDataViewWithOffset;
}
export { MultiBufferDataView } from './classes/multi-buffer-data-view';
//# sourceMappingURL=/build/es2018/module.d.ts.map

@@ -1,163 +0,2 @@

export class MultiBufferDataView {
constructor(buffers, byteOffset = 0, byteLength) {
if (byteOffset < 0 || (byteLength !== undefined && byteLength < 0)) {
throw new RangeError();
}
const availableBytes = buffers.reduce((length, buffer) => length + buffer.byteLength, 0);
if (byteOffset > availableBytes || (byteLength !== undefined && (byteOffset + byteLength) > availableBytes)) {
throw new RangeError();
}
const dataViews = [];
const effectiveByteLength = (byteLength === undefined) ? availableBytes - byteOffset : byteLength;
const truncatedBuffers = [];
let consumedByteLength = 0;
let truncatedByteOffset = byteOffset;
for (const buffer of buffers) {
if (truncatedBuffers.length === 0) {
if (buffer.byteLength > truncatedByteOffset) {
consumedByteLength = buffer.byteLength - truncatedByteOffset;
const byteLengthOfDataView = (consumedByteLength > effectiveByteLength) ? effectiveByteLength : consumedByteLength;
dataViews.push(new DataView(buffer, truncatedByteOffset, byteLengthOfDataView));
truncatedBuffers.push(buffer);
}
else {
truncatedByteOffset -= buffer.byteLength;
}
}
else if (truncatedBuffers.length > 0 && consumedByteLength < effectiveByteLength) {
consumedByteLength += buffer.byteLength;
const byteLengthOfDataView = (consumedByteLength > effectiveByteLength)
? buffer.byteLength - consumedByteLength + effectiveByteLength
: buffer.byteLength;
dataViews.push(new DataView(buffer, 0, byteLengthOfDataView));
truncatedBuffers.push(buffer);
}
}
this._buffers = truncatedBuffers;
this._byteLength = effectiveByteLength;
this._byteOffset = truncatedByteOffset;
this._dataViews = dataViews;
this._internalBuffer = new DataView(new ArrayBuffer(8));
}
get buffers() {
return this._buffers;
}
get byteLength() {
return this._byteLength;
}
get byteOffset() {
return this._byteOffset;
}
getFloat32(byteOffset, littleEndian) {
this._internalBuffer.setUint8(0, this.getUint8(byteOffset + 0));
this._internalBuffer.setUint8(1, this.getUint8(byteOffset + 1));
this._internalBuffer.setUint8(2, this.getUint8(byteOffset + 2));
this._internalBuffer.setUint8(3, this.getUint8(byteOffset + 3));
return this._internalBuffer.getFloat32(0, littleEndian);
}
getFloat64(byteOffset, littleEndian) {
this._internalBuffer.setUint8(0, this.getUint8(byteOffset + 0));
this._internalBuffer.setUint8(1, this.getUint8(byteOffset + 1));
this._internalBuffer.setUint8(2, this.getUint8(byteOffset + 2));
this._internalBuffer.setUint8(3, this.getUint8(byteOffset + 3));
this._internalBuffer.setUint8(4, this.getUint8(byteOffset + 4));
this._internalBuffer.setUint8(5, this.getUint8(byteOffset + 5));
this._internalBuffer.setUint8(6, this.getUint8(byteOffset + 6));
this._internalBuffer.setUint8(7, this.getUint8(byteOffset + 7));
return this._internalBuffer.getFloat64(0, littleEndian);
}
getInt16(byteOffset, littleEndian) {
this._internalBuffer.setUint8(0, this.getUint8(byteOffset + 0));
this._internalBuffer.setUint8(1, this.getUint8(byteOffset + 1));
return this._internalBuffer.getInt16(0, littleEndian);
}
getInt32(byteOffset, littleEndian) {
this._internalBuffer.setUint8(0, this.getUint8(byteOffset + 0));
this._internalBuffer.setUint8(1, this.getUint8(byteOffset + 1));
this._internalBuffer.setUint8(2, this.getUint8(byteOffset + 2));
this._internalBuffer.setUint8(3, this.getUint8(byteOffset + 3));
return this._internalBuffer.getInt32(0, littleEndian);
}
getInt8(byteOffset) {
const [dataView, byteOffsetOfDataView] = this._findDataViewWithOffset(byteOffset);
return dataView.getInt8(byteOffset - byteOffsetOfDataView);
}
getUint16(byteOffset, littleEndian) {
this._internalBuffer.setUint8(0, this.getUint8(byteOffset + 0));
this._internalBuffer.setUint8(1, this.getUint8(byteOffset + 1));
return this._internalBuffer.getUint16(0, littleEndian);
}
getUint32(byteOffset, littleEndian) {
this._internalBuffer.setUint8(0, this.getUint8(byteOffset + 0));
this._internalBuffer.setUint8(1, this.getUint8(byteOffset + 1));
this._internalBuffer.setUint8(2, this.getUint8(byteOffset + 2));
this._internalBuffer.setUint8(3, this.getUint8(byteOffset + 3));
return this._internalBuffer.getUint32(0, littleEndian);
}
getUint8(byteOffset) {
const [dataView, byteOffsetOfDataView] = this._findDataViewWithOffset(byteOffset);
return dataView.getUint8(byteOffset - byteOffsetOfDataView);
}
setFloat32(byteOffset, value, littleEndian) {
this._internalBuffer.setFloat32(0, value, littleEndian);
this.setUint8(byteOffset, this._internalBuffer.getUint8(0));
this.setUint8(byteOffset + 1, this._internalBuffer.getUint8(1));
this.setUint8(byteOffset + 2, this._internalBuffer.getUint8(2));
this.setUint8(byteOffset + 3, this._internalBuffer.getUint8(3));
}
setFloat64(byteOffset, value, littleEndian) {
this._internalBuffer.setFloat64(0, value, littleEndian);
this.setUint8(byteOffset, this._internalBuffer.getUint8(0));
this.setUint8(byteOffset + 1, this._internalBuffer.getUint8(1));
this.setUint8(byteOffset + 2, this._internalBuffer.getUint8(2));
this.setUint8(byteOffset + 3, this._internalBuffer.getUint8(3));
this.setUint8(byteOffset + 4, this._internalBuffer.getUint8(4));
this.setUint8(byteOffset + 5, this._internalBuffer.getUint8(5));
this.setUint8(byteOffset + 6, this._internalBuffer.getUint8(6));
this.setUint8(byteOffset + 7, this._internalBuffer.getUint8(7));
}
setInt16(byteOffset, value, littleEndian) {
this._internalBuffer.setInt16(0, value, littleEndian);
this.setUint8(byteOffset, this._internalBuffer.getUint8(0));
this.setUint8(byteOffset + 1, this._internalBuffer.getUint8(1));
}
setInt32(byteOffset, value, littleEndian) {
this._internalBuffer.setInt32(0, value, littleEndian);
this.setUint8(byteOffset, this._internalBuffer.getUint8(0));
this.setUint8(byteOffset + 1, this._internalBuffer.getUint8(1));
this.setUint8(byteOffset + 2, this._internalBuffer.getUint8(2));
this.setUint8(byteOffset + 3, this._internalBuffer.getUint8(3));
}
setInt8(byteOffset, value) {
const [dataView, byteOffsetOfDataView] = this._findDataViewWithOffset(byteOffset);
dataView.setInt8(byteOffset - byteOffsetOfDataView, value);
}
setUint16(byteOffset, value, littleEndian) {
this._internalBuffer.setUint16(0, value, littleEndian);
this.setUint8(byteOffset, this._internalBuffer.getUint8(0));
this.setUint8(byteOffset + 1, this._internalBuffer.getUint8(1));
}
setUint32(byteOffset, value, littleEndian) {
this._internalBuffer.setUint32(0, value, littleEndian);
this.setUint8(byteOffset, this._internalBuffer.getUint8(0));
this.setUint8(byteOffset + 1, this._internalBuffer.getUint8(1));
this.setUint8(byteOffset + 2, this._internalBuffer.getUint8(2));
this.setUint8(byteOffset + 3, this._internalBuffer.getUint8(3));
}
setUint8(byteOffset, value) {
const [dataView, byteOffsetOfDataView] = this._findDataViewWithOffset(byteOffset);
dataView.setUint8(byteOffset - byteOffsetOfDataView, value);
}
_findDataViewWithOffset(byteOffset) {
let byteOffsetOfDataView = 0;
for (const dataView of this._dataViews) {
const byteOffsetOfNextDataView = byteOffsetOfDataView + dataView.byteLength;
if (byteOffset >= byteOffsetOfDataView && byteOffset < byteOffsetOfNextDataView) {
return [dataView, byteOffsetOfDataView];
}
byteOffsetOfDataView = byteOffsetOfNextDataView;
}
throw new RangeError();
}
}
export { MultiBufferDataView } from './classes/multi-buffer-data-view';
//# sourceMappingURL=/build/es2018/module.js.map

@@ -6,227 +6,9 @@ "use strict";

});
exports.MultiBufferDataView = void 0;
class MultiBufferDataView {
constructor(buffers, byteOffset = 0, byteLength) {
if (byteOffset < 0 || byteLength !== undefined && byteLength < 0) {
throw new RangeError();
}
const availableBytes = buffers.reduce((length, buffer) => length + buffer.byteLength, 0);
if (byteOffset > availableBytes || byteLength !== undefined && byteOffset + byteLength > availableBytes) {
throw new RangeError();
}
const dataViews = [];
const effectiveByteLength = byteLength === undefined ? availableBytes - byteOffset : byteLength;
const truncatedBuffers = [];
let consumedByteLength = 0;
let truncatedByteOffset = byteOffset;
for (const buffer of buffers) {
if (truncatedBuffers.length === 0) {
if (buffer.byteLength > truncatedByteOffset) {
consumedByteLength = buffer.byteLength - truncatedByteOffset;
const byteLengthOfDataView = consumedByteLength > effectiveByteLength ? effectiveByteLength : consumedByteLength;
dataViews.push(new DataView(buffer, truncatedByteOffset, byteLengthOfDataView));
truncatedBuffers.push(buffer);
} else {
truncatedByteOffset -= buffer.byteLength;
}
} else if (truncatedBuffers.length > 0 && consumedByteLength < effectiveByteLength) {
consumedByteLength += buffer.byteLength;
const byteLengthOfDataView = consumedByteLength > effectiveByteLength ? buffer.byteLength - consumedByteLength + effectiveByteLength : buffer.byteLength;
dataViews.push(new DataView(buffer, 0, byteLengthOfDataView));
truncatedBuffers.push(buffer);
}
}
this._buffers = truncatedBuffers;
this._byteLength = effectiveByteLength;
this._byteOffset = truncatedByteOffset;
this._dataViews = dataViews;
this._internalBuffer = new DataView(new ArrayBuffer(8));
Object.defineProperty(exports, "MultiBufferDataView", {
enumerable: true,
get: function () {
return _multiBufferDataView.MultiBufferDataView;
}
});
get buffers() {
return this._buffers;
}
get byteLength() {
return this._byteLength;
}
get byteOffset() {
return this._byteOffset;
}
getFloat32(byteOffset, littleEndian) {
this._internalBuffer.setUint8(0, this.getUint8(byteOffset + 0));
this._internalBuffer.setUint8(1, this.getUint8(byteOffset + 1));
this._internalBuffer.setUint8(2, this.getUint8(byteOffset + 2));
this._internalBuffer.setUint8(3, this.getUint8(byteOffset + 3));
return this._internalBuffer.getFloat32(0, littleEndian);
}
getFloat64(byteOffset, littleEndian) {
this._internalBuffer.setUint8(0, this.getUint8(byteOffset + 0));
this._internalBuffer.setUint8(1, this.getUint8(byteOffset + 1));
this._internalBuffer.setUint8(2, this.getUint8(byteOffset + 2));
this._internalBuffer.setUint8(3, this.getUint8(byteOffset + 3));
this._internalBuffer.setUint8(4, this.getUint8(byteOffset + 4));
this._internalBuffer.setUint8(5, this.getUint8(byteOffset + 5));
this._internalBuffer.setUint8(6, this.getUint8(byteOffset + 6));
this._internalBuffer.setUint8(7, this.getUint8(byteOffset + 7));
return this._internalBuffer.getFloat64(0, littleEndian);
}
getInt16(byteOffset, littleEndian) {
this._internalBuffer.setUint8(0, this.getUint8(byteOffset + 0));
this._internalBuffer.setUint8(1, this.getUint8(byteOffset + 1));
return this._internalBuffer.getInt16(0, littleEndian);
}
getInt32(byteOffset, littleEndian) {
this._internalBuffer.setUint8(0, this.getUint8(byteOffset + 0));
this._internalBuffer.setUint8(1, this.getUint8(byteOffset + 1));
this._internalBuffer.setUint8(2, this.getUint8(byteOffset + 2));
this._internalBuffer.setUint8(3, this.getUint8(byteOffset + 3));
return this._internalBuffer.getInt32(0, littleEndian);
}
getInt8(byteOffset) {
const [dataView, byteOffsetOfDataView] = this._findDataViewWithOffset(byteOffset);
return dataView.getInt8(byteOffset - byteOffsetOfDataView);
}
getUint16(byteOffset, littleEndian) {
this._internalBuffer.setUint8(0, this.getUint8(byteOffset + 0));
this._internalBuffer.setUint8(1, this.getUint8(byteOffset + 1));
return this._internalBuffer.getUint16(0, littleEndian);
}
getUint32(byteOffset, littleEndian) {
this._internalBuffer.setUint8(0, this.getUint8(byteOffset + 0));
this._internalBuffer.setUint8(1, this.getUint8(byteOffset + 1));
this._internalBuffer.setUint8(2, this.getUint8(byteOffset + 2));
this._internalBuffer.setUint8(3, this.getUint8(byteOffset + 3));
return this._internalBuffer.getUint32(0, littleEndian);
}
getUint8(byteOffset) {
const [dataView, byteOffsetOfDataView] = this._findDataViewWithOffset(byteOffset);
return dataView.getUint8(byteOffset - byteOffsetOfDataView);
}
setFloat32(byteOffset, value, littleEndian) {
this._internalBuffer.setFloat32(0, value, littleEndian);
this.setUint8(byteOffset, this._internalBuffer.getUint8(0));
this.setUint8(byteOffset + 1, this._internalBuffer.getUint8(1));
this.setUint8(byteOffset + 2, this._internalBuffer.getUint8(2));
this.setUint8(byteOffset + 3, this._internalBuffer.getUint8(3));
}
setFloat64(byteOffset, value, littleEndian) {
this._internalBuffer.setFloat64(0, value, littleEndian);
this.setUint8(byteOffset, this._internalBuffer.getUint8(0));
this.setUint8(byteOffset + 1, this._internalBuffer.getUint8(1));
this.setUint8(byteOffset + 2, this._internalBuffer.getUint8(2));
this.setUint8(byteOffset + 3, this._internalBuffer.getUint8(3));
this.setUint8(byteOffset + 4, this._internalBuffer.getUint8(4));
this.setUint8(byteOffset + 5, this._internalBuffer.getUint8(5));
this.setUint8(byteOffset + 6, this._internalBuffer.getUint8(6));
this.setUint8(byteOffset + 7, this._internalBuffer.getUint8(7));
}
setInt16(byteOffset, value, littleEndian) {
this._internalBuffer.setInt16(0, value, littleEndian);
this.setUint8(byteOffset, this._internalBuffer.getUint8(0));
this.setUint8(byteOffset + 1, this._internalBuffer.getUint8(1));
}
setInt32(byteOffset, value, littleEndian) {
this._internalBuffer.setInt32(0, value, littleEndian);
this.setUint8(byteOffset, this._internalBuffer.getUint8(0));
this.setUint8(byteOffset + 1, this._internalBuffer.getUint8(1));
this.setUint8(byteOffset + 2, this._internalBuffer.getUint8(2));
this.setUint8(byteOffset + 3, this._internalBuffer.getUint8(3));
}
setInt8(byteOffset, value) {
const [dataView, byteOffsetOfDataView] = this._findDataViewWithOffset(byteOffset);
dataView.setInt8(byteOffset - byteOffsetOfDataView, value);
}
setUint16(byteOffset, value, littleEndian) {
this._internalBuffer.setUint16(0, value, littleEndian);
this.setUint8(byteOffset, this._internalBuffer.getUint8(0));
this.setUint8(byteOffset + 1, this._internalBuffer.getUint8(1));
}
setUint32(byteOffset, value, littleEndian) {
this._internalBuffer.setUint32(0, value, littleEndian);
this.setUint8(byteOffset, this._internalBuffer.getUint8(0));
this.setUint8(byteOffset + 1, this._internalBuffer.getUint8(1));
this.setUint8(byteOffset + 2, this._internalBuffer.getUint8(2));
this.setUint8(byteOffset + 3, this._internalBuffer.getUint8(3));
}
setUint8(byteOffset, value) {
const [dataView, byteOffsetOfDataView] = this._findDataViewWithOffset(byteOffset);
dataView.setUint8(byteOffset - byteOffsetOfDataView, value);
}
_findDataViewWithOffset(byteOffset) {
let byteOffsetOfDataView = 0;
for (const dataView of this._dataViews) {
const byteOffsetOfNextDataView = byteOffsetOfDataView + dataView.byteLength;
if (byteOffset >= byteOffsetOfDataView && byteOffset < byteOffsetOfNextDataView) {
return [dataView, byteOffsetOfDataView];
}
byteOffsetOfDataView = byteOffsetOfNextDataView;
}
throw new RangeError();
}
}
exports.MultiBufferDataView = MultiBufferDataView;
var _multiBufferDataView = require("./classes/multi-buffer-data-view");

@@ -46,3 +46,3 @@ {

"mocha": "^6.2.2",
"rollup": "^1.27.12",
"rollup": "^1.27.13",
"rollup-plugin-babel": "^4.3.3",

@@ -52,3 +52,3 @@ "sinon": "^7.5.0",

"ts-loader": "^6.2.1",
"tsconfig-holy-grail": "^10.0.33",
"tsconfig-holy-grail": "^10.0.34",
"tslint": "^5.20.1",

@@ -92,3 +92,3 @@ "tslint-config-holy-grail": "^47.0.3",

"types": "build/es2018/module.d.ts",
"version": "1.1.2"
"version": "1.1.3"
}

@@ -1,222 +0,1 @@

export class MultiBufferDataView implements Omit<DataView, 'buffer'> {
private _buffers: ArrayBuffer[];
private _byteLength: number;
private _byteOffset: number;
private _dataViews: DataView[];
private _internalBuffer: DataView;
constructor (buffers: ArrayBuffer[], byteOffset = 0, byteLength?: number) {
if (byteOffset < 0 || (byteLength !== undefined && byteLength < 0)) {
throw new RangeError();
}
const availableBytes = buffers.reduce((length, buffer) => length + buffer.byteLength, 0);
if (byteOffset > availableBytes || (byteLength !== undefined && (byteOffset + byteLength) > availableBytes)) {
throw new RangeError();
}
const dataViews = [ ];
const effectiveByteLength = (byteLength === undefined) ? availableBytes - byteOffset : byteLength;
const truncatedBuffers = [ ];
let consumedByteLength = 0;
let truncatedByteOffset = byteOffset;
for (const buffer of buffers) {
if (truncatedBuffers.length === 0) {
if (buffer.byteLength > truncatedByteOffset) {
consumedByteLength = buffer.byteLength - truncatedByteOffset;
const byteLengthOfDataView = (consumedByteLength > effectiveByteLength) ? effectiveByteLength : consumedByteLength;
dataViews.push(new DataView(buffer, truncatedByteOffset, byteLengthOfDataView));
truncatedBuffers.push(buffer);
} else {
truncatedByteOffset -= buffer.byteLength;
}
} else if (truncatedBuffers.length > 0 && consumedByteLength < effectiveByteLength) {
consumedByteLength += buffer.byteLength;
const byteLengthOfDataView = (consumedByteLength > effectiveByteLength)
? buffer.byteLength - consumedByteLength + effectiveByteLength
: buffer.byteLength;
dataViews.push(new DataView(buffer, 0, byteLengthOfDataView));
truncatedBuffers.push(buffer);
}
}
this._buffers = truncatedBuffers;
this._byteLength = effectiveByteLength;
this._byteOffset = truncatedByteOffset;
this._dataViews = dataViews;
this._internalBuffer = new DataView(new ArrayBuffer(8));
}
get buffers (): ArrayBuffer[] {
return this._buffers;
}
get byteLength (): number {
return this._byteLength;
}
get byteOffset (): number {
return this._byteOffset;
}
public getFloat32 (byteOffset: number, littleEndian?: boolean): number {
this._internalBuffer.setUint8(0, this.getUint8(byteOffset + 0));
this._internalBuffer.setUint8(1, this.getUint8(byteOffset + 1));
this._internalBuffer.setUint8(2, this.getUint8(byteOffset + 2));
this._internalBuffer.setUint8(3, this.getUint8(byteOffset + 3));
return this._internalBuffer.getFloat32(0, littleEndian);
}
public getFloat64 (byteOffset: number, littleEndian?: boolean): number {
this._internalBuffer.setUint8(0, this.getUint8(byteOffset + 0));
this._internalBuffer.setUint8(1, this.getUint8(byteOffset + 1));
this._internalBuffer.setUint8(2, this.getUint8(byteOffset + 2));
this._internalBuffer.setUint8(3, this.getUint8(byteOffset + 3));
this._internalBuffer.setUint8(4, this.getUint8(byteOffset + 4));
this._internalBuffer.setUint8(5, this.getUint8(byteOffset + 5));
this._internalBuffer.setUint8(6, this.getUint8(byteOffset + 6));
this._internalBuffer.setUint8(7, this.getUint8(byteOffset + 7));
return this._internalBuffer.getFloat64(0, littleEndian);
}
public getInt16 (byteOffset: number, littleEndian?: boolean): number {
this._internalBuffer.setUint8(0, this.getUint8(byteOffset + 0));
this._internalBuffer.setUint8(1, this.getUint8(byteOffset + 1));
return this._internalBuffer.getInt16(0, littleEndian);
}
public getInt32 (byteOffset: number, littleEndian?: boolean): number {
this._internalBuffer.setUint8(0, this.getUint8(byteOffset + 0));
this._internalBuffer.setUint8(1, this.getUint8(byteOffset + 1));
this._internalBuffer.setUint8(2, this.getUint8(byteOffset + 2));
this._internalBuffer.setUint8(3, this.getUint8(byteOffset + 3));
return this._internalBuffer.getInt32(0, littleEndian);
}
public getInt8 (byteOffset: number): number {
const [ dataView, byteOffsetOfDataView ] = this._findDataViewWithOffset(byteOffset);
return dataView.getInt8(byteOffset - byteOffsetOfDataView);
}
public getUint16 (byteOffset: number, littleEndian?: boolean): number {
this._internalBuffer.setUint8(0, this.getUint8(byteOffset + 0));
this._internalBuffer.setUint8(1, this.getUint8(byteOffset + 1));
return this._internalBuffer.getUint16(0, littleEndian);
}
public getUint32 (byteOffset: number, littleEndian?: boolean): number {
this._internalBuffer.setUint8(0, this.getUint8(byteOffset + 0));
this._internalBuffer.setUint8(1, this.getUint8(byteOffset + 1));
this._internalBuffer.setUint8(2, this.getUint8(byteOffset + 2));
this._internalBuffer.setUint8(3, this.getUint8(byteOffset + 3));
return this._internalBuffer.getUint32(0, littleEndian);
}
public getUint8 (byteOffset: number): number {
const [ dataView, byteOffsetOfDataView ] = this._findDataViewWithOffset(byteOffset);
return dataView.getUint8(byteOffset - byteOffsetOfDataView);
}
public setFloat32 (byteOffset: number, value: number, littleEndian?: boolean): void {
this._internalBuffer.setFloat32(0, value, littleEndian);
this.setUint8(byteOffset, this._internalBuffer.getUint8(0));
this.setUint8(byteOffset + 1, this._internalBuffer.getUint8(1));
this.setUint8(byteOffset + 2, this._internalBuffer.getUint8(2));
this.setUint8(byteOffset + 3, this._internalBuffer.getUint8(3));
}
public setFloat64 (byteOffset: number, value: number, littleEndian?: boolean): void {
this._internalBuffer.setFloat64(0, value, littleEndian);
this.setUint8(byteOffset, this._internalBuffer.getUint8(0));
this.setUint8(byteOffset + 1, this._internalBuffer.getUint8(1));
this.setUint8(byteOffset + 2, this._internalBuffer.getUint8(2));
this.setUint8(byteOffset + 3, this._internalBuffer.getUint8(3));
this.setUint8(byteOffset + 4, this._internalBuffer.getUint8(4));
this.setUint8(byteOffset + 5, this._internalBuffer.getUint8(5));
this.setUint8(byteOffset + 6, this._internalBuffer.getUint8(6));
this.setUint8(byteOffset + 7, this._internalBuffer.getUint8(7));
}
public setInt16 (byteOffset: number, value: number, littleEndian?: boolean): void {
this._internalBuffer.setInt16(0, value, littleEndian);
this.setUint8(byteOffset, this._internalBuffer.getUint8(0));
this.setUint8(byteOffset + 1, this._internalBuffer.getUint8(1));
}
public setInt32 (byteOffset: number, value: number, littleEndian?: boolean): void {
this._internalBuffer.setInt32(0, value, littleEndian);
this.setUint8(byteOffset, this._internalBuffer.getUint8(0));
this.setUint8(byteOffset + 1, this._internalBuffer.getUint8(1));
this.setUint8(byteOffset + 2, this._internalBuffer.getUint8(2));
this.setUint8(byteOffset + 3, this._internalBuffer.getUint8(3));
}
public setInt8 (byteOffset: number, value: number): void {
const [ dataView, byteOffsetOfDataView ] = this._findDataViewWithOffset(byteOffset);
dataView.setInt8(byteOffset - byteOffsetOfDataView, value);
}
public setUint16 (byteOffset: number, value: number, littleEndian?: boolean): void {
this._internalBuffer.setUint16(0, value, littleEndian);
this.setUint8(byteOffset, this._internalBuffer.getUint8(0));
this.setUint8(byteOffset + 1, this._internalBuffer.getUint8(1));
}
public setUint32 (byteOffset: number, value: number, littleEndian?: boolean): void {
this._internalBuffer.setUint32(0, value, littleEndian);
this.setUint8(byteOffset, this._internalBuffer.getUint8(0));
this.setUint8(byteOffset + 1, this._internalBuffer.getUint8(1));
this.setUint8(byteOffset + 2, this._internalBuffer.getUint8(2));
this.setUint8(byteOffset + 3, this._internalBuffer.getUint8(3));
}
public setUint8 (byteOffset: number, value: number): void {
const [ dataView, byteOffsetOfDataView ] = this._findDataViewWithOffset(byteOffset);
dataView.setUint8(byteOffset - byteOffsetOfDataView, value);
}
private _findDataViewWithOffset (byteOffset: number): [ DataView, number ] {
let byteOffsetOfDataView = 0;
for (const dataView of this._dataViews) {
const byteOffsetOfNextDataView = byteOffsetOfDataView + dataView.byteLength;
if (byteOffset >= byteOffsetOfDataView && byteOffset < byteOffsetOfNextDataView) {
return [ dataView, byteOffsetOfDataView ];
}
byteOffsetOfDataView = byteOffsetOfNextDataView;
}
throw new RangeError();
}
}
export { MultiBufferDataView } from './classes/multi-buffer-data-view';

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc