How to use the deep-object-diff.addedDiff 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 woleet / woleet.id-server / client / src / app / components / parts / user.form / index.ts View on Github external
if (alreadyExist) {
        if (!confirm('This seal identity already exists.\n'
          + 'Do you still want to update it?')) {
          this.formLocked = false;
          return;
        }
      }

      promise = this.service.update(this.user.id, cleaned)
        .then((up) => this.submitSucceed.emit(up));
    } else {
      user.createDefaultKey = this.createDefaultKey;
      if (this.sendPasswordEmail) {
        user.password = null;
      }
      const cleaned: any = addedDiff({}, cleanupObject(user));
      const alreadyExist = await this.checkSealIdentity(user);
      if (alreadyExist) {
        if (!confirm('This seal identity already exists.\n'
          + 'Do you still want to create it?')) {
          this.formLocked = false;
          return;
        }
      }

      promise = this.service.create(cleaned)
        .then((up) => {
          if (this.sendPasswordEmail) {
            try {
              this.sendResetPasswordEmail(up);
            } catch (err) {
              log.debug(err);
github Yoctol / bottender / packages / bottender / src / cli / providers / messenger / profile.ts View on Github external
print(`Successfully set ${bold('messenger_profile')} settings`);
    } else {
      const [_existedProfile] = await client.getMessengerProfile(FIELDS);

      const profile = trimDomain(_profile);
      const existedProfile = trimDomain(_existedProfile);

      const diffResult = diff(existedProfile, profile);

      if (Object.keys(diffResult).length !== 0) {
        const shouldDeleteFields = Object.keys(
          deletedDiff(existedProfile, profile)
        );

        const shouldSetFields = [
          ...Object.keys(addedDiff(existedProfile, profile)),
          ...Object.keys(updatedDiff(existedProfile, profile)),
        ];

        if (shouldDeleteFields.length > 0) {
          await client.deleteMessengerProfile(
            shouldDeleteFields.map(field => snakecase(field))
          );
          const deleteFileds = shouldDeleteFields.join(', ');
          print(`Successfully delete ${bold(deleteFileds)} settings`);
        }

        if (shouldSetFields.length > 0) {
          const shouldSetProfile = pick(profile, shouldSetFields);

          if (shouldSetFields.includes('whitelistedDomains')) {
            await client.setMessengerProfile(
github Yoctol / bottender / packages / bottender / src / viber / ViberConnector.ts View on Github external
case 'unsubscribed':
      case 'delivered':
      case 'seen':
      case 'failed':
        user = {
          id: body.userId,
        };
        break;
      case 'message':
        user = body.sender;
        break;
      default:
        break;
    }

    if (Object.keys(addedDiff(session.user || {}, user as any)).length > 0) {
      session.user = {
        ...session.user,
        ...user,
      };
      session.user._updatedAt = new Date().toISOString();
    }

    Object.freeze(session.user);
    Object.defineProperty(session, 'user', {
      configurable: false,
      enumerable: true,
      writable: false,
      value: session.user,
    });
  }

deep-object-diff

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

MIT
Latest version published 2 years ago

Package Health Score

67 / 100
Full package analysis