tree-each
forEach for trees
Getting Started
$ {package mananger} install jkroso/tree-each
then in your app:
var treach =
API
depth(path:String, node:Object, fn:Function, [context]:Any)
iterate a tree breadth first along path
from node
breadth(path:String, node:Object, fn:Function, [context]:Any)
iterate a tree depth first along path
from node
up(path:String, node:Object, fn:Function, [context]:Any)
walk up path
from node
example
each can be used to define other higher order functions that operate over trees. Here we define filter
and use it to emulate document.body.querySelectorAll
. Note the use of currying to keep noise to a minimum inside filter
. All functions in this package have been made curryable.
var each = { var res = return res} // => [ Element ]
Running the tests
Just run make
. It will install and start a development server. Then just point your browser to localhost:3000/test
. Likewise to run the examples.