closure-table
Closure Table on javascript
Install
npm install closure-table
Usage
; // sample node ;;;;;;; // sample tree//// n1 -+- n2 --- n4// |// +- n3 -+- n5// |// +- n6 --- n7 ; // initialize; // function examples ct.findAncestorsOfn3; // [ { id: 1 } ]ct.findAncestorsOfn3, true; // [ { id: 3 }, { id: 1 } ]ct.findDescendantsOfn3; // [ { id: 5 }, { id: 6 }, { id: 7 } ]ct.findDescendantsOfn3, true; // [ { id: 3 }, { id: 5 }, { id: 6 }, { id: 7 } ]ct.findChildrenOfn3; // [ { id: 5 }, { id: 6 } ] // default equal function://// function(source: T, target: T): boolean {// return source === target;// } ct.findDescendantsOf; // [] // modify equal function ct.setEqualFuncs.id === t.id; ct.findDescendantsOf; // [ { id: 5 }, { id: 6 }, { id: 7 } ]
Run tests
npm run test
Contributing
Contributions, issues and feature requests are welcome!
Feel free to check issues page.
License
Copyright © 2019 ak10m akio.morimoto@airits.jp.
This project is MIT licensed.