0.5.1 • Published 5 years ago

wakefile v0.5.1

Weekly downloads
6
License
GPLv3
Repository
-
Last release
5 years ago

Wakefile

Js rules builder inspired by unix make util.

For this module to be useful you need to provide prototype with target(), run() and other methods.

Example

module.exports = class Rules { constructor() { this.map = new Map(); }

// required target(name) { this.entry = {}; this.map.set(name, this.entry);

return this;

}

params(params) { this.entry.params = params; return this; // required for chaining }

use(cb) { this.entry.cb = cb; }

// required async run(ctx) { var entry = this.maps.get(ctx.method);

if(entry) {
  return await entry.cb(ctx);
}

} }

Now you can use it

const Wakefile = require('wakefile'); const rules = new Wakefile(new Rules()); const conf = require('./config/rules');

conf(rules);

async test(ctx) { var result = await rules.run(ctx); }

test({method: 'foo', data: 1234}) test({method: 'bar', data: 4321})

Here is example of config/rules

module.export = function rules($) { $('foo').params({a: 1}).use(async(ctx) => {console.log('foo', ctx.data)}) $('bar').params({b: 2}).use(async(ctx) => {console.log('bar', ctx.data)}) }

TODO

Examples

0.5.0

5 years ago

0.5.1

5 years ago

0.2.15

6 years ago

0.2.14

6 years ago

0.2.12

6 years ago

0.2.9

6 years ago

0.2.7

6 years ago

0.2.6

6 years ago

0.2.8

6 years ago

0.2.5

8 years ago

0.2.4

8 years ago

0.2.3

8 years ago

0.2.2

8 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago

0.0.16

9 years ago

0.0.15

10 years ago

0.0.14

10 years ago

0.0.13

10 years ago

0.0.12

10 years ago

0.0.11

10 years ago

0.0.10

10 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago