Package Exports
- is-valid-instance
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (is-valid-instance) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
is-valid-instance

Returns true if a value is a valid instance of Base.
Install
Install with npm:
$ npm install is-valid-instance --saveUsage
Use in your [base][] plugin to ensure that the plugin is registered on a valid instance.
var isValidInstance = require('is-valid-instance');
function plugin(app) {
if (!isValidInstance(app)) return;
// do plugin stauff
}API
Params
val{Object}names{Array|Function}: One or more names to check for on the given instance. Exampleappwill check forapp.isApp === trueorapp._name === 'app'.fn{Function}: Custom function for validating the instance.returns{Boolean}
Example
function plugin(app) {
if (!isValidInstance(app)) return;
// do plugin stuff
}Examples
Collection instance
Return true if the instance is a [templates][] view-collection (views):
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:
function plugin(view) {
if (!isValidInstance(view, ['view'])) {
return plugin;
}
// do plugin stauff
}View instance
Return true if the instance is either "app" or "collection":
function plugin(app) {
if (!isValidInstance(app, ['app', 'collection'])) {
return plugin;
}
// do plugin stauff
}Related projects
You might also be interested in these projects:
- base-app: Starting point for creating a base application, with a few light plugins for running tasks… more | homepage
- base: base is the foundation for creating modular, unit testable and highly pluggable node.js applications, starting… more | homepage
Contributing
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 verb && npm run docsOr, if verb is installed globally:
$ verbRunning tests
Install dev dependencies:
$ npm install -d && npm testAuthor
Jon Schlinkert
License
Copyright © 2016, Jon Schlinkert. Released under the MIT license.
This file was generated by verb, v0.9.0, on May 15, 2016.