0.5.1 • Published 3 years ago

wakefile v0.5.1

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

3 years ago

0.5.1

3 years ago

0.2.15

4 years ago

0.2.14

4 years ago

0.2.12

4 years ago

0.2.9

4 years ago

0.2.7

4 years ago

0.2.6

4 years ago

0.2.8

4 years ago

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

7 years ago

0.2.0

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.16

7 years ago

0.0.15

8 years ago

0.0.14

8 years ago

0.0.13

8 years ago

0.0.12

8 years ago

0.0.11

8 years ago

0.0.10

8 years ago

0.0.9

8 years ago

0.0.8

8 years ago

0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago