Passed
Push — master ( c17029...e68583 )
by Muhammad Dyas
01:29
created

src/helpers/utils.js   A

Complexity

Total Complexity 4
Complexity/F 4

Size

Lines of Code 16
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 16
rs 10
c 0
b 0
f 0
wmc 4
mnd 3
bc 3
fnc 1
bpm 3
cpm 4
noi 1
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
function splitMessage(message) {
9
  const expression = /[^\s"]+|"([^"]*)"/gi;
10
  const result = [];
11
  let match;
12
  do {
13
    match = expression.exec(message);
14
    if (match != null) {
0 ignored issues
show
Best Practice introduced by
Comparing match to null using the != operator is not safe. Consider using !== instead.
Loading history...
15
      result.push(match[1] ? match[1] : match[0]);
16
    }
17
  } while (match != null);
18
19
  return result;
20
}
21
22
23
exports.splitMessage = splitMessage;
24