StackGenVis: Alignment of Data, Algorithms, and Models for Stacking Ensemble Learning Using Performance Metrics https://doi.org/10.1109/TVCG.2020.3030352
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

134 lines
3.5 KiB

# is-valid-instance [![NPM version](https://img.shields.io/npm/v/is-valid-instance.svg?style=flat)](https://www.npmjs.com/package/is-valid-instance) [![NPM downloads](https://img.shields.io/npm/dm/is-valid-instance.svg?style=flat)](https://npmjs.org/package/is-valid-instance) [![Build Status](https://img.shields.io/travis/jonschlinkert/is-valid-instance.svg?style=flat)](https://travis-ci.org/jonschlinkert/is-valid-instance)
Returns true if a value is a valid instance of Base.
## Install
Install with [npm](https://www.npmjs.com/):
```sh
$ npm install is-valid-instance --save
```
## Usage
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
}
```
## API
**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
}
```
## Examples
**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
}
```
## Related projects
You might also be interested in these projects:
* [base-app](https://www.npmjs.com/package/base-app): Starting point for creating a base application, with a few light plugins for running tasks… [more](https://www.npmjs.com/package/base-app) | [homepage](https://github.com/node-base/base-app)
* [base](https://www.npmjs.com/package/base): base is the foundation for creating modular, unit testable and highly pluggable node.js applications, starting… [more](https://www.npmjs.com/package/base) | [homepage](https://github.com/node-base/base)
## Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/is-valid-instance/issues/new).
## Building docs
Generate readme and API documentation with [verb](https://github.com/verbose/verb):
```sh
$ npm install verb && npm run docs
```
Or, if [verb](https://github.com/verbose/verb) is installed globally:
```sh
$ verb
```
## Running tests
Install dev dependencies:
```sh
$ npm install -d && npm test
```
## Author
**Jon Schlinkert**
* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
## License
Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT license](https://github.com/jonschlinkert/is-valid-instance/blob/master/LICENSE).
***
_This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on May 15, 2016._