| Total Complexity | 4 |
| Complexity/F | 2 |
| Lines of Code | 18 |
| Function Count | 2 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 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 |
||
| 7 | * @returns {void} card |
||
| 8 | */ |
||
| 9 | export 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 |