buffer: clean up usage of __proto__
authorTrevor Norris <trev.norris@gmail.com>
Sat, 26 Sep 2015 22:18:08 +0000 (16:18 -0600)
committerJames M Snell <jasnell@gmail.com>
Thu, 8 Oct 2015 03:39:16 +0000 (20:39 -0700)
Prefer using Object.setPrototypeOf() instead.

PR-URL: https://github.com/nodejs/node/pull/3080
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
lib/buffer.js

index fc4f269..2da61f6 100644 (file)
@@ -58,8 +58,8 @@ function Buffer(arg) {
   return fromObject(arg);
 }
 
-Buffer.prototype.__proto__ = Uint8Array.prototype;
-Buffer.__proto__ = Uint8Array;
+Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype);
+Object.setPrototypeOf(Buffer, Uint8Array);
 
 
 function SlowBuffer(length) {
@@ -72,8 +72,8 @@ function SlowBuffer(length) {
   return ui8;
 }
 
-SlowBuffer.prototype.__proto__ = Buffer.prototype;
-SlowBuffer.__proto__ = Buffer;
+Object.setPrototypeOf(SlowBuffer.prototype, Uint8Array.prototype);
+Object.setPrototypeOf(SlowBuffer, Uint8Array);
 
 
 function allocate(size) {