From: Feross Aboukhadijeh Date: Fri, 16 Feb 2018 07:58:11 +0000 (-0800) Subject: replace 'instanceof Buffer' with Buffer.isBuffer() X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=08ef8b54e3b7c29a697a4a45269d0172179d136c;p=buffer.git replace 'instanceof Buffer' with Buffer.isBuffer() To support buffers that come from other contexts like iframes, or Buffers that come from multiple version of buffer embedded in the same browserify bundle Always use Buffer.isBuffer!!! --- diff --git a/index.js b/index.js index 9d0f800..db55513 100644 --- a/index.js +++ b/index.js @@ -55,7 +55,7 @@ function typedArraySupport () { Object.defineProperty(Buffer.prototype, 'parent', { get: function () { - if (!(this instanceof Buffer)) { + if (!Buffer.isBuffer(this)) { return undefined } return this.buffer @@ -64,7 +64,7 @@ Object.defineProperty(Buffer.prototype, 'parent', { Object.defineProperty(Buffer.prototype, 'offset', { get: function () { - if (!(this instanceof Buffer)) { + if (!Buffer.isBuffer(this)) { return undefined } return this.byteOffset