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

json-difference

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-difference - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

2

dist.browser/json-difference.umd.js

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

(function(t,d){typeof exports=="object"&&typeof module<"u"?d(exports):typeof define=="function"&&define.amd?define(["exports"],d):(t=typeof globalThis<"u"?globalThis:t||self,d(t["json-difference"]={}))})(this,function(t){"use strict";const d=(i,n)=>{const o=[];let e={};for(const f in i)if(n.hasOwnProperty(f)){if(typeof i[f]=="object"&&typeof n[f]=="object"&&JSON.stringify(i[f])===JSON.stringify(n[f]))continue;i[f]!==n[f]&&(e={[f]:{oldValue:i[f],newValue:n[f]}},o.push(e))}return o},y=(i,n)=>{const o={};for(const e in i)e in n||(o[e]=i[e]);return o},s=(i,n={},o="")=>{for(const e of Object.keys(i)){const f=o!==""?`${o}/${e}`:e;typeof i[e]=="object"?(Object.keys(i[e]).length===0&&(n[f]=i[e]),s(i[e],n,f)):n[f]=i[e]}return n},c=(i,n)=>{const o={added:{},removed:{},edited:[]},e=s(i),f=s(n);return o.removed=y(e,f),o.added=y(f,e),o.edited=d(e,f),o};t.getDiff=c,t.getEditedPaths=d,t.getPathsDiff=y,t.getStructPaths=s,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
(function(t,d){typeof exports=="object"&&typeof module<"u"?d(exports):typeof define=="function"&&define.amd?define(["exports"],d):(t=typeof globalThis<"u"?globalThis:t||self,d(t["json-difference"]={}))})(this,function(t){"use strict";const d=(i,n)=>{const o=[];let e={};for(const f in i)if(n.hasOwnProperty(f)){if(typeof i[f]=="object"&&typeof n[f]=="object"&&JSON.stringify(i[f])===JSON.stringify(n[f]))continue;i[f]!==n[f]&&(e={[f]:[i[f],n[f]]},o.push(e))}return o},y=(i,n)=>{const o={};for(const e in i)e in n||(o[e]=i[e]);return o},s=(i,n={},o="")=>{for(const e of Object.keys(i)){const f=o!==""?`${o}/${e}`:e;typeof i[e]=="object"?(Object.keys(i[e]).length===0&&(n[f]=i[e]),s(i[e],n,f)):n[f]=i[e]}return n},c=(i,n)=>{const o={added:{},removed:{},edited:[]},e=s(i),f=s(n);return o.removed=y(e,f),o.added=y(f,e),o.edited=d(e,f),o};t.getDiff=c,t.getEditedPaths=d,t.getPathsDiff=y,t.getStructPaths=s,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});

@@ -9,3 +9,3 @@ "use strict";

var struct2 = { 1: { 3: { 4: 5 } } };
var expectedResult = { edited: [{ '1/3/4': { newValue: 5, oldValue: 6 } }], added: {}, removed: { '1/2': 7 } };
var expectedResult = { edited: [{ '1/3/4': [6, 5] }], added: {}, removed: { '1/2': 7 } };
var result = (0, _1.getDiff)(struct1, struct2);

@@ -18,3 +18,3 @@ expect(result).toEqual(expectedResult);

var expectedResult = {
edited: [{ a: { newValue: 11, oldValue: 1 } }, { 'b/1/c2': { newValue: 22, oldValue: 2 } }],
edited: [{ a: [1, 11] }, { 'b/1/c2': [2, 22] }],
added: {},

@@ -30,3 +30,3 @@ removed: {}

var expectedResult = {
edited: [{ a: { newValue: 11, oldValue: 1 } }, { 'b/0/c1/0/c3/c5/2/c6': { newValue: 4, oldValue: 3 } }],
edited: [{ a: [1, 11] }, { 'b/0/c1/0/c3/c5/2/c6': [3, 4] }],
added: {},

@@ -42,3 +42,3 @@ removed: {}

var expectedResult = {
edited: [{ a: { newValue: '1', oldValue: 1 } }, { c: { newValue: true, oldValue: 3 } }],
edited: [{ a: [1, '1'] }, { c: [3, true] }],
added: { b: 2 },

@@ -65,8 +65,3 @@ removed: { 'b/c1': 2 }

var expectedResult = {
edited: [
{ a: { newValue: {}, oldValue: [] } },
{ b: { newValue: [], oldValue: {} } },
{ c: { newValue: false, oldValue: [] } },
{ d: { newValue: 1, oldValue: {} } }
],
edited: [{ a: [[], {}] }, { b: [{}, []] }, { c: [[], false] }, { d: [{}, 1] }],
added: {},

@@ -73,0 +68,0 @@ removed: {}

@@ -17,6 +17,3 @@ "use strict";

diff = (_a = {},
_a[key] = {
oldValue: oldStructPaths[key],
newValue: newStructPaths[key]
},
_a[key] = [oldStructPaths[key], newStructPaths[key]],
_a);

@@ -23,0 +20,0 @@ diffs.push(diff);

@@ -8,3 +8,3 @@ "use strict";

var newStruct = { a: 1, b: 'a/a/a/a/a/a/a', d: '0/1/2/3/4/5/6/7/8/9', e: 4 };
var expectedResult = [];
var expectedResult = Array();
var result = (0, _1.getEditedPaths)(oldStruct, newStruct);

@@ -17,5 +17,5 @@ expect(result).toEqual(expectedResult);

var expectedResult = [
{ b: { newValue: 'b/b/b/b/b/b/b', oldValue: 'a/a/a/a/a/a/a' } },
{ c: { newValue: '1/1/1/1', oldValue: '0/0/0/0' } },
{ d: { newValue: '9/8/7/6/5/4/3/2/1/0', oldValue: '0/1/2/3/4/5/6/7/8/9' } }
{ b: ['a/a/a/a/a/a/a', 'b/b/b/b/b/b/b'] },
{ c: ['0/0/0/0', '1/1/1/1'] },
{ d: ['0/1/2/3/4/5/6/7/8/9', '9/8/7/6/5/4/3/2/1/0'] }
];

@@ -35,8 +35,3 @@ var result = (0, _1.getEditedPaths)(oldStruct, newStruct);

var newStruct = { a: {}, b: [], c: false, d: 1 };
var expectedResult = [
{ a: { newValue: {}, oldValue: [] } },
{ b: { newValue: [], oldValue: {} } },
{ c: { newValue: false, oldValue: [] } },
{ d: { newValue: 1, oldValue: {} } }
];
var expectedResult = [{ a: [[], {}] }, { b: [{}, []] }, { c: [[], false] }, { d: [{}, 1] }];
var result = (0, _1.getEditedPaths)(oldStruct, newStruct);

@@ -43,0 +38,0 @@ expect(result).toEqual(expectedResult);

export declare type EditedPath = {
[key: string]: {
newValue: any;
oldValue: any;
};
[key: string]: [any, any];
};

@@ -7,0 +4,0 @@ export declare type StructPaths = Record<string, any>;

{
"name": "json-difference",
"version": "1.3.0",
"version": "1.4.0",
"description": "json diff lib",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -72,12 +72,6 @@ # jsondiffer

{
"color/color1": {
"oldValue": "black",
"newValue": "red"
}
"color/color1": ["black", "red"]
},
{
"color/color2": {
"oldValue": "brown",
"newValue": "blue"
}
"color/color2": ["brown", "blue"]
}

@@ -84,0 +78,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