mooorph

0.0.0 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i mooorph

Weekly Downloads

0

Version

0.0.0

License

ISC

Last publish

Collaborators

  • florianbellazouz