base-namespace
v0.2.0
Published
Plugin that adds a `namespace` getter to a Base instance.
Downloads
89,500
Readme
base-namespace
Plugin that adds a namespace
getter to a Base instance.
Install
Install with npm:
$ npm install base-namespace --save
Usage
var namespace = require('base-namespace');
var Base = require('base');
var base = new Base();
base.use(namespace());
Default
By default, namespace
uses the app._name
property, which is uses the constructor name (set in base):
console.log(base.namespace);
//=> 'base'
Alias
If alias
is defined, it will be used instead of app._name
:
base.alias = 'foo';
console.log(base.namespace);
//=> 'foo'
Parent namespace
If a parent
instance is defined, namespace
is created from parent.namespace
+ alias
:
var foo = new Base();
foo.alias = 'whatever';
base.parent = foo;
base.alias = 'foo';
console.log(base.namespace);
//=> 'whatever.foo'
Multiple ancestors
When an app has multiple ancestors, its namespace
might look something like this:
var foo = new Base();
foo.alias = 'foo';
var bar = new Base();
bar.alias = 'bar';
bar.parent = foo;
var baz = new Base();
baz.alias = 'baz';
baz.parent = bar;
var qux = new Base();
qux.alias = 'qux';
qux.parent = baz;
console.log(qux.namespace);
//=> 'foo.bar.baz.qux'
Related projects
You might also be interested in these projects:
- base-env: Base plugin, creates a normalized environment object from a function, filepath or instance of base. | homepage
- base: base is the foundation for creating modular, unit testable and highly pluggable node.js applications, starting… more | homepage
- base-generators: Adds project-generator support to your
base
application. | homepage - base-task: base plugin that provides a very thin wrapper around https://github.com/doowb/composer for adding task methods to… more | homepage
Contributing
This document was generated by verb, please don't edit directly. Any changes to the readme must be made in .verb.md. See Building Docs.
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Building docs
Generate readme and API documentation with verb:
$ npm install -g verb verb-readme-generator && verb
Running tests
Install dev dependencies:
$ npm install -d && npm test
Author
Jon Schlinkert
License
Copyright © 2016, Jon Schlinkert. Released under the MIT license.
This file was generated by verb, v0.9.0, on June 05, 2016.