Skip to content

dominictarr/poset

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

poset

experimental poset module

Poset is an abstraction that fits neatly over trees, lists, and sets.

The goal for this module is to create a simple API that can be used to mainpulate all of the above.

included so far, is ./fs.js and ./object.js which adapt this module for operating on fs trees, and js objects.

There are many other possibilities, such as HTMLElements, git commits, and many others.

thanks to @jez0990 for introducing me to posets!

Stability

Experimental: Expect the unexpected. Please provide feedback on api and your use-case.

API

Node.ancestors()

Node.subposet (test) / filter

return a subposet of the poset that matches a property

example: tree of directories

poset(fs).filter(function (e) {return e.isDirectory()})

tree of objects

poset(obj).filter(function (e) {return e && 'object' === typeof e})

traversals

//depth first
poset(fs).depthFirst(function (item) {...})

//width first
poset(fs).widthFirst(function (item) {...})

//leaves first
poset(fs).topological(function (item) {...})

//ancestors
poset(fs).ancestors(function (item) {...})

//bottom most ancestors
poset(fs).roots(function (item) {...})

comparisons

item1.gt(item2) 
item1.decendentOf(item2)
item1.ancestorOf(item2)
item1.concestor(item2)

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published