@dabble/patches 0.4.1 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { Delta } from '@dabble/delta';
|
|
2
2
|
export * from './client/index.js';
|
|
3
3
|
export * from './event-signal.js';
|
|
4
|
-
export
|
|
4
|
+
export { createPathProxy } from './json-patch/index.js';
|
|
5
5
|
export type { ApplyJSONPatchOptions } from './json-patch/types.js';
|
|
6
6
|
export type * from './types.js';
|
package/dist/index.js
CHANGED
|
@@ -75,11 +75,7 @@ export declare class JSONPatch {
|
|
|
75
75
|
*/
|
|
76
76
|
addUpdates(updates: {
|
|
77
77
|
[key: string]: any;
|
|
78
|
-
}, path?:
|
|
79
|
-
/**
|
|
80
|
-
* This will ensure an "add empty object" operation is created for each property along the path that does not exist.
|
|
81
|
-
*/
|
|
82
|
-
addObjectsInPath(obj: any, path: PathLike): this;
|
|
78
|
+
}, path?: PathLike): this;
|
|
83
79
|
/**
|
|
84
80
|
* Apply this patch to an object, returning a new object with the applied changes (or the same object if nothing
|
|
85
81
|
* changed in the patch). Optionally apply the page at the given path prefix.
|
|
@@ -122,6 +122,7 @@ export class JSONPatch {
|
|
|
122
122
|
* Creates a patch from an object partial, updating each field. Set a field to undefined to delete it.
|
|
123
123
|
*/
|
|
124
124
|
addUpdates(updates, path = '/') {
|
|
125
|
+
path = checkPath(path);
|
|
125
126
|
if (path[path.length - 1] !== '/')
|
|
126
127
|
path += '/';
|
|
127
128
|
Object.keys(updates).forEach(key => {
|
|
@@ -135,21 +136,6 @@ export class JSONPatch {
|
|
|
135
136
|
});
|
|
136
137
|
return this;
|
|
137
138
|
}
|
|
138
|
-
/**
|
|
139
|
-
* This will ensure an "add empty object" operation is created for each property along the path that does not exist.
|
|
140
|
-
*/
|
|
141
|
-
addObjectsInPath(obj, path) {
|
|
142
|
-
path = checkPath(path);
|
|
143
|
-
const parts = path.split('/');
|
|
144
|
-
for (let i = 1; i < parts.length - 1; i++) {
|
|
145
|
-
const prop = parts[i];
|
|
146
|
-
if (!obj || !obj[prop]) {
|
|
147
|
-
this.add(parts.slice(0, i + 1).join('/'), {});
|
|
148
|
-
}
|
|
149
|
-
obj = obj && obj[prop];
|
|
150
|
-
}
|
|
151
|
-
return this;
|
|
152
|
-
}
|
|
153
139
|
/**
|
|
154
140
|
* Apply this patch to an object, returning a new object with the applied changes (or the same object if nothing
|
|
155
141
|
* changed in the patch). Optionally apply the page at the given path prefix.
|
|
@@ -3,6 +3,7 @@ export { composePatch } from './composePatch.js';
|
|
|
3
3
|
export { invertPatch } from './invertPatch.js';
|
|
4
4
|
export { applyBitmask, bitmask, combineBitmasks } from './ops/bitmask.js';
|
|
5
5
|
export * as defaultOps from './ops/index.js';
|
|
6
|
+
export * from './pathProxy.js';
|
|
6
7
|
export { transformPatch } from './transformPatch.js';
|
|
7
8
|
export * from './JSONPatch.js';
|
|
8
9
|
export * from './ops/index.js';
|
package/dist/json-patch/index.js
CHANGED
|
@@ -3,6 +3,7 @@ export { composePatch } from './composePatch.js';
|
|
|
3
3
|
export { invertPatch } from './invertPatch.js';
|
|
4
4
|
export { applyBitmask, bitmask, combineBitmasks } from './ops/bitmask.js';
|
|
5
5
|
export * as defaultOps from './ops/index.js';
|
|
6
|
+
export * from './pathProxy.js';
|
|
6
7
|
export { transformPatch } from './transformPatch.js';
|
|
7
8
|
export * from './JSONPatch.js';
|
|
8
9
|
export * from './ops/index.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dabble/patches",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"description": "Immutable JSON Patch implementation based on RFC 6902 supporting operational transformation and last-writer-wins",
|
|
5
5
|
"author": "Jacob Wright <jacwright@gmail.com>",
|
|
6
6
|
"bugs": {
|