UNPKG

597 BJavaScriptView Raw
1const RequestList = require('./requestList');
2
3class Beau {
4 constructor(doc) {
5 this.defaults = {
6 VERSION: 1,
7 CACHE: false,
8 HOST: '',
9 PLUGINS: []
10 };
11
12
13 this.configKeys = Object.keys(this.defaults);
14 this.config = this.loadConfig(doc, this.defaults);
15 this.requests = new RequestList(doc, this.config);
16 }
17
18 loadConfig(doc, defaults = {}) {
19 var result = defaults;
20
21 Object.keys(doc)
22 .filter(k => this.configKeys.indexOf(k.toUpperCase()) > -1)
23 .forEach(k => result[k.toUpperCase()] = doc[k]);
24
25 return result;
26 }
27}
28
29
30module.exports = Beau;