New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

array-changes

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-changes - npm Package Compare versions

Comparing version 3.0.0 to 3.0.1

33

lib/arrayChanges.js

@@ -200,24 +200,35 @@ var arrayDiff = require('arraydiff-papandreou');

nonNumericalKeys.forEach(function (key) {
var valueExpected;
if (key in actual) {
if (key in expected) {
var valueActual = actual[key];
valueExpected = expected[key];
if (key in expected && typeof valueExpected !== 'undefined') {
valueExpected = expected[key];
mutatedArray.push({
type: equal(actual[key], expected[key], key, key) ? 'equal' : 'similar',
type: equal(valueActual, valueExpected, key, key) ? 'equal' : 'similar',
expectedIndex: key,
actualIndex: key,
value: actual[key],
expected: expected[key]
value: valueActual,
expected: valueExpected
});
} else {
} else if (typeof valueActual !== 'undefined') {
mutatedArray.push({
type: 'remove',
actualIndex: key,
value: actual[key]
value: valueActual
});
}
} else {
mutatedArray.push({
type: 'insert',
expectedIndex: key,
value: expected[key]
});
valueExpected = expected[key];
if (typeof valueExpected !== 'undefined') {
mutatedArray.push({
type: 'insert',
expectedIndex: key,
value: valueExpected
});
}
}

@@ -224,0 +235,0 @@ });

{
"name": "array-changes",
"version": "3.0.0",
"version": "3.0.1",
"description": "Array diffing",

@@ -5,0 +5,0 @@ "main": "./lib/arrayChanges.js",

@@ -271,2 +271,59 @@ /*global describe, it, Symbol*/

describe('when including non-numerical properties', function () {
it('returns an empty change-list with an undefined key on the LHS', function () {
var a = [];
a.nothing = undefined;
var b = [];
expect(arrayChanges(a, b, undefined, false, {
includeNonNumericalProperties: true
}), 'to equal', []);
});
it('returns an empty change-list with an undefined key on the RHS', function () {
var a = [];
var b = [];
b.nothing = undefined;
expect(arrayChanges(a, b, undefined, false, {
includeNonNumericalProperties: true
}), 'to equal', []);
});
it('returns an empty change-list with undefined keys on both the LHS and RHS', function () {
var a = [];
a.nothing = undefined;
var b = [];
b.nothing = undefined;
expect(arrayChanges(a, b, undefined, false, {
includeNonNumericalProperties: true
}), 'to equal', []);
});
it('returns a change-list containing remove when a LHS key is undefined on the RHS', function () {
var a = [];
a.nothing = true;
var b = [];
b.nothing = undefined;
expect(arrayChanges(a, b, undefined, false, {
includeNonNumericalProperties: true
}), 'to equal', [
{ type: 'remove', actualIndex: 'nothing', value: true, expected: undefined, last: true }
]);
});
it('returns a change-list containing similar when a RHS key is undefined on the LHS', function () {
var a = [];
a.nothing = undefined;
var b = [];
b.nothing = true;
expect(arrayChanges(a, b, undefined, false, {
includeNonNumericalProperties: true
}), 'to equal', [
{ type: 'similar', expectedIndex: 'nothing', actualIndex: 'nothing', value: undefined, expected: true, last: true }
]);
});
it('should diff arrays that have non-numerical property names', function () {

@@ -273,0 +330,0 @@ var a = [1, 2, 3];

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