var buf2 = new Uint8Array(buf.buffer, 20, 40);
buf is a TypedArray, buf.buffer is an ArrayBuffer.
Creating a second view like you showed doesn't work, it copies the whole buffer.
Try the following code:
var buf = new Uint8Array(100);
var buf2 = new Uint8Array(buf, 20, 40);
It might work if I use actual ArrayBuffers, but for that I will have to change my whole code.