# deep-compare-json

> Compare JSON files, create new file from default file, update keys in JSON

Latest version **1.1.1** (published 2019-01-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install deep-compare-json
pnpm add deep-compare-json
yarn add deep-compare-json
bun add deep-compare-json
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2019-01-01 |
| First published | 2018-11-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 18.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Mohan Singh |
| Maintainers | singhmohancs |
| Keywords | compare json files, compare directory, deep compare json files, add missing key in json  |

## Links

- npm: https://www.npmjs.com/package/deep-compare-json
- Repository: https://github.com/singhmohancs/deep-compare
- Homepage: https://github.com/singhmohancs/deep-compare#readme
- Issues: https://github.com/singhmohancs/deep-compare/issues
- npm.io page: https://npm.io/package/deep-compare-json

## Dependencies (2)

- [chalk](https://npm.io/package/chalk.md) ^2.4.1
- [lodash](https://npm.io/package/lodash.md) ^4.17.11

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.1.1 (latest) — 2019-01-01
- 1.1.0 — 2018-12-26
- 1.0.9 — 2018-12-26
- 1.0.8 — 2018-12-07
- 1.0.7 — 2018-12-07
- 1.0.6 — 2018-12-07
- 1.0.5 — 2018-12-07
- 1.0.4 — 2018-12-07
- 1.0.3 — 2018-12-07
- 1.0.2 — 2018-12-07
- 1.0.1 — 2018-11-29
- 1.0.0 — 2018-11-29

## README

# deep-compare
- Checks if file exists
- Add if key is missing

### Use-case

There is a directory `files` that contains `directories` that has `json` files.

* `files`
  * `en`
    * `a.json`
    * `b.json`
    * `c.json`
  * `nl`  
    * `c.json`  

 Find missing files and keys in `nl` directory.

 ### Example 

Import dependency
```
const deepCompare = require('deep-compare-json');
```

```javascript
const basePath = './files';
const filesDirs = ['en', 'nl'];


deepCompare.directory({
  basePath: basePath,
  compareWith: filesDirs,
  createUpdate: false,
  defaultDir: 'en',
  key_placeholder: 'demo_key'
}).then(response => {
  console.log(response);
});
```

### Result

```json
{ nl:
   [ 
     { file: a.json',
       missing_keys:
        'Error: ENOENT: no such file or directory, open \'./files/nl/a.json\'' 
    },
     { file: 'b.json',
       missing_keys:
        'Error: ENOENT: no such file or directory, open \'./files/nl/b.json\'' 
    },
     { file: 'c.json',
       missing_keys: 'form.fields.name.errors.min1Len' 
      } 
  ] 
}
```

#### Settings
Name  | Type | Description
------------- | -------------- | -------------
`basePath` | `string` | `required` base path of directory. See example 
`compareWith` | `array` | `required` An array of directory's name inside `basePath`
`defaultDir` | `string` | `optional` Directory and files are compared against this directory.
`createUpdate` | `boolean` | `optional` Default: `false` if set to `true` then missing key and files are created. 
`key_placeholder` | `string` | `optional` Default: `missing_key`. A placeholder value of missing key.
`debugLog` | `boolean` | `optional` Default : `false`. If set to `true` then shows log

---
_Source: https://npm.io/package/deep-compare-json · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
