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

just-compare

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

just-compare - npm Package Compare versions

Comparing version 2.0.1 to 2.0.3

CHANGELOG.md

37

index.js

@@ -21,2 +21,3 @@ module.exports = compare;

}
/* eslint-disable no-self-compare */

@@ -27,5 +28,10 @@ // if both values are NaNs return true

}
if ({}.toString.call(value1) != {}.toString.call(value2)) {
if (
typeof value1 != typeof value2 || // primitive != primitive wrapper
{}.toString.call(value1) != {}.toString.call(value2) // check for other (maybe nullish) objects
) {
return false;
}
if (value1 !== Object(value1)) {

@@ -35,16 +41,20 @@ // non equal primitives

}
if (!value1) {
return false;
}
if (Array.isArray(value1)) {
return compareArrays(value1, value2);
}
if ({}.toString.call(value1) == '[object Set]') {
return compareArrays(Array.from(value1), Array.from(value2));
}
if ({}.toString.call(value1) == '[object Object]') {
return compareObjects(value1, value2);
} else {
return compareNativeSubtypes(value1, value2);
}
return compareNativeSubtypes(value1, value2);
}

@@ -59,30 +69,33 @@

var len = value1.length;
if (len != value2.length) {
return false;
}
var alike = true;
for (var i = 0; i < len; i++) {
if (!compare(value1[i], value2[i])) {
alike = false;
break;
return false;
}
}
return alike;
return true;
}
function compareObjects(value1, value2) {
var keys1 = Object.keys(value1).sort();
var keys2 = Object.keys(value2).sort();
var keys1 = Object.keys(value1);
var len = keys1.length;
if (len != keys2.length) {
if (len != Object.keys(value2).length) {
return false;
}
for (var i = 0; i < len; i++) {
var key1 = keys1[i];
var key2 = keys2[i];
if (!(key1 == key2 && compare(value1[key1], value2[key2]))) {
if (!(value2.hasOwnProperty(key1) && compare(value1[key1], value2[key1]))) {
return false;
}
}
return true;
}
{
"name": "just-compare",
"version": "2.0.1",
"version": "2.0.3",
"description": "compare two collections",

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

@@ -0,1 +1,4 @@

<!-- DO NOT EDIT THIS FILE! THIS FILE WAS AUTOGENERATED BY TEMPLATE-MATE -->
<!-- SEE https://github.com/angus-c/just/blob/master/CONTRIBUTING.md#readme-template -->
## just-compare

@@ -2,0 +5,0 @@

Sorry, the diff of this file is not supported yet

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