1 | export function mapSymbolsToNotifications(marbles, messagesArg) {
|
2 | const messages = messagesArg.slice();
|
3 | const result = {};
|
4 | for (let i = 0; i < marbles.length; i++) {
|
5 | const symbol = marbles[i];
|
6 | switch (symbol) {
|
7 | case ' ':
|
8 | case '-':
|
9 | case '^':
|
10 | case '(':
|
11 | case ')':
|
12 | break;
|
13 | case '#':
|
14 | case '|': {
|
15 | messages.shift();
|
16 | break;
|
17 | }
|
18 | default: {
|
19 | if ((symbol.match(/^[0-9]$/) && i === 0) || marbles[i - 1] === ' ') {
|
20 | const buffer = marbles.slice(i);
|
21 | const match = buffer.match(/^([0-9]+(?:\.[0-9]+)?)(ms|s|m) /);
|
22 | if (match) {
|
23 | i += match[0].length - 1;
|
24 | }
|
25 | break;
|
26 | }
|
27 | const message = messages.shift();
|
28 | result[symbol] = message.notification;
|
29 | }
|
30 | }
|
31 | }
|
32 | return result;
|
33 | }
|
34 |
|
\ | No newline at end of file |