How to use the deep-object-diff.detailedDiff 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 amejia1 / atom-xterm / src / lib / atom-xterm-profiles.js View on Github external
diffProfiles (oldProfile, newProfile) {
    // This method will return added or modified entries.
    let diff = detailedDiff(oldProfile, newProfile)
    return Object.assign(diff.added, diff.updated)
  }
github fabiospampinato / overstated / src / debug.ts View on Github external
store.subscribe ( () => {

        const date = new Date (),
              timestamp = `[${padLeft ( date.getHours (), 2, 0 )}:${padLeft ( date.getMinutes (), 2, 0 )}:${padLeft ( date.getSeconds (), 2, 0 )}.${padLeft ( date.getMilliseconds (), 3, 0 )}]`;

        group ( `${name} ${timestamp}` );

        const {state} = store;

        if ( options.logStateDiffChanges ) {

          const {detailedDiff} = require ( 'deep-object-diff' ),
                {added, updated, deleted} = detailedDiff ( prevState, state ) as any; //TSC

          if ( !isEmptyObject ( added ) ) {
            console.log ( 'Added\n ', added );
          }

          if ( !isEmptyObject ( updated ) ) {
            console.log ( 'Updated\n ', updated );
          }

          if ( !isEmptyObject ( deleted ) ) {
            console.log ( 'Deleted\n ', deleted );
          }

        }

        if ( options.logStateFullChanges && !areShallowEqual ( state, prevState ) ) {
github ice-lab / icestore / middlewares / logger / src / index.ts View on Github external
export default async (ctx, next) => {
  const { namespace, getState } = ctx.store;
  const { name: actionName } = ctx.action;
  const preState = clone(getState());

  const value = await next();

  const state = clone(getState());
  const diff: any  = detailedDiff(preState, state);
  const hasChanges = obj => Object.keys(obj).length > 0;

  console.group('Store Name: ', namespace);
  console.log('Action Name: ', actionName);

  if (hasChanges(diff.added)) {
    console.log('Added\n', diff.added);
  }

  if (hasChanges(diff.updated)) {
    console.log('Updated\n', diff.updated);
  }

  if (hasChanges(diff.deleted)) {
    console.log('Deleted\n', diff.deleted);
  }
github sindresorhus / unstated-debug / index.js View on Github external
container.subscribe(() => {
		if (!(UNSTATED.isEnabled && UNSTATED.logStateChanges)) {
			return;
		}

		const {state} = container;
		const diff = detailedDiff(prevState, state);

		const group = UNSTATED.isCollapsed ? console.groupCollapsed : console.group;
		group(name);

		const hasChanges = obj => Object.keys(obj).length > 0;

		if (hasChanges(diff.added)) {
			console.log('Added\n', diff.added);
		}

		if (hasChanges(diff.updated)) {
			console.log('Updated\n', diff.updated);
		}

		if (hasChanges(diff.deleted)) {
			console.log('Deleted\n', diff.deleted);
github FormidableLabs / spectacle / src / components / magic-wrapper.js View on Github external
() => {
          const styles = {};
          const portalRoot = get(this.portal, 'childNodes[0].childNodes[0]');
          if (portalRoot) {
            updateChildren(portalRoot);
            buildStyleMap(styles, portalRoot);
            this.diffs = detailedDiff(this.portalMap, styles);
            this.lastPortalMap = this.portalMap;
            this.portalMap = styles;
            if (this.mounted) {
              this.setState(
                {
                  renderedChildren: this.props.children
                },
                () => {
                  this.forceUpdate();
                }
              );
            }
          }
        }
      );

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