mirror of
https://github.com/flynx/diff.js.git
synced 2025-10-29 19:10:11 +00:00
experimenting...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
465f754521
commit
1fb6c3bdd2
18
diff2.js
18
diff2.js
@ -135,7 +135,7 @@ object.Constructor('Walk', {
|
|||||||
.iter()
|
.iter()
|
||||||
.filter(function([n, h]){
|
.filter(function([n, h]){
|
||||||
return (typeof(h) == 'function' || h.list)
|
return (typeof(h) == 'function' || h.list)
|
||||||
&& !this['no' + n.capitalize()] })
|
&& !that['no' + n.capitalize()] })
|
||||||
.map(function([n, h]){
|
.map(function([n, h]){
|
||||||
var res = typeof(h) == 'function' ?
|
var res = typeof(h) == 'function' ?
|
||||||
h.call(that.listers, obj)
|
h.call(that.listers, obj)
|
||||||
@ -189,6 +189,16 @@ module.OBJECT_LISTERS = {
|
|||||||
if(obj === null){
|
if(obj === null){
|
||||||
throw module.STOP } },
|
throw module.STOP } },
|
||||||
|
|
||||||
|
/* XXX not sure if this should be here...
|
||||||
|
// XXX also this is diff-specific...
|
||||||
|
text: function(obj){
|
||||||
|
return typeof(obj) == 'string'
|
||||||
|
&& obj.includes('\n')
|
||||||
|
&& obj.split(/\n/g).entries()
|
||||||
|
.map(function([k, v]){
|
||||||
|
return [[module.CONTENT, k], v] }) },
|
||||||
|
//*/
|
||||||
|
|
||||||
set: function(obj){
|
set: function(obj){
|
||||||
return obj instanceof Set
|
return obj instanceof Set
|
||||||
&& [...obj.values()]
|
&& [...obj.values()]
|
||||||
@ -231,12 +241,16 @@ module.OBJECT_LISTERS = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// XXX add function support...
|
// XXX add function support...
|
||||||
|
// XXX would be nice to be able to extend this...
|
||||||
|
// e.g. make this a generic walker and for a diff-specific walker add
|
||||||
|
// text support...
|
||||||
var objectWalker =
|
var objectWalker =
|
||||||
module.objectWalker =
|
module.objectWalker =
|
||||||
Walk(
|
Walk(
|
||||||
function(obj, path, next, type){
|
function(obj, path, next, type){
|
||||||
// text...
|
// text...
|
||||||
// XXX should this be here or in OBJECT_LISTERS???
|
// XXX should this be here or in OBJECT_LISTERS???
|
||||||
|
// XXX also this is diff-specific...
|
||||||
if(typeof(obj) == 'string' && obj.includes('\n')){
|
if(typeof(obj) == 'string' && obj.includes('\n')){
|
||||||
next.push(['text',
|
next.push(['text',
|
||||||
obj.split(/\n/g).entries()
|
obj.split(/\n/g).entries()
|
||||||
@ -824,9 +838,7 @@ console.log(JSON.stringify(diff(
|
|||||||
|
|
||||||
console.log('---')
|
console.log('---')
|
||||||
|
|
||||||
// XXX test functions...
|
|
||||||
console.log([
|
console.log([
|
||||||
//...objectWalker(o)
|
|
||||||
...objectWalker(
|
...objectWalker(
|
||||||
`This
|
`This
|
||||||
is
|
is
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user