Net Tree is an algorithm which turns an array of items with expressed dependencies to a stream of items with expressed tree structure.
Terminology:
- item is an item being processed or the resulting item depending on context
-
super item is an item which has identifier matching one of another item's
superIds
, it is a super to it (this dictates nesting) -
prior item is an item which has identifier matching one of another item's
priorIds
, is is a prior to it (this dictates ordering) - hyper item is an item which is a given item but for another super in the item's path, it is a hyper to it (this dictates flashing)
recurse(items, ownerIds)
-
items
is an array of items which is never mutated byrecurse
-
id
is unique item identifier, most commonly a number of a string -
superIds
is an array of identifiers of super items -
priorIds
is a map describing from which super of itssuperIds
has item which prior item (dependency for ordering) -
state
is eitherexpanded
(the item should be expanded),collapsed
(the item should be collapsed), orundefined
-
data
is any value with the item data
-
-
ownerIds
is a map describing for which super of itssuperIds
is item expanded (one at a time)
The return value is a stream of items with these fields:
-
item
is the item passed in fromitems
-
level
is the nesting level in the tree, starting at a0
for root items -
state
is an expansion state from enumeration of:-
expandable-explicitly-expanded
means the item had astate
ofexpanded
and its current super matches its owner -
expandable-implicitly-expanded
means the item had astate
ofundefined
and appeared first on prior order (expand by default) -
expandable-explicitly-collapsed
means the item had astate
ofcollapsed
or its current super doesn't match its owner -
expandable-implicitly-expanded
means the item had astate
ofundefined
and didn't appear first on prior order -
unexpandable
means the item has no subitems
-
-
superId
is an effective super of the item (from item'ssuperIds
)
yarn start
- Update
CHANGELOG.md
andpackage.json
'sversion
npm publish
For stuff to do, see doc/tasks
.