mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 09:47:48 +00:00
Add support for comparing array buffers to _.isEqual.
This commit is contained in:
@@ -4512,6 +4512,13 @@
|
|||||||
*/
|
*/
|
||||||
function equalByTag(object, other, tag, equalFunc, customizer, bitmask) {
|
function equalByTag(object, other, tag, equalFunc, customizer, bitmask) {
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
|
case arrayBufferTag:
|
||||||
|
if ((object.byteLength != other.byteLength) ||
|
||||||
|
!equalFunc(new Uint8Array(object), new Uint8Array(other))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
case boolTag:
|
case boolTag:
|
||||||
case dateTag:
|
case dateTag:
|
||||||
// Coerce dates and booleans to numbers, dates to milliseconds and booleans
|
// Coerce dates and booleans to numbers, dates to milliseconds and booleans
|
||||||
|
|||||||
19
test/test.js
19
test/test.js
@@ -8024,6 +8024,25 @@
|
|||||||
assert.strictEqual(_.isEqual(new Foo, args), false);
|
assert.strictEqual(_.isEqual(new Foo, args), false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
QUnit.test('should compare array buffers', function(assert) {
|
||||||
|
assert.expect(2);
|
||||||
|
|
||||||
|
if (ArrayBuffer) {
|
||||||
|
var buffer1 = new ArrayBuffer(4),
|
||||||
|
buffer2 = new ArrayBuffer(8);
|
||||||
|
|
||||||
|
assert.strictEqual(_.isEqual(buffer1, buffer2), false);
|
||||||
|
|
||||||
|
buffer1 = new Int8Array([-1]).buffer;
|
||||||
|
buffer2 = new Uint8Array([255]).buffer;
|
||||||
|
|
||||||
|
assert.strictEqual(_.isEqual(buffer1, buffer2), true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
skipTest(assert, 2);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
QUnit.test('should compare date objects', function(assert) {
|
QUnit.test('should compare date objects', function(assert) {
|
||||||
assert.expect(4);
|
assert.expect(4);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user