Passed
Push — master ( 46d449...c17029 )
by Muhammad Dyas
01:28
created

src/helpers/option.js   A

Complexity

Total Complexity 2
Complexity/F 2

Size

Lines of Code 11
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 11
rs 10
c 0
b 0
f 0
wmc 2
mnd 1
bc 1
fnc 1
bpm 1
cpm 2
noi 1
1
/**
2
 * Add a new option to the state(like DB)
3
 *
4
 * @param {string} option - the new option name
5
 * @param {object} state - the current message state
6
 * @param {string} creator - who add the new option
0 ignored issues
show
Documentation introduced by
The parameter creator does not exist. Did you maybe forget to remove this comment?
Loading history...
7
 * @returns {void} card
8
 */
9
function addOptionToState(option, state, creator = '') {
10
  const choiceLength = state.choices.length;
11
  state.choices.push(option);
12
  if (state.choiceCreator === undefined) {
13
    state.choiceCreator = {[choiceLength]: creator};
14
  } else {
15
    state.choiceCreator[choiceLength] = creator;
16
  }
17
}
18
19
exports.addOptionToState = addOptionToState;
20