Completed
Push — master ( 57c78c...4fcad4 )
by Muhammad Dyas
15s queued 13s
created

src/helpers/utils.ts   A

Complexity

Total Complexity 8
Complexity/F 4

Size

Lines of Code 21
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 8
eloc 12
mnd 6
bc 6
fnc 2
dl 0
loc 21
bpm 3
cpm 4
noi 0
c 0
b 0
f 0
rs 10
1
/**
2
 * Split string/message to topic and choice
3
 * reference: https://stackoverflow.com/a/18647776/2671470
4
 *
5
 * @param {string} message - the new option name
6
 * @returns {array} card
7
 */
8
export function splitMessage(message: string) {
9
  const expression = /[^\s"]+|"([^"]*)"/gi;
10
  const result = [];
11
  let match;
12
  do {
13
    match = expression.exec(message);
14
    if (match != null) {
15
      result.push(match[1] ? match[1] : match[0]);
16
    }
17
  } while (match != null);
18
19
  return result;
20
}
21