diff --git a/README.md b/README.md index 1e1d2a8..dc9fc81 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ XXX - Full JSON *diff* support - Support for JavaScript objects without restrictions - *Text diff* support +- ~~Optional attribute order support~~ (not done yet) - Configurable and extensible implementation - As simple as possible @@ -132,7 +133,7 @@ Shorter strings or strings containing just a single line are treated as *basic* // // NOTE: a string must also contain at least one \n to be text // diffed... - min_text_length: 1000 | -1, + min_text_length: 100 | -1, // If true, disable attribute diff for non Object's... // @@ -267,7 +268,7 @@ ExtendedDiff.types.set('SomeType', { // .check(obj[, options]) // -> bool // - check: function(obj, options){ + compatible: function(obj, options){ // ... }, diff --git a/diff.js b/diff.js index bc3dbca..a3896ea 100644 --- a/diff.js +++ b/diff.js @@ -697,8 +697,8 @@ module.Types = { // explicit checkers have priority over instance tests... for(var t of types){ var h = this.get(t) - if(h.check - && h.check(A, options)){ + if(h.compatible + && h.compatible(A, options)){ type = t break } @@ -1005,8 +1005,13 @@ module.Types = { // Check if diff is applicable to obj... // + // XXX should this return a diff??? + // XXX need a custom check for custom handler... + // ...we also have a name clash whit .check(..) that checks if + // the object type is compatible to handler... + // XXX EXPERIMENTAL... check: function(diff, obj, options){ - // XXX + // XXX try and use .walk(..) + custom handlers for custom types... }, } @@ -1049,10 +1054,10 @@ module.Types = { // // // Check if obj is compatible (optional)... // // -// // .check(obj[, options]) +// // .compatible(obj[, options]) // // -> bool // // -// check: function(obj, options){ +// compatible: function(obj, options){ // .. // }, // @@ -1146,7 +1151,7 @@ Types.set('Basic', { priority: 50, no_attributes: true, - check: function(obj, options){ + compatible: function(obj, options){ return typeof(obj) != 'object' }, handle: function(obj, diff, A, B, options){ ;(!options.keep_none && A === NONE) @@ -1485,7 +1490,7 @@ Types.set('Text', { priority: 100, no_attributes: true, - check: function(obj, options){ + compatible: function(obj, options){ options = options || {} min = options.min_text_length || MIN_TEXT_LENGTH return typeof(obj) == typeof('str') @@ -1659,7 +1664,7 @@ Types.set(LogicType, { // // // add a new synthetic type... // ExtendedDiff.types.set('SomeOtherType', { -// check: function(..){ .. }, +// compatible: function(..){ .. }, // ... // }) //