Total Complexity | 2 |
Complexity/F | 2 |
Lines of Code | 20 |
Function Count | 1 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import {PollState} from './interfaces'; |
||
2 | |||
3 | /** |
||
4 | * Add a new option to the state(like DB) |
||
5 | * |
||
6 | * @param {string} option - the new option name |
||
7 | * @param {object} state - the current message state |
||
8 | * @param {string} creator - who add the new option |
||
9 | * @returns {void} card |
||
10 | */ |
||
11 | export function addOptionToState(option: string, state: PollState, creator = '') { |
||
12 | const choiceLength = state.choices.length; |
||
13 | state.choices.push(option); |
||
14 | if (state.choiceCreator === undefined) { |
||
15 | state.choiceCreator = {[choiceLength]: creator}; |
||
16 | } else { |
||
17 | state.choiceCreator[choiceLength] = creator; |
||
18 | } |
||
19 | } |
||
20 |