From 08ef8b54e3b7c29a697a4a45269d0172179d136c Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Thu, 15 Feb 2018 23:58:11 -0800 Subject: [PATCH] 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!!! --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 -- 2.34.1