Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@threads/json-patch-ot

Package Overview
Dependencies
Maintainers
15
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@threads/json-patch-ot - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

8

CHANGELOG.md

@@ -0,1 +1,9 @@

## [1.0.1](https://github.com/ThreadsStyling/json-patch-ot/compare/v1.0.0...v1.0.1) (2019-06-28)
### Bug Fixes
* move bugs fixed and tests reordered ([8c89a21](https://github.com/ThreadsStyling/json-patch-ot/commit/8c89a21))
* resolve move and add issues with replace ([54f22d2](https://github.com/ThreadsStyling/json-patch-ot/commit/54f22d2))
# 1.0.0 (2018-07-19)

@@ -2,0 +10,0 @@

12

lib/index.js

@@ -62,10 +62,10 @@ "use strict";

const addTransformer = (acceptedOp, proposedOps, options) => {
shiftIndices(acceptedOp, proposedOps, true);
removeOperations(acceptedOp, proposedOps, options);
shiftIndices(acceptedOp, proposedOps, true);
};
const moveTransformer = (acceptedOp, proposedOps, options) => {
removeOperations(acceptedOp, proposedOps, { acceptedWinsOnEqualPath: true }, true, 'from');
shiftIndices(acceptedOp, proposedOps, false, 'from');
shiftIndices(acceptedOp, proposedOps, true, 'path');
removeOperations(acceptedOp, proposedOps, options, false, 'path');
shiftIndices(acceptedOp, proposedOps, true, 'path');
shiftIndices(acceptedOp, proposedOps, false, 'from');
};

@@ -79,3 +79,3 @@ const transformAgainst = {

};
const reduceJSONPatches = (proposedOps, acceptedOp, options) => {
const reduceJSONPatches = (options) => (proposedOps, acceptedOp) => {
const transformFunc = transformAgainst[acceptedOp.op];

@@ -88,7 +88,5 @@ if (transformFunc)

const clonedProposed = JSON.parse(JSON.stringify(proposedOps));
return acceptedOps.reduce((proposedOps, acceptedOp) => {
return reduceJSONPatches(proposedOps, acceptedOp, options);
}, clonedProposed);
return acceptedOps.reduce(reduceJSONPatches(options), clonedProposed);
}
exports.default = JSONPatchOT;
//# sourceMappingURL=index.js.map
{
"name": "@threads/json-patch-ot",
"version": "1.0.0",
"version": "1.0.1",
"description": "Library to reconcile JSON patch changes using Operational Transformation",

@@ -54,3 +54,4 @@ "main": "lib/index.js",

"@types/node": "^10.5.2",
"ci-scripts": "^0.10.0",
"commit-status": "^4.3.0",
"cross-ci": "^1.4.0",
"husky": "^0.14.3",

@@ -57,0 +58,0 @@ "jest": "^23.3.0",

@@ -39,2 +39,25 @@ # json-patch-ot

```
## Options
> `acceptedWinsOnEqualPath`
For some operation types, the default behaviour is to overwrite if the proposed change has the same path as an accepted change. For example, below, without the option passed, the second replace in the proposedOps would not be remove. This is useful if you want proposed changes only to be able to change a path if they knew the value it had before. Note: `remove` ops in accepted changes always cause proposed operations with the same path to be deleted.
```js
const options = {acceptedWinsOnEqualPath: true};
const acceptedOps: Operation[] = [
{op: OpType.replace, path: '/toreplace', value: 'new val'}
];
const proposedOps: Operation[] = [
{op: OpType.replace, path: '/some/other', value: 3},
{op: OpType.replace, path: '/toreplace', value: 'something else'},
];
const result = JSONPatchOT(acceptedOps, proposedOps, options); // options passed here
// result = [
// {op: OpType.replace, path: '/some/other', value: 3},
// // {op: OpType.replace, path: '/toreplace', value: 'something else'}, <- removed
// ]
```
<!-- prettier-ignore-end -->

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc