Giter VIP home page Giter VIP logo

equal's People

Contributors

btd avatar vingarcia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

equal's Issues

Bug in Map with object keys

In Maps it is possible to use objects as keys and even to use the same key multiple times.
The latter will fail right now.

const a = new Map([[{}, {a:6}], [{}, {a:5}]])
const b = new Map([[{}, {a:6}], [{}, {a:5}]])
eq(a, b) // failure
[ EqualityFail {
    a: 6,
    b: 5,
    reason: 'A is not equal to B',
    path: [ 'a' ],
    showReason: false },
  EqualityFail {
    a: 5,
    b: 6,
    reason: 'A is not equal to B',
    path: [ 'a' ],
    showReason: false } ]

ES6 Set support

Is it possible to work ES6 set support into this? I would love to be able to compare 2 sets, and see which members differ.

Thanks for the outstanding work, regardless!

WeakSet and WeakMap bug

Right now WeakSet and WeakMap are considered to behave the same as Set and Map. This is however not true and comparing these types will result in the following error. It is actually not possible to check for WeakSet or WeakMap equality at all. It is only possible to check if a entry itself exists or not.

const a = new WeakSet()
const b = new WeakSet()
eq(a,b) // TypeError: a.entries is not a function
    at EQ._check_object_weak-set (/home/repos/general/equal/cjs/should-equal.js:281:23)
    at EQ.check0 (/home/repos/general/equal/cjs/should-equal.js:130:7)
    at EQ.check (/home/repos/general/equal/cjs/should-equal.js:90:12)
    at eq (/home/repos/general/equal/cjs/should-equal.js:312:29)

deepEqual only compares TypedArrays but not bare ArrayBuffers

The following code reproduces the issue:

require("should");

const a = (new Uint8Array([1])).buffer;
const b = (new Uint8Array([2])).buffer; 

console.log(a.constructor, b.constructor);
// [Function: ArrayBuffer] [Function: ArrayBuffer]
console.log(a.should.deepEqual(b)); // doesn't throw
/*
Assertion {
  obj: ArrayBuffer { [Uint8Contents]: <01>, byteLength: 1 },
  anyOne: false,
  negate: false,
  params: {
    operator: 'to equal',
    expected: ArrayBuffer { [Uint8Contents]: <02>, byteLength: 1 },
    message: undefined,
    details: '',
    showDiff: true
  }
}
*/

const c = new Uint8Array([1]);
const d = new Uint8Array([2]);

console.log(c.constructor, d.constructor);
// [Function: Uint8Array] [Function: Uint8Array]
console.log(c.should.deepEqual(d)); // throws

The first deepEqual should throw as well, but it doesn't. I'm using shouldjs 13.2.3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.