*Net Tree* is an algorithm which turns an array of items with expressed dependencies to a stream of items with expressed tree structure.
Homepage Repository npm Download
npm install net-tree@8.0.0
Net Tree is an algorithm which turns an array of items with expressed dependencies to a stream of items with expressed tree structure.
Terminology:
superIds
, it is a super to it (this dictates nesting)priorIds
, is is a prior to it (this dictates ordering)recurse(items, ownerIds)
items
is an array of items which is never mutated by recurse
id
is unique item identifier, most commonly a number of a stringsuperIds
is an array of identifiers of super itemspriorIds
is a map describing from which super of its superIds
has item which prior item (dependency for ordering)state
is either expanded
(the item should be expanded), collapsed
(the item should be collapsed), or undefined
data
is any value with the item dataownerIds
is a map describing for which super of its superIds
is item expanded (one at a time)The return value is a stream of items with these fields:
item
is the item passed in from items
level
is the nesting level in the tree, starting at a 0
for root itemsstate
is an expansion state from enumeration of:
expandable-explicitly-expanded
means the item had a state
of expanded
and its current super matches its ownerexpandable-implicitly-expanded
means the item had a state
of undefined
and appeared first on prior order (expand by default)expandable-explicitly-collapsed
means the item had a state
of collapsed
or its current super doesn't match its ownerexpandable-implicitly-expanded
means the item had a state
of undefined
and didn't appear first on prior orderunexpandable
means the item has no subitemssuperId
is an effective super of the item (from item's superIds
)yarn start
CHANGELOG.md
and package.json
's version
npm publish
For stuff to do, see doc/tasks
.