1 | var assert = require('assert');
|
2 |
|
3 | var Config = (function () {
|
4 |
|
5 | function Config(options) {
|
6 |
|
7 | this.returnValue = Config.PROMISE;
|
8 |
|
9 | this.acceptsCallback = false;
|
10 |
|
11 | this.isIterable = false;
|
12 |
|
13 | this.maxConcurrency = null;
|
14 | if (options) {
|
15 | this.returnValue = options.returnValue;
|
16 | this.acceptsCallback = options.acceptsCallback;
|
17 | this.isIterable = options.isIterable;
|
18 | this.maxConcurrency = options.maxConcurrency;
|
19 | }
|
20 | }
|
21 |
|
22 | Config.prototype.validate = function () {
|
23 | var knownRetVal = [Config.PROMISE, Config.THUNK, Config.RESULT, Config.NONE].indexOf(this.returnValue) !== -1;
|
24 | assert(knownRetVal, 'Unrecognised return value: ' + this.returnValue);
|
25 | var hasNotifier = this.returnValue !== Config.NONE || this.acceptsCallback;
|
26 | assert(hasNotifier, 'At least one notification method must be enabled.');
|
27 | };
|
28 |
|
29 | Config.PROMISE = 'promise';
|
30 | Config.THUNK = 'thunk';
|
31 | Config.RESULT = 'result';
|
32 | Config.NONE = 'none';
|
33 | return Config;
|
34 | })();
|
35 | module.exports = Config;
|
36 |
|
\ | No newline at end of file |