mirror of
https://github.com/flynx/diff.js.git
synced 2025-10-29 02:50:10 +00:00
notes...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
112ca65a1d
commit
4616e94f7e
29
diff2.js
29
diff2.js
@ -826,13 +826,11 @@ function(A, B, cmp){
|
|||||||
var keyValueDiff =
|
var keyValueDiff =
|
||||||
function(A, B, options={}){
|
function(A, B, options={}){
|
||||||
return diffSections(
|
return diffSections(
|
||||||
[...objectWalkerWithText(A)
|
[...objectWalkerWithText(A)],
|
||||||
.chain(serializePaths)],
|
[...objectWalkerWithText(B)],
|
||||||
[...objectWalkerWithText(B)
|
|
||||||
.chain(serializePaths)],
|
|
||||||
// XXX add link support...
|
// XXX add link support...
|
||||||
function([ap, av], [bp, bv]){
|
function([ap, av], [bp, bv]){
|
||||||
return ap == bp
|
return ap.cmp(bp)
|
||||||
&& (av == bv
|
&& (av == bv
|
||||||
|| (typeof(av) == 'object'
|
|| (typeof(av) == 'object'
|
||||||
&& typeof(bv) == 'object'
|
&& typeof(bv) == 'object'
|
||||||
@ -844,10 +842,8 @@ function(A, B, options={}){
|
|||||||
var valueDiff =
|
var valueDiff =
|
||||||
function(A, B, options={}){
|
function(A, B, options={}){
|
||||||
return diffSections(
|
return diffSections(
|
||||||
[...objectWalkerWithText(A)
|
[...objectWalkerWithText(A)],
|
||||||
.chain(serializePaths)],
|
[...objectWalkerWithText(B)],
|
||||||
[...objectWalkerWithText(B)
|
|
||||||
.chain(serializePaths)],
|
|
||||||
// XXX add link support...
|
// XXX add link support...
|
||||||
function([ap, av], [bp, bv]){
|
function([ap, av], [bp, bv]){
|
||||||
return av == bv
|
return av == bv
|
||||||
@ -862,6 +858,16 @@ var diff = keyValueDiff
|
|||||||
|
|
||||||
// convert diff sections into diff...
|
// convert diff sections into diff...
|
||||||
//
|
//
|
||||||
|
// XXX so this is a bit more complicated than simply converting from one
|
||||||
|
// format to another...
|
||||||
|
// we need to:
|
||||||
|
// - convert offset changes to one of:
|
||||||
|
// - insertions of empty slots
|
||||||
|
// - ???
|
||||||
|
// - ...
|
||||||
|
// XXX changes to a path should not affect the subtree...
|
||||||
|
// /a/b/.. -> /a/x/..
|
||||||
|
// not sure how and where (here or in diff(..)) to handle this yet...
|
||||||
// XXX add context lines...
|
// XXX add context lines...
|
||||||
var toDiff =
|
var toDiff =
|
||||||
module.toDiff =
|
module.toDiff =
|
||||||
@ -871,7 +877,12 @@ function*(A, B, options={}){
|
|||||||
.map(function*([ia, ca, ib, cb]){
|
.map(function*([ia, ca, ib, cb]){
|
||||||
// XXX add pre-context...
|
// XXX add pre-context...
|
||||||
// ...if changes are adjacent, then skip context...
|
// ...if changes are adjacent, then skip context...
|
||||||
|
// ...use atPath(..)
|
||||||
yield ['=']
|
yield ['=']
|
||||||
|
// XXX OFFSET: here we have to be a bit more cleaver, if an
|
||||||
|
// offset of an element changed then we need to insert
|
||||||
|
// a set of empty slots shifting the rest of the array...
|
||||||
|
// XXX convert offset to index...
|
||||||
yield* ca
|
yield* ca
|
||||||
.map(function(change){
|
.map(function(change){
|
||||||
return ['-', ...change] })
|
return ['-', ...change] })
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user