DataView slice

Sometimes you just want a sub dataview and that is currently pretty annoying to do:

new DataView(dataview.buffer, dataview.byteOffset + offset, length)

a .slice method seems way more logical. Also you don't want people slicing the buffer as that creates a copy.

So am I the only one longing for this.

I wouldn't call it .slice(), since as you mentioned, that has the meaning of "copy and create new", but it certainly wouldn't be unreasonable to add a .subview() method for parity with TypedArray.prototype.subarray().

1 Like