0.5.1 • Published 4 years ago

wakefile v0.5.1

Weekly downloads
6
License
GPLv3
Repository
-
Last release
4 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

4 years ago

0.5.1

4 years ago

0.2.15

5 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

7 years ago

0.2.4

7 years ago

0.2.3

7 years ago

0.2.2

7 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.16

8 years ago

0.0.15

9 years ago

0.0.14

9 years ago

0.0.13

9 years ago

0.0.12

9 years ago

0.0.11

9 years ago

0.0.10

9 years ago

0.0.9

9 years ago

0.0.8

9 years ago

0.0.7

9 years ago

0.0.6

9 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago