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

To help you get started, we’ve selected a few deep-object-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 wxajs / wxa / packages / wxa-core / src / diff / diff.js View on Github external
if (this == null || this.data == null) {
        console.warn('请绑定diff函数到Page/Component实例!');
        return false;
    };

    // filter data without __webviewId__ from this.data
    let oldData = Object.keys(newData).reduce((prev, key)=>{
        if (key === '__webviewId__') return prev;

        if (this.data.hasOwnProperty(key)) {
            prev[key] = this.data[key];
        };
        return prev;
    }, {});

    let diffValue = diff(oldData, newData);

    return flatten(oldData, newData, diffValue);
}
github GetStream / Winds / api / src / utils / upsert.js View on Github external
export function normalizedDiff(existingPost, newPost) {
	let existingObject = normalizePost(existingPost);
	let newObject = normalizePost(newPost);
	// handle the fact that images are updated via OG scraping, so we only care if more became available
	newObject.images = Object.assign(existingObject.images, newObject.images);
	let objectDiff = diff(existingObject, newObject);
	// remove the immutable fields from the diff
	for (let f of immutableFields) {
		delete objectDiff[f];
	}
	return Object.keys(objectDiff);
}
github yurafuca / nicosapo / src / javascripts / modules / Bucket.ts View on Github external
private static difference(prev: object | null, next: object) {
        if (prev != null) {
            const difference = diff(prev, next);
            if (!Bucket.isEmpty(difference)) {
                console.log(difference)
            }
        } else {
            console.info(next);
        }
    }
github aholachek / redux-usage-report / src / generateReduxReport.js View on Github external
generate() {
      global.reduxReport.__inProgress = true
      const used = JSON.parse(JSON.stringify(this.accessedState))
      const stateCopy = JSON.parse(JSON.stringify(this.state))
      const unused = diff(stateCopy, used)
      replaceUndefinedWithNull(unused)
      const report = {
        used,
        unused,
        stateCopy
      }
      global.reduxReport.__inProgress = false
      return report
    }
  }
github mutantcornholio / veendor / src / lib / install / index.ts View on Github external
async function installDiff(oldPkgJson: PkgJson, newPkgJson: PkgJson): Promise {
    const logger = getLogger();
    const allDepsOld = Object.assign({}, oldPkgJson.devDependencies, oldPkgJson.dependencies);
    const allDepsNew = Object.assign({}, newPkgJson.devDependencies, newPkgJson.dependencies);
    const depsDiff = objectDiff.diff(allDepsOld, allDepsNew);
    const depsToInstall = _.omitBy(depsDiff, _.isUndefined);
    const depsToUninstall = _.keys(_.pickBy(depsDiff, _.isUndefined));

    const loggingDepsToInstall = 'Installing dependencies: ' +
        Object.keys(depsToInstall).map(pkg => `${pkg}@${depsToInstall[pkg]}`).join(' ');

    const loggingDepsToUninstall = 'Uninstalling dependencies: ' + depsToUninstall.join(' ');

    if (_.keys(depsToInstall).length) {
        logger.info(loggingDepsToInstall);

        await npmWrapper.install(depsToInstall);
    }

    if (depsToUninstall.length) {
        logger.info(loggingDepsToUninstall);
github mutantcornholio / veendor / lib / install / index.js View on Github external
return new Promise((resolve, reject) => {
        const logger = getLogger();
        const allDepsOld = Object.assign({}, oldPkgJson.devDependencies, oldPkgJson.dependencies);
        const allDepsNew = Object.assign({}, newPkgJson.devDependencies, newPkgJson.dependencies);
        const depsDiff = objectDiff.diff(allDepsOld, allDepsNew);
        const depsToInstall = _.omitBy(depsDiff, _.isUndefined);
        const depsToUninstall = _.keys(_.pickBy(depsDiff, _.isUndefined));

        const loggingDepsToInstall = 'Installing dependencies: ' +
            Object.keys(depsToInstall).map(pkg => `${pkg}@${depsToInstall[pkg]}`).join(' ');

        const loggingDepsToUninstall = 'Uninstalling dependencies: ' + depsToUninstall.join(' ');

        if (_.keys(depsToInstall).length) {
            logger.info(loggingDepsToInstall);

            return npmWrapper.install(depsToInstall)
                .then(() => {
                    if (depsToUninstall.length) {
                        logger.info(loggingDepsToUninstall);
                        return npmWrapper.uninstall(depsToUninstall).then(resolve, reject);
github leptojs / lepto / src / runner.js View on Github external
onGUIConfigUpdate(configOutput) {
    const normalizedConfig = this.normalizeConfig(configOutput);
    const configDiff = deepDiff.diff(normalizedConfig, this.config);

    if (Object.keys(configDiff).length) {
      const newConfigSet = this.setConfig(configOutput);

      if (newConfigSet.success) {
        this.processAll();
        const jsonStr = JSON.stringify(configOutput, null, 2);

        fse.outputFile(this.configFile, jsonStr, err => {
          this.configFileWritten = true;

          if (err) {
            gui.updateFinish();
            this.eventsHandler.dispatch(
              'error',
              'Unable to save config file from GUI update'

deep-object-diff

Deep diffs two objects, including nested structures of arrays and objects, and return the difference.

MIT
Latest version published 1 year ago

Package Health Score

67 / 100
Full package analysis