Commit 5a9d30bb authored by Ben Noordhuis's avatar Ben Noordhuis
Browse files

typed arrays: copy Buffer in typed array constructor

Convert the Buffer to an ArrayBuffer. The typed_array.buffer property
should be an ArrayBuffer to avoid confusion: a Buffer doesn't have a
byteLength property and more importantly, its slice() method works
subtly different.

That means that before this commit:

  var buf = new Buffer(1);
  var arr = new Int8Array(buf);
  assert.equal(arr.buffer, buf);
  assert(arr.buffer instanceof Buffer);

And now:

  var buf = new Buffer(1);
  var arr = new Int8Array(buf);
  assert.notEqual(arr.buffer, buf);
  assert(arr.buffer instanceof ArrayBuffer);
parent fe103357
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment