whiterabbit

0.2.5 • Public • Published

whiteRabbit


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

Readme

Keywords

Package Sidebar

Install

npm i whiterabbit

Weekly Downloads

9

Version

0.2.5

License

MIT

Unpacked Size

79.7 kB

Total Files

13

Last publish

Collaborators

  • c0b41