-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapplyrules.js
50 lines (40 loc) · 1.6 KB
/
applyrules.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const registrationRule = require('./rules/registration');
const promisesRule = require('./rules/promises');
const fifoByTypeRule = require('./rules/fifobytype');
const fifoByTimeoutRule = require('./rules/fifobytimeout');
const intervalRule = require('./rules/interval');
const promiseAllRule = require('./rules/promiseall');
const promiseRaceRule = require('./rules/promiserace');
const globalRules = require('./rules/global');
function applyRules(entries, asyncObjects, relations, opts) {
let defaultOpts = {
registration: true,
promises: true,
fifoByType: true,
fifoByTimeout: true,
interval: true,
promiseAll: true,
promiseRace: true,
global: true
};
opts = { ...defaultOpts, ...opts };
if (opts.registration)
registrationRule.apply(entries, asyncObjects, relations);
if (opts.promises)
promisesRule.apply(entries, asyncObjects, relations);
if (opts.fifoByType)
fifoByTypeRule.apply(entries, asyncObjects, relations);
if (opts.fifoByTimeout)
fifoByTimeoutRule.apply(entries, asyncObjects, relations);
if (opts.interval)
intervalRule.apply(entries, asyncObjects, relations);
if (opts.promiseAll)
promiseAllRule.apply(entries, asyncObjects, relations);
if (opts.global)
globalRules.apply(entries, asyncObjects, relations);
//As promise.race introduces optional h-b relations, they should not be used to
//infer global relations
if (opts.promiseRace)
promiseRaceRule.apply(entries, asyncObjects, relations);
}
module.exports = applyRules;