Skip to content

A difference calculator is a program that determines the difference between two data structures.

Notifications You must be signed in to change notification settings

chickenzombie/Difference-calculator

Repository files navigation

Program status

Hexlet tests:

Actions Status

Tests (Jest) and linter (ESLint) status:

CI check

Maintainability and test coverage (both using Codeclimate) status:

Maintainability Test Coverage

Caluclator description

A difference calculator is a program that determines the difference between two data structures. This is a popular task for which there are many online services, such as http://www.jsondiff.com/. A similar mechanism is used when outputting tests or when automatically tracking changes in configuration files.

Features of the calculator:

  • Supports various input formats: yaml, json
  • Report generation as plain text, stylish and json

Current version: 0.0.9

To get info about program commands type:

gendiff -h or gendiff --help
Usage: gendiff [options] <filepath1> <filepath2>

Compares two configuration files and shows a difference

Options:
  -V, --version        output the version number
  -f, --format [type]  output format (default: "stylish")
  -h, --help           display help for command

Example of usage

# plain format
gendiff --format plain path/to/file.yml another/path/file.json

Property 'common.follow' was added with value: false
Property 'group1.baz' was updated. From 'bas' to 'bars'
Property 'group2' was removed

# stylish format
gendiff filepath1.json filepath2.json

{
  + follow: false
    setting1: Value 1
  - setting2: 200
  - setting3: true
  + setting3: {
        key: value
    }
  + setting4: blah blah
  + setting5: {
        key5: value5
    }
}

How to install

Make sure you have installed Node.js version 16 or higher.

  1. Clone repo:
git clone git@github.com:chickenzombie/frontend-project-46.git
  1. Change directory:
cd frontend-project-46
  1. Install packages:
make install

Example of work

1. Difference between 2 files with stylish formatter (set by default):

You can use short version of data input (more information in Makefile). 2 json files are compared by default.

make diff

or for example calculate difference between 2 yaml files:

make diff-yml

asciicast

2. Difference between 2 files with plain formatter:

make diff-plain
make diff-yml-plain

asciicast

3. Difference between 2 files with json formatter:

make diff-json
make diff-yml-json

asciicast

About

A difference calculator is a program that determines the difference between two data structures.

Resources

Stars

Watchers

Forks

Packages

No packages published