@basd/nested
Version:
Allows you to create deeply nested object structures, while also enabling you to traverse them efficiently.
69 lines (50 loc) • 2.26 kB
Markdown
## Members
<dl>
<dt><a href="#root">root</a> ⇒ <code>Object</code></dt>
<dd><p>Gets the root node by traversing up the parent nodes.</p>
</dd>
</dl>
## Functions
<dl>
<dt><a href="#NestedMixin">NestedMixin([childClass])</a></dt>
<dd><p>Mixin to add nested capabilities to a class.
This class can be used as a superclass or mixed into other classes.</p>
</dd>
<dt><a href="#mixin">mixin(childClass)</a> ⇒ <code>Class</code></dt>
<dd><p>Utility function for creating a mixin with Nested capabilities.</p>
</dd>
<dt><a href="#sub">sub(path, [opts], ...args)</a> ⇒ <code>Object</code></dt>
<dd><p>Creates and returns a new node, subordinated to this node.</p>
</dd>
</dl>
<a name="root"></a>
## root ⇒ <code>Object</code>
Gets the root node by traversing up the parent nodes.
**Kind**: global variable
**Returns**: <code>Object</code> - The root node.
<a name="NestedMixin"></a>
## NestedMixin([childClass])
Mixin to add nested capabilities to a class.
This class can be used as a superclass or mixed into other classes.
**Kind**: global function
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| [childClass] | <code>Class</code> | <code>class {}</code> | The class to which nested capabilities will be added. |
<a name="mixin"></a>
## mixin(childClass) ⇒ <code>Class</code>
Utility function for creating a mixin with Nested capabilities.
**Kind**: global function
**Returns**: <code>Class</code> - - A class mixed in with Nested capabilities.
| Param | Type | Description |
| --- | --- | --- |
| childClass | <code>Class</code> | The class to which nested capabilities will be added. |
<a name="sub"></a>
## sub(path, [opts], ...args) ⇒ <code>Object</code>
Creates and returns a new node, subordinated to this node.
**Kind**: global function
**Returns**: <code>Object</code> - - The newly created sub-node.
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| path | <code>Array</code> \| <code>string</code> | | The path to the new sub-node. |
| [opts] | <code>Object</code> \| <code>function</code> | <code>{}</code> | Options or a function to generate options for the new node. |
| ...args | <code>any</code> | | Additional arguments passed to the constructor of the new node. |