|
2 | 2 | import { format, inherits } from 'util' |
3 | 3 | import { EventEmitter } from 'events' |
4 | 4 | import { parseMessage, parseVersionMessage, change as change_util } from './util' |
5 | | -import JSONDiff from './jsondiff' |
6 | 5 | import { v4 as uuid } from 'uuid' |
7 | 6 |
|
8 | | -const jsondiff = new JSONDiff( {list_diff: false} ); |
9 | | - |
10 | 7 | const UNKNOWN_CV = '?'; |
11 | 8 | const CODE_INVALID_VERSION = 405; |
12 | 9 | const CODE_EMPTY_RESPONSE = 412; |
@@ -128,7 +125,7 @@ internal.updateObjectVersion = function( id, version, data, original, patch, ack |
128 | 125 | // apply the transformed patch and emit the update |
129 | 126 | if ( transformed ) { |
130 | 127 | patch = transformed; |
131 | | - update = jsondiff.apply_object_diff( data, transformed ); |
| 128 | + update = change_util.apply( transformed, data ); |
132 | 129 | // queue up the new change |
133 | 130 | change = change_util.modify( id, version, patch ); |
134 | 131 | this.localQueue.queue( change ); |
@@ -218,7 +215,7 @@ internal.applyChange = function( change, ghost ) { |
218 | 215 |
|
219 | 216 | original = ghost.data; |
220 | 217 | patch = change.v; |
221 | | - modified = jsondiff.apply_object_diff( original, patch ); |
| 218 | + modified = change_util.apply( patch, original ); |
222 | 219 | return internal.updateObjectVersion.call( this, change.id, change.ev, modified, original, patch, acknowledged ) |
223 | 220 | .then( updateChangeVersion ); |
224 | 221 | } else if ( change.o === operation.REMOVE ) { |
@@ -842,7 +839,7 @@ LocalQueue.prototype.compressAndSend = function( id, ghost ) { |
842 | 839 | break; |
843 | 840 | } |
844 | 841 |
|
845 | | - target = jsondiff.apply_object_diff( target, c.v ); |
| 842 | + target = change_util.apply( c.v, target ); |
846 | 843 | } |
847 | 844 |
|
848 | 845 | type = target === null ? change_util.type.REMOVE : change_util.type.MODIFY; |
|
0 commit comments