A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.npmjs.com/package/base-tree below:

base-tree - npm

base-tree

Add a tree method to generate a hierarchical tree structure representing nested applications and child objects.

Install

Install with npm:

Usage
var tree = require('base-tree');
API .tree

Creates a .tree method on app that will recursively generate a tree of nodes specified by the names option passed in.

Params

Example

var app = new Base();
app.use(tree({names: 'children'}));

app.children = {};
app.children.one = new Base();
app.children.two = new Base();
app.children.three = new Base();

console.log(app.tree());
console.log(archy(app.tree()));
options.tree

Default tree building function. Gets the label and metadata properties for the current app and recursively generates the child nodes and child trees if possible.

This method may be overriden by passing a .tree function on options.

Params

options.getLabel

Figure out a label to add for a node in the tree.

Params

options.getMetadata

Additional metadata that should be added to a node

Params

Running Example

Clone the repository, install dependencies and run the example with node.

$ git clone https://github.com/doowb/base-tree
$ cd base-tree
$ npm install
$ node example.js

The example will output the raw object and a formatted tree structure using archy

Related projects Running tests

Install dev dependencies:

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Author

Brian Woodward

License

Copyright © 2016 Brian Woodward Released under the MIT license.

This file was generated by verb on January 14, 2016.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4