#base[](https://www.npmjs.com/package/base) [](https://npmjs.org/package/base) [](https://npmjs.org/package/base) [](https://travis-ci.org/node-base/base)
>baseisthefoundationforcreatingmodular,unittestableandhighlypluggablenode.jsapplications,startingwithahandfulofcommonmethods,like`set`, `get`, `del` and `use`.
Bydefault,the`.get`, `.set` and `.has` methods set and get values from the root of the `base` instance. You can customize this using the `.namespace`methodexposedontheexportedfunction.Forexample:
```js
varBase=require('base');
// get and set values on the `base.cache` object
varbase=Base.namespace('cache');
varapp=base();
app.set('foo','bar');
console.log(app.cache.foo);
//=> 'bar'
```
##API
**Usage**
```js
varBase=require('base');
varapp=newBase();
app.set('foo','bar');
console.log(app.foo);
//=> 'bar'
```
###[Base](index.js#L44)
Createaninstanceof`Base` with the given `config` and `options`.
**Params**
*`config`**{Object}**:Ifsupplied,thisobjectispassedto[cache-base](https://github.com/jonschlinkert/cache-base) to merge onto the the instance upon instantiation.
*`options` **{Object}**: If supplied, this object is used to initialize the `base.options`object.
**Example**
```js
// initialize with `config` and `options`
varapp=newBase({isApp:true},{abc:true});
app.set('foo','bar');
// values defined with the given `config` object will be on the root of the instance
console.log(app.baz);//=> undefined
console.log(app.foo);//=> 'bar'
// or use `.get`
console.log(app.get('isApp'));//=> true
console.log(app.get('foo'));//=> 'bar'
// values defined with the given `options` object will be on `app.options
console.log(app.options.abc);//=> true
```
###[.is](index.js#L107)
Setthegiven`name` on `app._name` and `app.is*`properties.Usedfordoinglookupsinplugins.
// arbitrary `render` function using lodash `template`
app.define('render',function(str,locals){
return_.template(str)(locals);
});
```
###[.mixin](index.js#L222)
Mixproperty`key` onto the Base prototype. If base is inherited using `Base.extend` this method will be overridden by a new `mixin`methodthatwillonlyaddpropertiestotheprototypeoftheinheritingapplication.
**Params**
*`key`**{String}**
*`val`**{Object|Array}**
*`returns` **{Object}**: Returns the `base`instanceforchaining.
**Example**
```js
app.mixin('foo',function(){
// do stuff
});
```
###[.base](index.js#L268)
Getter/setterusedwhencreatingnestedinstancesof`Base`, for storing a reference to the first ancestor instance. This works by setting an instance of `Base` on the `parent` property of a "child" instance. The `base` property defaults to the current instance if no `parent`propertyisdefined.
**Example**
```js
// create an instance of `Base`, this is our first ("base") instance
varfirst=newBase();
first.foo='bar';// arbitrary property, to make it easier to see what's happening later
// create another instance
varsecond=newBase();
// create a reference to the first instance (`first`)
second.parent=first;
// create another instance
varthird=newBase();
// create a reference to the previous instance (`second`)
// repeat this pattern every time a "child" instance is created
third.parent=second;
// we can always access the first instance using the `base` property
*`returns` **{Object}**: Returns the `Base`constructorforchaining
**Example**
```js
Base.use(function(app){
app.foo='bar';
});
varapp=newBase();
console.log(app.foo);
//=> 'bar'
```
###[#extend](index.js#L337)
Staticmethodforinheritingtheprototypeandstaticmethodsofthe`Base`class.Thismethodgreatlysimplifiestheprocessofcreatinginheritance-basedapplications.See[static-extend](https://github.com/jonschlinkert/static-extend) for more details.
*`returns` **{Object}**: Returns the `Base`constructorforchaining
**Example**
```js
varextend=cu.extend(Parent);
Parent.extend(Child);
// optional methods
Parent.extend(Child,{
foo:function(){},
bar:function(){}
});
```
###[#mixin](index.js#L379)
Usedforaddingmethodstothe`Base` prototype, and/or to the prototype of child instances. When a mixin function returns a function, the returned function is pushed onto the `.mixins` array, making it available to be used on inheriting classes whenever `Base.mixins()` is called (e.g. `Base.mixins(Child)`).
**Params**
*`fn`**{Function}**:Functiontocall
*`returns` **{Object}**: Returns the `Base`constructorforchaining
*`returns` **{Object}**: Returns the `Base`constructorforchaining
**Example**
```js
Base.extend(Child);
Base.mixins(Child);
```
###[#inherit](index.js#L420)
Similarto`util.inherit`, but copies all static properties, prototype properties, and getters/setters from `Provider` to `Receiver`.See[class-utils](https://github.com/jonschlinkert/class-utils#inherit) for more details.
*Static`.use` and `.run`methodsarenownon-enumerable
###v0.9.0
**Breakingchanges**
*`.is`nolongertakesafunction,astringmustbepassed
*allremaining`.debug`codehasbeenremoved
*`app._namespace` was removed (related to `debug`)
*`.plugin`, `.use`, and `.define`nolongeremitevents
*`.assertPlugin`wasremoved
*`.lazy`wasremoved
##About
###Relatedprojects
*[base-cwd](https://www.npmjs.com/package/base-cwd): Base plugin that adds a getter/setter for the current working directory. | [homepage](https://github.com/node-base/base-cwd "Base plugin that adds a getter/setter for the current working directory.")
*[base-data](https://www.npmjs.com/package/base-data): adds a `data` method to base-methods. | [homepage](https://github.com/node-base/base-data "adds a `data` method to base-methods.")
*[base-fs](https://www.npmjs.com/package/base-fs): base-methods plugin that adds vinyl-fs methods to your 'base' application for working with the file… [more](https://github.com/node-base/base-fs) | [homepage](https://github.com/node-base/base-fs "base-methods plugin that adds vinyl-fs methods to your 'base' application for working with the file system, like src, dest, copy and symlink.")
*[base-generators](https://www.npmjs.com/package/base-generators): Adds project-generator support to your `base` application. | [homepage](https://github.com/node-base/base-generators "Adds project-generator support to your `base` application.")
*[base-option](https://www.npmjs.com/package/base-option): Adds a few options methods to base, like `option`, `enable` and `disable`. See the readme… [more](https://github.com/node-base/base-option) | [homepage](https://github.com/node-base/base-option "Adds a few options methods to base, like `option`, `enable` and `disable`. See the readme for the full API.")
*[base-pipeline](https://www.npmjs.com/package/base-pipeline): base-methods plugin that adds pipeline and plugin methods for dynamically composing streaming plugin pipelines. | [homepage](https://github.com/node-base/base-pipeline "base-methods plugin that adds pipeline and plugin methods for dynamically composing streaming plugin pipelines.")
*[base-pkg](https://www.npmjs.com/package/base-pkg): Plugin for adding a `pkg` method that exposes pkg-store to your base application. | [homepage](https://github.com/node-base/base-pkg "Plugin for adding a `pkg` method that exposes pkg-store to your base application.")
*[base-plugins](https://www.npmjs.com/package/base-plugins): Adds 'smart plugin' support to your base application. | [homepage](https://github.com/node-base/base-plugins "Adds 'smart plugin' support to your base application.")
*[base-questions](https://www.npmjs.com/package/base-questions): Plugin for base-methods that adds methods for prompting the user and storing the answers on… [more](https://github.com/node-base/base-questions) | [homepage](https://github.com/node-base/base-questions "Plugin for base-methods that adds methods for prompting the user and storing the answers on a project-by-project basis.")
*[base-store](https://www.npmjs.com/package/base-store): Plugin for getting and persisting config values with your base-methods application. Adds a 'store' object… [more](https://github.com/node-base/base-store) | [homepage](https://github.com/node-base/base-store "Plugin for getting and persisting config values with your base-methods application. Adds a 'store' object that exposes all of the methods from the data-store library. Also now supports sub-stores!")
*[base-task](https://www.npmjs.com/package/base-task): base plugin that provides a very thin wrapper around [https://github.com/doowb/composer](https://github.com/doowb/composer) for adding task methods to… [more](https://github.com/node-base/base-task) | [homepage](https://github.com/node-base/base-task "base plugin that provides a very thin wrapper around <https://github.com/doowb/composer> for adding task methods to your application.")
_(Thisproject'sreadme.mdisgeneratedby[verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_