Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
211 views
in Technique[技术] by (71.8m points)

javascript - How to get current byteoffset from the start of the dataview while advancing the buffer?

I'm trying to get the updated byte offset after inserting an element to dataview.

However, I don't know how to calculate the updated byte position from the beginning of the array.

My code:

let buffer = new ArrayBuffer(6);
let dataView = new DataView(buffer);
let bufferCounter = 0;
dataview.setUint16(0, 17);
bufferCounter += dataview.offset; // Is this the correct way?
console.log(bufferCounter); // Expecting "2", getting "0"

How can I get the result I was expecting?

Thanks.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...