0.2.5 • Published 6 years ago

whiterabbit v0.2.5

Weekly downloads
7
License
MIT
Repository
github
Last release
6 years ago
UsagePluginsDevelopmentDebug

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
0.2.5

6 years ago

0.2.4

6 years ago

0.2.3

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago