mirror of
https://github.com/flynx/diff.js.git
synced 2025-10-28 18:40:09 +00:00
experimenting with data flow through the walk...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
a9d8ab7b89
commit
e02e0fecf7
22
diff2.js
22
diff2.js
@ -13,6 +13,10 @@ var types = require('ig-types')
|
||||
|
||||
/*********************************************************************/
|
||||
|
||||
var CONTENT_ATTR =
|
||||
module.CONTENT_ATTR = '[CONTENT$]'
|
||||
|
||||
|
||||
// XXX need to deal with functions...
|
||||
var HANDLERS =
|
||||
module.HANDLERS = {
|
||||
@ -91,13 +95,25 @@ module.HANDLERS = {
|
||||
// XXX should this be more generic and just check for .entries(..) ???
|
||||
match: function(obj){
|
||||
return obj instanceof Map },
|
||||
handle: function(obj){
|
||||
handle: function(obj, path, options){
|
||||
// NOTE: we store content in a special attribute...
|
||||
var pattern = options.contentAttr || module.CONTENT_ATTR
|
||||
var i = 0
|
||||
do{
|
||||
var attr = pattern
|
||||
.replace('$', i == 0 ? '' : i)
|
||||
i++
|
||||
} while(attr in obj)
|
||||
// XXX store the attr in parent spec...
|
||||
// ...how can we get the parent spec???
|
||||
// XXX
|
||||
|
||||
return [ obj.entries()
|
||||
.map(function([k, v], i){
|
||||
return [
|
||||
// XXX not sure how to format these...
|
||||
[[i +':key'], k],
|
||||
[[i], v],
|
||||
[[attr, i +':key'], k],
|
||||
[[attr, i], v],
|
||||
] })
|
||||
.flat()
|
||||
.toArray() ] },
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user