json-difference
Advanced tools
Comparing version 1.9.1 to 1.15.7
@@ -1,2 +0,21 @@ | ||
import { Delta } from '../models/jsondiffer.model'; | ||
export declare const getDiff: (oldStruct: Record<string, any>, newStruct: Record<string, any>, isLodashLike?: boolean) => Delta; | ||
import { Delta, JsonDiffOptions } from '../models/jsondiffer.model'; | ||
/** | ||
* This method returns a delta object containing all the information needed to understand what happened during | ||
* the transition from the original object to the modified one. | ||
* | ||
* @param oldStruct Original structure to be investigated | ||
* @param newStruct Modified structure to be investigated | ||
* @param options Options for changing result behavior | ||
* @returns returns a JSON diference delta | ||
* | ||
* | ||
* @example | ||
* const oldStruct = { 1: null } | ||
* const newStruct = { 1: "coffee" } | ||
* | ||
* const result = getDiff(oldStruct, newStruct) | ||
* | ||
* console.log(result) | ||
* // Output: {"edited": [["1", null, "coffee"]], added: [], removed: []} | ||
*/ | ||
export declare const getDiff: (oldStruct: Record<string, any> | string, newStruct: Record<string, any> | string, options?: JsonDiffOptions) => Delta; |
import { EditedPath, StructPaths } from '../models/jsondiffer.model'; | ||
/** | ||
* This method returns all paths whose leaf value has changed | ||
* | ||
* @param oldStructPaths Original paths to be investigated | ||
* @param newStructPaths Modified paths to be investigated | ||
* @returns returns an object with all edited paths | ||
* | ||
* | ||
* @example | ||
* const oldStruct = { 1: null } | ||
* const newStruct = { 1: "coffee" } | ||
* | ||
* const result = getEditedPaths(oldStruct, newStruct) | ||
* | ||
* // Output: [1, null ,"coffee"] | ||
* console.log(result) | ||
*/ | ||
export declare const getEditedPaths: (oldStructPaths: StructPaths, newStructPaths: StructPaths) => Array<EditedPath>; |
import { PathsDiff, StructPaths } from '../models/jsondiffer.model'; | ||
/** | ||
* This method returns all paths whose leaf value has changed | ||
* | ||
* @param oldStructPaths Original paths to be investigated | ||
* @param newStructPaths Modified paths to be investigated | ||
* @returns returns an object with all edited paths | ||
* | ||
* | ||
* @example | ||
* const oldStruct = { 1: null, 2: "tea" } | ||
* const newStruct = { 1: "coffee" } | ||
* | ||
* const result = getPathsDiff(oldStruct, newStruct) | ||
* | ||
* console.log(result) | ||
* // Output: ["2": "tea"] | ||
*/ | ||
export declare const getPathsDiff: (oldStructPaths: StructPaths, newStructPaths: StructPaths) => Array<PathsDiff>; |
import { StructPaths } from '../models/jsondiffer.model'; | ||
/** | ||
* This method returns all possible paths to leaf nodes and objects other than null | ||
* | ||
* @param struct A structure to be processed | ||
* @param isLodashLike Boolean to change the path generation behavior | ||
* @returns returns a list of all paths | ||
* | ||
* | ||
* @example | ||
* const struct = { 1: { 2: null } } | ||
* | ||
* const result1 = getStructPaths(struct) | ||
* const result2 = getStructPaths(struct, { isLodashLike: true }}) | ||
* | ||
* | ||
* The values "@{}" and "@[]" are used internally to represent objects and arrays respectively. | ||
* But they have a particular meaning, where the key is parent, that is, it must have children. | ||
* ("@{}" !== "{}" && "@[]" !== "[]") => true | ||
* | ||
* console.log(result) | ||
* // Output: {"1": "@{}","1/2": null} | ||
* | ||
* console.log(result) | ||
* // Output: {"1": "@{}","1.2": null} | ||
*/ | ||
export declare const getStructPaths: (struct: any, isLodashLike?: boolean, paths?: { | ||
[key: string]: any; | ||
}, currentPath?: string) => StructPaths; | ||
} | undefined, currentPath?: string) => StructPaths; |
@@ -1,14 +0,1 @@ | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./core"), exports); | ||
__exportStar(require("./models"), exports); | ||
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=(e,f)=>{const o=[];for(const i in e)if(f.hasOwnProperty(i)){if(typeof e[i]=="object"&&typeof f[i]=="object"&&JSON.stringify(e[i])===JSON.stringify(f[i])||e[i]===f[i])continue;if(e[i]==="@{}"||e[i]==="@[]"){const n=f[i]==="@{}"?{}:f[i]==="@[]"?[]:f[i];e[i]==="@{}"?JSON.stringify(f[i])!=="{}"&&o.push([i,{},n]):JSON.stringify(f[i])!=="[]"&&o.push([i,[],n])}else o.push([i,e[i],f[i]])}return o},p=(e,f)=>{const o=[];let i=0;for(const n in e)if(!(n in f)){const r=e[n]==="@{}"?{}:e[n]==="@[]"?[]:e[n];o[i]=[n,r],i++}return o},O=(e,f,o,i)=>{const n=i?e?"[":".":"/",r=i?e?"]":"":e?"[]":"";return f==="__start__"?`${i&&e?"[":""}${o}${r}`:`${f}${n}${o}${r}`},s=(e,f=!1,o,i="__start__")=>{o===void 0&&(o=Array.isArray(e)?{__root__:"@[]"}:{__root__:"@{}"});for(const n of Object.keys(e)){const r=O(Array.isArray(e),i,n,f);typeof e[n]=="object"&&e[n]!==null?(Object.keys(e[n]).length===0?o[r]=e[n]:o[r]=Array.isArray(e[n])?"@[]":"@{}",s(e[n],f,o,r)):o[r]=e[n]}return o},c=e=>(e.edited=e.edited.filter(f=>!(typeof f[1]=="object"&&f[2]==="@{}")).map(f=>f[2]==="@{}"?[f[0],f[1],{}]:f[2]==="@[]"?[f[0],f[1],[]]:f),e),b={isLodashLike:!1},j=(e,f,o)=>{const{isLodashLike:i}=o??b,n={added:[],removed:[],edited:[]},r=typeof e=="string"?JSON.parse(e):e,_=typeof f=="string"?JSON.parse(f):f,y=s(r,i),g=s(_,i);return n.removed=p(y,g),n.added=p(g,y),n.edited=t(y,g),c(n)};exports.getDiff=j;exports.getEditedPaths=t;exports.getPathsDiff=p;exports.getStructPaths=s; |
@@ -1,4 +0,4 @@ | ||
export declare type EditedPath = [string, any, any]; | ||
export declare type StructPaths = Record<string, any>; | ||
export declare type PathsDiff = [string, any]; | ||
export type EditedPath = [string, any, any]; | ||
export type StructPaths = Record<string, any>; | ||
export type PathsDiff = [string, any]; | ||
export interface Delta { | ||
@@ -9,1 +9,4 @@ added: Array<PathsDiff>; | ||
} | ||
export interface JsonDiffOptions { | ||
isLodashLike?: boolean; | ||
} |
{ | ||
"name": "json-difference", | ||
"version": "1.9.1", | ||
"description": "json diff lib", | ||
"version": "1.15.7", | ||
"author": "lukascivil", | ||
"homepage": "https://github.com/lukascivil/json-difference#readme", | ||
"description": "json difference lib", | ||
"license": "MIT", | ||
"main": "dist", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"engines": { | ||
"node": ">=14.x" | ||
"node": ">=18.17.x" | ||
}, | ||
@@ -15,16 +17,5 @@ "files": [ | ||
], | ||
"scripts": { | ||
"lint": "eslint --ext .ts", | ||
"check-types": "tsc --noemit -p tsconfig.json", | ||
"test": "jest --config jestconfig.json --coverage", | ||
"test:local": "jest --watchAll --config jestconfig.json", | ||
"example": "echo Use {simple} or {stress} as example param && cd ./examples && yarn", | ||
"build": "tsc && vite build", | ||
"format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"", | ||
"prepare": "yarn build", | ||
"prepublishOnly": "yarn test" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/lukascivil/jsondiffer.git" | ||
"url": "git+https://github.com/lukascivil/json-difference.git" | ||
}, | ||
@@ -35,21 +26,12 @@ "keywords": [ | ||
], | ||
"author": "lukascivil", | ||
"homepage": "https://github.com/lukascivil/jsondiffer#readme", | ||
"devDependencies": { | ||
"@types/jest": "^28.1.6", | ||
"@typescript-eslint/eslint-plugin": "^5.0.0", | ||
"eslint": "^8.32.0", | ||
"eslint-config-standard-with-typescript": "^22.0.0", | ||
"eslint-plugin-import": "^2.27.5", | ||
"eslint-plugin-jest": "^27.2.1", | ||
"eslint-plugin-n": "^15.0.0", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"eslint-plugin-promise": "^6.0.0", | ||
"jest": "^29.3.1", | ||
"prettier": "^2.8.3", | ||
"ts-jest": "^29.0.5", | ||
"typescript": "4.4.3", | ||
"vite": "^4.0.4", | ||
"vite-tsconfig-paths": "^4.0.5" | ||
"scripts": { | ||
"lint": "eslint --ext .ts", | ||
"check-types": "tsc --noemit -p tsconfig.json", | ||
"test": "jest --config jestconfig.json --coverage", | ||
"test:local": "jest --watchAll --config jestconfig.json", | ||
"format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"", | ||
"example": "echo Use {simple} or {stress} as example param && cd ./apps/examples && yarn", | ||
"start-playground": "yarn --cwd apps/playground dev", | ||
"build-playground": "yarn --cwd apps/playground build" | ||
} | ||
} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
0
11254
14
177
1
0
1