Skip to content

Native buf checks

Native Buffer method calls do not require anything from the prototype. So it is unnecessary to check if the Object's prototype is equal to Buffer.prototype.

This fixes an issue that prevents Buffer from being inherited the ES5 way. Now the following will work:

function A(n) {
  const b = new Buffer(n);
  Object.setPrototypeOf(b, A.prototype);
  return b;
}

Object.setPrototypeOf(A.prototype, Buffer.prototype);
Object.setPrototypeOf(A, Buffer);

console.log(new A(4));

R=@bnoordhuis Also, will those native buffer functions need to be re-added for this to land on v4?

Merge request reports

Loading