Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native buf checks #3080

Closed
wants to merge 2 commits into from
Closed

Commits on Oct 6, 2015

  1. buffer: cleanup usage of __proto__

    Prefer using Object.setPrototypeOf() instead.
    trevnorris committed Oct 6, 2015
    Configuration menu
    Copy the full SHA
    7547947 View commit details
    Browse the repository at this point in the history
  2. 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: nodejs#2882
    trevnorris committed Oct 6, 2015
    Configuration menu
    Copy the full SHA
    b7eb4f1 View commit details
    Browse the repository at this point in the history