npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

deltajson

v1.0.3

Published

A powerful JSON comparision tool

Downloads

9

Readme

*Use of this product requires a license

deltajson

DeltaJSON is a powerful tool used to accurately compare the differences between two json files. With superior results for unordered array comparison, combined with a JSON output format for ease of use in further transformation of results.

Getting a free DeltaJSON subscription

For DeltaJSON to work you will need a token file.

To get this file head to our website to sign up and download your token file. If you already have a subscription head to DeltaJSON App to get your token file.

Installation

To install the DeltaJSON package, navigate to your desired location in your terminal, and type the following commands.

npm install deltajson
npm link deltajson

In your development environment, place the token file in the root directory of your project. Make sure you add the filename to your .gitignore file.

echo 'DeltaJSON_Auth.json' >> .gitignore

Get Started

Getting started in Node

Import the package in your .js file

import deltajson from 'deltajson'

Once that has been completed, the function deltajson.compare() will be available for you to use. Here is an example of how to use the compare function:

let Result = await deltajson.compare('/Path/to/fileA.json','/Path/to/fileB.json')

Your JSON will be compared and the result can then be further processed as required. Note: the compare function is calling a rest service, you will need to use the "await/async" functions to be able to receive the results.

Now you are ready to configure your comparison using additional parameters which are described below in the Usage section.


Getting started on the command Line using deltajson command

The above sample will run a basic comparison. This is an example of the sample running the below code:

deltajson compare node_modules/deltajson/samples/fileA.json node_modules/deltajson/samples/fileB.json result.json

You can replace fileA and fileB with your own files and give it a try.

deltajson compare [/Path/to/your/first/fileA.json] [/Path/to/your/second/fileB.json] [/Path/to/your/results/result.json]

Getting started on the command Line using sample

If you want explore DeltaJSON parameters we have provided a sample below.

Download and place the token file in the same folder as the installed node package. This would normally be node_modules/deltajson. When that has been completed you will be able to run the sample.

Navigate in the terminal to the same folder as the installed node package and run this command. This will run a preset sample to give you an example of how the comparison works.

npm run sample

Configuration

Configuration parameters for each operation

|Parameters|Options|Default| |--------|--------|------| |wordByWord|true/false|false| |arrayAlignment|Orderless/Type With Value/Position|Orderless| |dxConfig|ignoreChanges|null|

Usage

Default JSON Comparison

When using the package in node the following lines will do the default comparison and return a json.

import deltajson from 'deltajson'
let Result = await deltajson.compare('/Path/to/fileA.json','/Path/to/fileB.json')

When using the command line, the following fields are all required and should be typed in in the following order. This will do a comparison with the default parameters set.

  1. npmjson
  2. compare
  3. Path to first json file
  4. Path to second json file
  5. Result file name
deltajson compare fileA.json fileB.json result.json

wordByWord

The parameter wordByWord will give you a more granualar result. This is set to false by default.

let result = await deltajson.compare('fileA.json','fileB.json',{"wordByWord":"true"});
deltajson compare fileA.json fileB.json result.json wordByWord=true

Click here for more information on how wordByWord works.


arrayAlignment

This parameter gives you control over how items in arrays are matched for comparison. The options for arrayAlignment are as follows:

  • orderless(default)
let result = await deltajson.compare('fileA.json','fileB.json',{"arrayAlignment":"Orderless"});
deltajson compare fileA.json fileB.json result.json arrayAlignment=orderless
  • typeWithValuePriority
let result = await deltajson.compare('fileA.json','fileB.json',{"arrayAlignment":"Orderless"});
deltajson compare fileA.json fileB.json result.json arrayAlignment=typeWithValuePriority
  • positionPriority
let result = await deltajson.compare('fileA.json','fileB.json',{"arrayAlignment":"positionPriority"});
deltajson compare fileA.json fileB.json result.json arrayAlignment=positionPriority

Click here for more information on how arrayAlignment works.


dxConfig - To specify ignore changes

dxConfig is used for additional transformations of the json file like ignoring changes, for instructions on how to use this setting, go to our documentation

let result = await deltajson.compare('fileA.json','fileB.json',{"dxConfig":"[path/to/dxconfig.json]" or 
"dxConfig":"{ \"dxConfig\" : [{ \"ignoreChanges\" : \"delete\",\"key\" : \"hobbies\" }]}"});
deltajson compare fileA.json fileB.json result.json dxConfig=""