How to use the sp2.normalizeUpdateOperation function in sp2

To help you get started, we’ve selected a few sp2 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 phenyl / phenyl / modules / central-state / src / versioning.ts View on Github external
>(command: T): T {
    const normalizedOperation = normalizeUpdateOperation(command.operation);
    const version = {
      id: timeStampWithRandomString(),
      op: JSON.stringify(command.operation)
    };
    const $push = Object.assign({}, normalizedOperation.$push, {
      "_PhenylMeta.versions": { $each: [version], $slice: -100 }
    });
    const newOperation = Object.assign({}, normalizedOperation, { $push });
    return Object.assign({}, command, { operation: newOperation });
  }