Commit 1031749311b931bd3002c844937b52219aed2775
1 parent
557cc7fd55
Exists in
master
and in
1 other branch
Deprecating enabledModems
Showing 1 changed file with 4 additions and 1 deletions Inline Diff
lib/modems.js
1 | /* eslint-disable no-console */ | 1 | /* eslint-disable no-console */ |
2 | const DEBUG = !!process.env.DEBUG_KOMODO_CENTER_CP_EVO_MODEMS; | 2 | const DEBUG = !!process.env.DEBUG_KOMODO_CENTER_CP_EVO_MODEMS; |
3 | 3 | ||
4 | const config = require('komodo-sdk/config'); | 4 | const config = require('komodo-sdk/config'); |
5 | 5 | ||
6 | exports.modemsDictionary = (arrayOfModem) => { | 6 | exports.modemsDictionary = (arrayOfModem) => { |
7 | const modems = arrayOfModem || config.modems || []; | 7 | const modems = arrayOfModem || config.modems || []; |
8 | const retval = {}; | 8 | const retval = {}; |
9 | modems.forEach((modem) => { | 9 | modems.forEach((modem) => { |
10 | retval[modem.name] = modem; | 10 | retval[modem.name] = modem; |
11 | }); | 11 | }); |
12 | return retval; | 12 | return retval; |
13 | }; | 13 | }; |
14 | 14 | ||
15 | /** | ||
16 | * deprecated | ||
17 | */ | ||
15 | exports.enabledModems = (arrayOfModem) => { | 18 | exports.enabledModems = (arrayOfModem) => { |
16 | const modems = arrayOfModem || config.modems || []; | 19 | const modems = arrayOfModem || config.modems || []; |
17 | return modems.filter((modem) => !modem.disabled); | 20 | return modems.filter((modem) => !modem.disabled); |
18 | }; | 21 | }; |
19 | 22 | ||
20 | exports.outgoingModems = (arrayOfModem) => { | 23 | exports.outgoingModems = (arrayOfModem) => { |
21 | const modems = arrayOfModem || config.modems || []; | 24 | const modems = arrayOfModem || config.modems || []; |
22 | return modems.filter((modem) => !modem.disabled && modem.outgoing); | 25 | return modems.filter((modem) => modem.outgoing); |
23 | }; | 26 | }; |
24 | 27 | ||
25 | exports.randomModem = (arrayOfModem) => { | 28 | exports.randomModem = (arrayOfModem) => { |
26 | const modems = this.outgoingModems(arrayOfModem); | 29 | const modems = this.outgoingModems(arrayOfModem); |
27 | 30 | ||
28 | if (DEBUG) { | 31 | if (DEBUG) { |
29 | console.log('DEBUG_MODEMS: Get random modems', { | 32 | console.log('DEBUG_MODEMS: Get random modems', { |
30 | haystack: modems, | 33 | haystack: modems, |
31 | }); | 34 | }); |
32 | } | 35 | } |
33 | const modemCount = modems.length; | 36 | const modemCount = modems.length; |
34 | 37 | ||
35 | if (!modemCount) return null; | 38 | if (!modemCount) return null; |
36 | 39 | ||
37 | const idx = Math.floor(Math.random() * modemCount); | 40 | const idx = Math.floor(Math.random() * modemCount); |
38 | return modems[idx]; | 41 | return modems[idx]; |
39 | }; | 42 | }; |
40 | 43 |