Skip to content

Commit

Permalink
[Fix] robustly distinguish Typed Arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Mar 6, 2020
1 parent c1d173e commit 7ccb2b0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var callBound = require('es-abstract/helpers/callBound');
var whichCollection = require('which-collection');
var getIterator = require('es-get-iterator');
var getSideChannel = require('side-channel');
var whichTypedArray = require('which-typed-array');

var $getTime = callBound('Date.prototype.getTime');
var gPO = Object.getPrototypeOf;
Expand Down Expand Up @@ -304,6 +305,10 @@ function objEquiv(a, b, opts, channel) {
}
if (opts.strict && gPO && gPO(a) !== gPO(b)) { return false; }

if (whichTypedArray(a) !== whichTypedArray(b)) {
return false;
}

var aIsBuffer = isBuffer(a);
var bIsBuffer = isBuffer(b);
if (aIsBuffer !== bIsBuffer) { return false; }
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
"regexp.prototype.flags": "^1.3.0",
"side-channel": "^1.0.2",
"which-boxed-primitive": "^1.0.1",
"which-collection": "^1.0.1"
"which-collection": "^1.0.1",
"which-typed-array": "^1.1.1"
},
"devDependencies": {
"@ljharb/eslint-config": "^16.0.0",
Expand Down

0 comments on commit 7ccb2b0

Please sign in to comment.