Commit 05d424c0 authored by Trevor Norris's avatar Trevor Norris
Browse files

buffer: only check if instance is Uint8Array

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));

Fix: https://github.com/nodejs/node/issues/2882
PR-URL: https://github.com/nodejs/node/pull/3080


Reviewed-By: default avatarBen Noordhuis <info@bnoordhuis.nl>
parent 8a685e7f
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