@djuleayo/hierarchy
TypeScript icon, indicating that this package has built-in type declarations

1.0.8 • Public • Published

Hierarchy

Installation

npm i @djuleayo/hierarchy

Description

In memory implementation of a hierarchy.

Objects are hierarchies. They have keys, also called nodes and other names. Here they are called Marks. Hierarchy allows marks to be objects, not just strings like in js object. It also provides set of operations custom to hierarchies. See examples for more.

Basic usage

let Hierarchy = require('@djuleayo/hierarchy');

let h = new Hierarchy({
  name: 'My fancy mark',
  desription: 'This is used for...'
});

let child = new Hierarchy('subhierarchy');

h.addChild(child);

let isDescendant = child.belongs(h);
let branch = child.getParentBranch();

console.log(isDescendant, JSON.stringify(branch.map(x => x.mark), null, 2));

GitHub Repository

Check it out.

Package Sidebar

Install

npm i @djuleayo/hierarchy

Weekly Downloads

2

Version

1.0.8

License

ISC

Unpacked Size

53 kB

Total Files

11

Last publish

Collaborators

  • djuleayo