How to use the deep-diff.DeepDiff function in deep-diff

To help you get started, we’ve selected a few deep-diff examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ngneat / transloco / projects / ngneat / transloco-keys-manager / keysDetective.js View on Github external
_prodMode = _prodMode || prodMode;
  logger = getLogger(_prodMode);
  logger.startSpinner(`${messages.checkMissing} ✨`);
  const result = {};
  /** An array of the existing translation files in the i18n dir */
  const currentFiles = translationFiles || verifyTranslationsDir(i18nPath);
  if (!currentFiles) return;
  for (const fileName of currentFiles) {
    /** extract the lang name from the file */
    const { scope, fileLang } = regexs.fileLang(i18nPath).exec(fileName).groups;
    const extracted = scope ? keys[scope.slice(0, -1)] : keys.__global;
    if (!extracted) continue;
    /** Read the current file */
    const file = readFile(fileName);
    const fileObj = JSON.parse(file);
    const diffArr = DeepDiff(fileObj, extracted);
    if (diffArr) {
      const lang = `${scope || ''}${fileLang}`;
      result[lang] = {
        missing: [],
        extra: []
      };
      for (const diff of diffArr) {
        if (diff.kind === 'N') {
          result[lang].missing.push(diff);
          if (addMissing) {
            applyChange(fileObj, extracted, diff);
          }
        } else if (!_prodMode && diff.kind === 'D') {
          result[lang].extra.push(diff);
        }
      }

deep-diff

Javascript utility for calculating deep difference, capturing changes, and applying changes across objects; for nodejs and the browser.

MIT
Latest version published 6 years ago

Package Health Score

73 / 100
Full package analysis