
Security News
NVD Quietly Sweeps 100K+ CVEs Into a “Deferred” Black Hole
NVD now marks all pre-2018 CVEs as "Deferred," signaling it will no longer enrich older vulnerabilities, further eroding trust in its data.
@threads/json-patch-ot
Advanced tools
Library to reconcile JSON patch changes using Operational Transformation
Library to reconcile JSON patch changes using Operational Transformation
You must pass the function a list of JSON patches that you want to transform against. These should be your accepted changes that are already accepted by the server, but were not known about at the creation of the second argument, the proposed changes.
Finally you can pass an options object which currently only supports one option. The acceptedWinsOnEqualPath
option will decide if new replace
operations should override an accepted replace
that was made to the exact same path
.
// [0, 1, 2, 3, 4, 5, 6]; <- Starting array
const acceptedOps: Operation[] = [
{op: OpType.remove, path: '/array/1'},
{op: OpType.add, path: '/array/3', value: 30},
];
// [0, 2, 3, 30, 4, 5, 6]; <- Array after accepted add and remove
// Actions to double some specific values
const proposedOps: Operation[] = [
{op: OpType.replace, path: '/array/2', value: 4}, // 2 -> 4
{op: OpType.replace, path: '/array/1', value: 2}, // 1 -> 2
{op: OpType.replace, path: '/array/5', value: 10}, // 5 -> 10
];
const result = JSONPatchOT(acceptedOps, proposedOps);
// result === [
// {op: OpType.replace, path: '/array/1', value: 4}, <- index changed
// // {op: OpType.replace, path: '/array/1', value: 2}, <- removed
// {op: OpType.replace, path: '/array/5', value: 10}, <- unchanged
// ]
// [0, 4, 3, 30, 4, 10, 6]; <- Array after transformed proposed changes
FAQs
Library to reconcile JSON patch changes using Operational Transformation
The npm package @threads/json-patch-ot receives a total of 18 weekly downloads. As such, @threads/json-patch-ot popularity was classified as not popular.
We found that @threads/json-patch-ot demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 16 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
NVD now marks all pre-2018 CVEs as "Deferred," signaling it will no longer enrich older vulnerabilities, further eroding trust in its data.
Research
Security News
Lazarus-linked threat actors expand their npm malware campaign with new RAT loaders, hex obfuscation, and over 5,600 downloads across 11 packages.
Security News
Safari 18.4 adds support for Iterator Helpers and two other TC39 JavaScript features, bringing full cross-browser coverage to key parts of the ECMAScript spec.