mooorph
v0.0.0
Published
An agnostic tree morpher
Downloads
2
Readme
Mooorph
An agnostic tree morpher
Basic Usage
const Morph = require('mooorph')
const a = {
name:'world',
children:[
{name:'hero',x:100,y:100,},
{name:'coin',x:20,y:30,},
]
}
const b = {
name:'world',
children:[
{name:'hero',x:100,y:100,},
{name:'coin',x:20,y:30,},
{name:'coin',x:20,y:30,},
{name:'dog',x:20,y:50,},
]
}
Morph(a,b) // a deep equal b && a === Morph(a,b)
API
Morph :: (oldTree, newTree, options={}) => oldTree:Tree
options.childrenKey = 'children' options.isSame = (oldNode, newNode)=>boolean options.morph = (oldNode, newNode, oldParent, index)=>undefined options.remove = (oldNode, newNode, oldParent, index)=>undefined options.create = (oldNode, newNode, oldParent, index)=>undefined options.replace = (oldNode, newNode, oldParent, index)=>undefined