1.1.1 • Published 5 years ago

deep-compare-json v1.1.1

Weekly downloads
16
License
MIT
Repository
github
Last release
5 years ago

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');
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

{ 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

NameTypeDescription
basePathstringrequired base path of directory. See example
compareWitharrayrequired An array of directory's name inside basePath
defaultDirstringoptional Directory and files are compared against this directory.
createUpdatebooleanoptional Default: false if set to true then missing key and files are created.
key_placeholderstringoptional Default: missing_key. A placeholder value of missing key.
debugLogbooleanoptional Default : false. If set to true then shows log
1.1.1

5 years ago

1.1.0

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago