Returns true if a value is a valid instance of Base.
npm install is-valid-instance> Returns true if a value is a valid instance of Base.
Install with npm:
``sh`
$ npm install --save is-valid-instance
Use in your base plugin to ensure that the plugin is registered on a valid instance.
`js
var isValidInstance = require('is-valid-instance');
function plugin(app) {
if (!isValidInstance(app)) return;
// do plugin stauff
}
`
Params
* val {Object}names
* {Array|Function}: One or more names to check for on the given instance. Example app will check for app.isApp === true or app._name === 'app'.fn
* {Function}: Custom function for validating the instance.returns
* {Boolean}
Example
`js`
function plugin(app) {
if (!isValidInstance(app)) return;
// do plugin stuff
}
Collection instance
Return true if the instance is a templates view-collection (views):
`js`
function plugin(collection) {
if (!isValidInstance(collection, ['views'])) {
// optionally return the plugin function so the plugin is re-tried on
// each instance until it finds the correct one
return plugin;
}
// do plugin stauff
}
View instance
Return true if the instance is a templates view:
`js`
function plugin(view) {
if (!isValidInstance(view, ['view'])) {
return plugin;
}
// do plugin stauff
}
View instance
Return true if the instance is either "app" or "collection":
`js`
function plugin(app) {
if (!isValidInstance(app, ['app', 'collection'])) {
return plugin;
}
// do plugin stauff
}
* base-app: Starting point for creating a base application, with a few light plugins for running tasks… more | homepage
* base-plugins: Upgrade's plugin support in base applications to allow plugins to be called any time after… more | homepage
* base: base is the foundation for creating modular, unit testable and highly pluggable node.js applications, starting… more | set, get, del and use."" class="text-primary hover:underline" target="_blank" rel="noopener noreferrer">homepage
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
_(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)_
To generate the readme, run the following command:
`sh`
$ npm install -g verbose/verb#dev verb-generate-readme && verb
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
`sh``
$ npm install && npm test
Jon Schlinkert
* github/jonschlinkert
* twitter/jonschlinkert
Copyright © 2017, Jon Schlinkert.
Released under the MIT License.
*
_This file was generated by verb-generate-readme, v0.4.3, on March 24, 2017._