{"_id":"base-tree","_rev":"231045","name":"base-tree","description":"Add a tree method to generate a hierarchical tree structure representing nested applications and child objects.","dist-tags":{"latest":"0.2.0"},"maintainers":[{"name":"doowb","email":"brian.woodward@gmail.com"}],"time":{"modified":"2021-06-03T15:46:08.000Z","created":"2015-12-04T20:52:17.072Z","0.2.0":"2016-01-14T18:16:34.668Z","0.1.0":"2015-12-04T20:52:17.072Z"},"users":{},"author":{"name":"Brian Woodward","url":"https://github.com/doowb"},"repository":{"type":"git","url":"git+https://github.com/doowb/base-tree.git"},"versions":{"0.2.0":{"name":"base-tree","description":"Add a tree method to generate a hierarchical tree structure representing nested applications and child objects.","version":"0.2.0","homepage":"https://github.com/doowb/base-tree","author":{"name":"Brian Woodward","url":"https://github.com/doowb"},"repository":{"type":"git","url":"git+https://github.com/doowb/base-tree.git"},"bugs":{"url":"https://github.com/doowb/base-tree/issues"},"license":"MIT","files":["index.js"],"main":"index.js","engines":{"node":">=0.10.0"},"scripts":{"test":"mocha"},"dependencies":{"extend-shallow":"^2.0.1"},"devDependencies":{"ansi-colors":"^0.1.0","archy":"^1.0.0","base-methods":"^0.6.1","gulp":"^3.9.0","gulp-eslint":"^1.1.1","gulp-istanbul":"^0.10.3","gulp-mocha":"^2.2.0","mocha":"^2.3.4","use":"^1.1.2"},"keywords":[],"verb":{"related":{"list":["base-methods","use"]}},"gitHead":"32f9fd3015460512a5f4013990048827329146ee","_id":"base-tree@0.2.0","_shasum":"d23fb91da202325264ac03b4230f1ce811b5afad","_from":".","_npmVersion":"3.5.2","_nodeVersion":"5.1.1","_npmUser":{"name":"doowb","email":"brian.woodward@gmail.com"},"dist":{"shasum":"d23fb91da202325264ac03b4230f1ce811b5afad","size":3737,"noattachment":false,"key":"/base-tree/-/base-tree-0.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/base-tree/download/base-tree-0.2.0.tgz"},"maintainers":[{"name":"doowb","email":"brian.woodward@gmail.com"}],"directories":{},"publish_time":1452795394668,"_cnpm_publish_time":1452795394668,"_hasShrinkwrap":false},"0.1.0":{"name":"base-tree","description":"Add a tree method to generate a hierarchical tree structure representing nested applications and child objects.","version":"0.1.0","homepage":"https://github.com/doowb/base-tree","author":{"name":"Brian Woodward","url":"https://github.com/doowb"},"repository":{"type":"git","url":"git+https://github.com/doowb/base-tree.git"},"bugs":{"url":"https://github.com/doowb/base-tree/issues"},"license":"MIT","files":["index.js"],"main":"index.js","engines":{"node":">=0.10.0"},"scripts":{"test":"mocha"},"dependencies":{"extend-shallow":"^2.0.1"},"devDependencies":{"archy":"^1.0.0","base-methods":"^0.6.1","gulp":"^3.9.0","gulp-eslint":"^1.1.1","gulp-istanbul":"^0.10.3","gulp-mocha":"^2.2.0","mocha":"^2.3.4","use":"^1.1.2"},"keywords":[],"verb":{"related":{"list":["base-methods","use"]}},"gitHead":"2bc01723b18f87072ac99f06d14cd99f34c1f7e5","_id":"base-tree@0.1.0","_shasum":"4dfb07952061f4f7e4d7a3542dc6a1cd4cc88c19","_from":".","_npmVersion":"2.13.3","_nodeVersion":"0.12.0","_npmUser":{"name":"doowb","email":"brian.woodward@gmail.com"},"dist":{"shasum":"4dfb07952061f4f7e4d7a3542dc6a1cd4cc88c19","size":3597,"noattachment":false,"key":"/base-tree/-/base-tree-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/base-tree/download/base-tree-0.1.0.tgz"},"maintainers":[{"name":"doowb","email":"brian.woodward@gmail.com"}],"directories":{},"publish_time":1449262337072,"_cnpm_publish_time":1449262337072,"_hasShrinkwrap":false}},"readme":"# base-tree [![NPM version](https://img.shields.io/npm/v/base-tree.svg)](https://www.npmjs.com/package/base-tree) [![Build Status](https://img.shields.io/travis/doowb/base-tree.svg)](https://travis-ci.org/doowb/base-tree)\n\n> Add a tree method to generate a hierarchical tree structure representing nested applications and child objects.\n\n## Install\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm i base-tree --save\n```\n\n## Usage\n\n```js\nvar tree = require('base-tree');\n```\n\n## API\n\n### [.tree](index.js#L40)\nCreates a `.tree` method on `app` that will recursively generate a tree of nodes specified by the `names` option passed in.\n\n\n**Params**\n\n* `options` **{Object}**: Options to use in `.tree` method    \n* `options.names` **{String|Array}**: Names of the collection objects to look for child nodes.    \n* `options.method` **{String}**: Optional method names defined on the `app`. Defaults to `tree`.    \n* `options.tree` **{Function}**: Optional `tree` function to use to generate the node or tree of nodes for the current app. Takes `app` and `options` as parameters.    \n* `options.getLabel` **{Function}**: Get a label for the node being built. Takes `app` and `options` as parameters.    \n* `options.getMetadata` **{Function}**: Get a metadata object for the node being built. Takes `app` and `options` as parameters.    \n* `returns` **{Function}**: plugin  \n\n**Example**\n\n\n\n```js\nvar app = new Base();\napp.use(tree({names: 'children'}));\n\napp.children = {};\napp.children.one = new Base();\napp.children.two = new Base();\napp.children.three = new Base();\n\nconsole.log(app.tree());\nconsole.log(archy(app.tree()));\n```\n\n\n### [options.tree](index.js#L78)\nDefault tree building function. Gets the label and metadata properties for the current `app` and recursively generates the child nodes and child trees if possible.\n\n\nThis method may be overriden by passing a `.tree` function on options.\n\n**Params**\n\n* `app` **{Object}**: Current application to build a node and tree from.    \n* `options` **{Object}**: Options used to control how the `label` and `metadata` properties are retreived.    \n* `returns` **{Object}**: Generated node containing `label`, `metadata`, and `nodes` properties for current segment of a tree.  \n\n\n\n### [options.getLabel](index.js#L124)\n\nFigure out a label to add for a node in the tree.\n\n**Params**\n\n* `app` **{Object}**: Current node/app being iterated over    \n* `options` **{Object}**: Pass `getLabel` on options to handle yourself.    \n* `returns` **{String}**: label to be shown  \n\n\n\n### [options.getMetadata](index.js#L141)\n\nAdditional metadata that should be added to a node\n\n**Params**\n\n* `app` **{Object}**: Current node/app being iterated over    \n* `options` **{Object}**: Pass `getMetadata` on options to handle yourself.    \n* `returns` **{Object}**: metadata object to add to node  \n\n\n\n\n## Running Example\n\nClone the repository, install dependencies and run the example with `node`.\n\n```sh\n$ git clone https://github.com/doowb/base-tree\n$ cd base-tree\n$ npm install\n$ node example.js\n```\n\nThe example will output the raw object and a formatted tree structure using [archy][]\n\n![image](https://cloud.githubusercontent.com/assets/995160/11600862/6d97b04e-9a9d-11e5-983d-57b47cd13c75.png)\n\n## Related projects\n* [base-methods](https://www.npmjs.com/package/base-methods): base-methods is the foundation for creating modular, unit testable and highly pluggable node.js applications, starting… [more](https://www.npmjs.com/package/base-methods) | [homepage](https://github.com/jonschlinkert/base-methods)\n* [use](https://www.npmjs.com/package/use): Easily add plugin support to your node.js application. | [homepage](https://github.com/jonschlinkert/use)\n\n## Running tests\nInstall dev dependencies:\n\n```sh\n$ npm i -d && npm test\n```\n\n## Contributing\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/doowb/base-tree/issues/new).\n\n## Author\n**Brian Woodward**\n\n+ [github/doowb](https://github.com/doowb)\n+ [twitter/doowb](http://twitter.com/doowb)\n\n## License\nCopyright © 2016 [Brian Woodward](https://github.com/doowb)\nReleased under the MIT license.\n\n***\n\n_This file was generated by [verb](https://github.com/verbose/verb) on January 14, 2016._\n\n[archy]: https://github.com/substack/node-archy\n","_attachments":{},"homepage":"https://github.com/doowb/base-tree","bugs":{"url":"https://github.com/doowb/base-tree/issues"},"license":"MIT"}