How to use the fast-json-patch.deepClone function in fast-json-patch

To help you get started, we’ve selected a few fast-json-patch 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 dav-m85 / babpi / src / server / archiveReducer.js View on Github external
function updatePlayers (nplayers, game) {
  // lets deep copy players
  let players = jsonpatch.deepClone(nplayers)

  // Add missing player if not in players list
  game.redPlayers.concat(game.bluePlayers).forEach(p => {
    if (players.filter(fp => fp.name === p).length === 0) {
      players.push({
        name: p,
        scored: 0,
        gameCount: 0,
        winCount: 0,
        // trueskill default parameters
        mu: 25.000,
        sigma: 8.333
      })
    }
  })
github dav-m85 / babpi / src / remoteStateSocket.js View on Github external
socket.on('diff-state', (patch) => {
      let state = jsonpatch.deepClone(this.state)
      jsonpatch.applyPatch(state, jsonpatch.deepClone(patch))
      this.setState(state)
      console.log('STATE', state)
    })
  }
github dav-m85 / babpi / src / remoteStateSocket.js View on Github external
socket.on('diff-state', (patch) => {
      let state = jsonpatch.deepClone(this.state)
      jsonpatch.applyPatch(state, jsonpatch.deepClone(patch))
      this.setState(state)
      console.log('STATE', state)
    })
  }
github DSpace / dspace-angular / src / app / core / submission / submission-response-parsing.service.ts View on Github external
parse(request: RestRequest, data: DSpaceRESTV2Response): RestResponse {
    this.dsoParser.parse(deepClone(request), deepClone(data));
    if (isNotEmpty(data.payload)
      && isNotEmpty(data.payload._links)
      && this.isSuccessStatus(data.statusCode)) {
      const dataDefinition = this.processResponse(data.payload, request);
      return new SubmissionSuccessResponse(dataDefinition, data.statusCode, data.statusText, this.processPageInfo(data.payload));
    } else if (isEmpty(data.payload) && this.isSuccessStatus(data.statusCode)) {
      return new SubmissionSuccessResponse(null, data.statusCode, data.statusText);
    } else {
      return new ErrorResponse(
        Object.assign(
          new Error('Unexpected response from server'),
          {statusCode: data.statusCode, statusText: data.statusText}
        )
      );
    }
  }
github Heigvd / Wegas / wegas-app / src / main / webapp / 2 / src / Editor / Components / Page / PageEditor.tsx View on Github external
(path: string[]) => {
      const browsePath = [...path];
      const newPage = deepClone(selectedPage);
      let parent: WegasComponent | undefined = undefined;
      let component: WegasComponent = newPage;
      while (browsePath.length > 0) {
        if (component.props.children) {
          parent = component;
          component = component.props.children[Number(browsePath[0])];
          browsePath.splice(0, 1);
        } else {
          return { newPage };
        }
      }
      return { newPage, component, parent };
    },
    [selectedPage],
github D1plo1d / graphql-live-subscriptions / src / queryExecutors / FullQueryExecutor.js View on Github external
recordPatch: async patch => {
      const patchResults = jsonPatch.applyPatch(
        previousState,
        jsonPatch.deepClone(patch)
      )
    },
  }
github Azure-Samples / digital-twins-explorer / client / src / components / PropertyInspectorComponent / PropertyInspectorComponent.js View on Github external
eventService.subscribeSelection(async selection => {
      let properties = null;
      try {
        properties = selection ? await new ModelService().getProperties(selection.$metadata.$model) : null;
      } catch (exc) {
        print(`*** Error fetching twin properties: ${exc}`, "error");
      }

      this.properties = properties;
      this.original = this.updated = selection ? await applyDefaultValues(properties, deepClone(selection)) : null;
      this.setState({ changed: false, selection, patch: null });
      if (selection) {
        this.editor.set(this.original);
      }
    });
  }
github Heigvd / Wegas / wegas-app / src / main / webapp / 2 / src / Editor / Components / Page / PageEditor.tsx View on Github external
(path: string[]) => {
      const newPage: Page = deepClone(selectedPage);
      let parent: WegasComponent = newPage;
      const browsePath = [...path];
      while (browsePath.length > 0) {
        if (parent.props.children) {
          if (browsePath.length == 1) {
            parent.props.children.splice(Number(browsePath[0]), 1);
            patchPage(pagesState.selectedPage, newPage);
            return;
          }
          parent = parent.props.children[Number(browsePath[0])];
        }
        browsePath.splice(0, 1);
      }
    },
    [selectedPage, pagesState.selectedPage, patchPage],