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

@wry/equality

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wry/equality - npm Package Compare versions

Comparing version 0.3.3 to 0.3.4

tsconfig.test.json

40

lib/equality.esm.js

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

const { toString, hasOwnProperty } = Object.prototype;
const fnToStr = Function.prototype.toString;
const previousComparisons = new Map();
var _a = Object.prototype, toString = _a.toString, hasOwnProperty = _a.hasOwnProperty;
var fnToStr = Function.prototype.toString;
var previousComparisons = new Map();
/**

@@ -22,4 +22,4 @@ * Performs a deep equality check on two JavaScript values, tolerating cycles.

// the given value that is considerably more precise than typeof.
const aTag = toString.call(a);
const bTag = toString.call(b);
var aTag = toString.call(a);
var bTag = toString.call(b);
// If the runtime types of a and b are different, they could maybe be equal

@@ -41,11 +41,11 @@ // under some interpretation of equality, but for simplicity and performance

return true;
const aKeys = definedKeys(a);
const bKeys = definedKeys(b);
var aKeys = definedKeys(a);
var bKeys = definedKeys(b);
// If `a` and `b` have a different number of enumerable keys, they
// must be different.
const keyCount = aKeys.length;
var keyCount = aKeys.length;
if (keyCount !== bKeys.length)
return false;
// Now make sure they have the same keys.
for (let k = 0; k < keyCount; ++k) {
for (var k = 0; k < keyCount; ++k) {
if (!hasOwnProperty.call(b, aKeys[k])) {

@@ -56,4 +56,4 @@ return false;

// Finally, check deep equality of all child properties.
for (let k = 0; k < keyCount; ++k) {
const key = aKeys[k];
for (var k = 0; k < keyCount; ++k) {
var key = aKeys[k];
if (!check(a[key], b[key])) {

@@ -77,3 +77,3 @@ return false;

case '[object String]':
return a == `${b}`;
return a == "" + b;
case '[object Map]':

@@ -85,10 +85,10 @@ case '[object Set]': {

return true;
const aIterator = a.entries();
const isMap = aTag === '[object Map]';
var aIterator = a.entries();
var isMap = aTag === '[object Map]';
while (true) {
const info = aIterator.next();
var info = aIterator.next();
if (info.done)
break;
// If a instanceof Set, aValue === aKey.
const [aKey, aValue] = info.value;
var _a = info.value, aKey = _a[0], aValue = _a[1];
// So this works the same way for both Set and Map.

@@ -110,3 +110,3 @@ if (!b.has(aKey)) {

case '[object Function]': {
const aCode = fnToStr.call(a);
var aCode = fnToStr.call(a);
if (aCode !== fnToStr.call(b)) {

@@ -152,5 +152,5 @@ return false;

}
const nativeCodeSuffix = "{ [native code] }";
var nativeCodeSuffix = "{ [native code] }";
function endsWith(full, suffix) {
const fromIndex = full.length - suffix.length;
var fromIndex = full.length - suffix.length;
return fromIndex >= 0 &&

@@ -168,3 +168,3 @@ full.indexOf(suffix, fromIndex) === fromIndex;

// lengths) a chance to pass the equality test.
let bSet = previousComparisons.get(a);
var bSet = previousComparisons.get(a);
if (bSet) {

@@ -171,0 +171,0 @@ // Return true here because we can be sure false will be returned somewhere

@@ -5,5 +5,5 @@ 'use strict';

const { toString, hasOwnProperty } = Object.prototype;
const fnToStr = Function.prototype.toString;
const previousComparisons = new Map();
var _a = Object.prototype, toString = _a.toString, hasOwnProperty = _a.hasOwnProperty;
var fnToStr = Function.prototype.toString;
var previousComparisons = new Map();
/**

@@ -27,4 +27,4 @@ * Performs a deep equality check on two JavaScript values, tolerating cycles.

// the given value that is considerably more precise than typeof.
const aTag = toString.call(a);
const bTag = toString.call(b);
var aTag = toString.call(a);
var bTag = toString.call(b);
// If the runtime types of a and b are different, they could maybe be equal

@@ -46,11 +46,11 @@ // under some interpretation of equality, but for simplicity and performance

return true;
const aKeys = definedKeys(a);
const bKeys = definedKeys(b);
var aKeys = definedKeys(a);
var bKeys = definedKeys(b);
// If `a` and `b` have a different number of enumerable keys, they
// must be different.
const keyCount = aKeys.length;
var keyCount = aKeys.length;
if (keyCount !== bKeys.length)
return false;
// Now make sure they have the same keys.
for (let k = 0; k < keyCount; ++k) {
for (var k = 0; k < keyCount; ++k) {
if (!hasOwnProperty.call(b, aKeys[k])) {

@@ -61,4 +61,4 @@ return false;

// Finally, check deep equality of all child properties.
for (let k = 0; k < keyCount; ++k) {
const key = aKeys[k];
for (var k = 0; k < keyCount; ++k) {
var key = aKeys[k];
if (!check(a[key], b[key])) {

@@ -82,3 +82,3 @@ return false;

case '[object String]':
return a == `${b}`;
return a == "" + b;
case '[object Map]':

@@ -90,10 +90,10 @@ case '[object Set]': {

return true;
const aIterator = a.entries();
const isMap = aTag === '[object Map]';
var aIterator = a.entries();
var isMap = aTag === '[object Map]';
while (true) {
const info = aIterator.next();
var info = aIterator.next();
if (info.done)
break;
// If a instanceof Set, aValue === aKey.
const [aKey, aValue] = info.value;
var _a = info.value, aKey = _a[0], aValue = _a[1];
// So this works the same way for both Set and Map.

@@ -115,3 +115,3 @@ if (!b.has(aKey)) {

case '[object Function]': {
const aCode = fnToStr.call(a);
var aCode = fnToStr.call(a);
if (aCode !== fnToStr.call(b)) {

@@ -157,5 +157,5 @@ return false;

}
const nativeCodeSuffix = "{ [native code] }";
var nativeCodeSuffix = "{ [native code] }";
function endsWith(full, suffix) {
const fromIndex = full.length - suffix.length;
var fromIndex = full.length - suffix.length;
return fromIndex >= 0 &&

@@ -173,3 +173,3 @@ full.indexOf(suffix, fromIndex) === fromIndex;

// lengths) a chance to pass the equality test.
let bSet = previousComparisons.get(a);
var bSet = previousComparisons.get(a);
if (bSet) {

@@ -176,0 +176,0 @@ // Return true here because we can be sure false will be returned somewhere

{
"name": "@wry/equality",
"version": "0.3.3",
"version": "0.3.4",
"author": "Ben Newman <ben@eloper.dev>",

@@ -24,3 +24,3 @@ "description": "Structural equality checking for JavaScript values",

"build": "npm run clean && npm run tsc && npm run rollup",
"mocha": "../../scripts/test.sh lib/tests.js",
"mocha": "../../scripts/test.sh lib/tests.cjs.js",
"prepublish": "npm run build",

@@ -35,3 +35,3 @@ "test": "npm run build && npm run mocha"

},
"gitHead": "a0b5382625fdb4a581bd6a0fa8d460c7c2356aef"
"gitHead": "fd3a0435b70fa195e5e053aa63391e5cf15cc4ed"
}

@@ -7,2 +7,3 @@ import typescriptPlugin from 'rollup-plugin-typescript2';

tslib: "tslib",
assert: "assert",
};

@@ -41,2 +42,19 @@

},
}, {
input: "src/tests.ts",
external,
output: {
file: "lib/tests.cjs.js",
format: "cjs",
exports: "named",
sourcemap: true,
name: "equality-tests",
globals,
},
plugins: [
typescriptPlugin({
typescript,
tsconfig: "./tsconfig.test.json",
}),
],
}];
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"target": "esnext",
"rootDir": "./src",

@@ -6,0 +5,0 @@ "outDir": "./lib"

Sorry, the diff of this file is not supported yet

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