whiterabbit
v0.2.5
Published
<div align="center"> <img src="./logo.png"> </div> <h1 align="center"> whiteRabbit</h1> <br>
Downloads
20
Readme
| Usage | Plugins | Development | Debug | | ------- | ------- | ------- | ------- |
Usage
install npm package
$ npm install whiterabbit
usages
var whiteRabbit = require('whiterabbit');
var cuteRabbit = new whiteRabbit([plugs]);
cuteRabbit.query({foo:'bar'},{series:true}).then(data => {
console.log(data);
}).catch(err => {
console.log(err);
});
remove the plugin
var whiteRabbit = require('whiterabbit');
var cuteRabbit = new whiteRabbit([plugs]);
cuteRabbit.destory('plug1');
//or
cuteRabbit.destory(['plug1','plug2']);
active the plugin
var whiteRabbit = require('whiterabbit');
var cuteRabbit = new whiteRabbit([plugs]);
cuteRabbit.active('plug1');
//or
cuteRabbit.active(['plug1','plug2']);
Plugins
Development
how to write plugins? so simple..
const whiteRabbit = require('whiterabbit');
module.exports = whiteRabbit.plugin('hello',(args) =>{
return new Promise(function(resolve, reject) { // always need return Promise
if(args.foo == 'bar') resolve('world');
resolve('whiteRabbit!');
});
});
debug and error handling
const PluginName = 'Foo';
const whiteRabbit = require('whiterabbit');
const debug = require('debug')(PluginName);
const PlugError = whiteRabbit.pluginError(PluginName)
module.exports = whiteRabbit.plugin('hello',(args) =>{
return new Promise(function(resolve, reject) { // always need return Promise
debug('started plugin..')
if(args.foo == 'bar'){
debug('complete data');
resolve('world');
}else{
reject(PlugError(new Error('Oh No!')));
}
});
});
Debug
env DEBUG='whiterabbit' node ./example/example.js
# or plugins
env DEBUG='plug1,plug2' node ./example/example.js
todo
- test