Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

should-equal

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

should-equal - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

15

index.js

@@ -30,2 +30,3 @@ var getType = require('should-type');

EQUALITY: 'A is not equal to B',
EQUALITY_PROTOTYPE: 'A and B have different prototypes',
WRAPPED_VALUE: 'A wrapped value is not equal to B wrapped value',

@@ -163,2 +164,16 @@ FUNCTION_SOURCES: 'function A is not equal to B by source code value (via .toString call)',

var prototypesEquals = false, canComparePrototypes = false;
if(Object.getPrototypeOf) {
prototypesEquals = Object.getPrototypeOf(a) === Object.getPrototypeOf(b);
canComparePrototypes = true;
} else if(a.__proto__ && b.__proto__) {
prototypesEquals = a.__proto__ === b.__proto__;
canComparePrototypes = true;
}
if(canComparePrototypes && !prototypesEquals) {
return makeResult(false, path, REASON.EQUALITY_PROTOTYPE, a, b);
}
stackA.pop();

@@ -165,0 +180,0 @@ stackB.pop();

2

package.json
{
"name": "should-equal",
"version": "0.1.1",
"version": "0.2.0",
"description": "Deep comparison of 2 instances for should.js",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -331,2 +331,43 @@ var assert = require('assert');

ne(re1, /a/);
};
exports['Date with props'] = function() {
var now = Date.now();
var d1 = new Date(now);
var d2 = new Date(now);
d1.a = 10;
ne(d1, d2);
};
exports['Check object prototypes'] = function() {
var nbRoot = {
toString: function() { return this.first + ' ' + this.last; }
};
function nameBuilder(first, last) {
this.first = first;
this.last = last;
return this;
}
nameBuilder.prototype = nbRoot;
function nameBuilder2(first, last) {
this.first = first;
this.last = last;
return this;
}
nameBuilder2.prototype = nbRoot;
var nb1 = new nameBuilder('Ryan', 'Dahl');
var nb2 = new nameBuilder2('Ryan', 'Dahl');
eq(nb1, nb2);
nameBuilder2.prototype = Object;
nb2 = new nameBuilder2('Ryan', 'Dahl');
ne(nb1, nb2);
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc