1
1
"use strict" ;
2
2
var cleanup_1 = require ( './cleanup' ) ;
3
3
var match_1 = require ( './match' ) ;
4
- function doAction ( type , isArray , actionValue , result , line , _a ) {
5
- var page = _a . page , task = _a . task ;
4
+ function doAction ( _a ) {
5
+ var type = _a . type , isArray = _a . isArray , actionValue = _a . actionValue , result = _a . result , page = _a . page , task = _a . task ;
6
6
if ( result . pages [ page ] . tasks [ task ] [ type ] === undefined ) {
7
7
result . pages [ page ] . tasks [ task ] [ type ] = [ ] ;
8
8
}
9
- var current = result . pages [ page ] . tasks [ task ] [ type ] ;
9
+ var current = new Set ( result . pages [ page ] . tasks [ task ] [ type ] ) ;
10
10
if ( ! ! isArray ) {
11
- var values_1 = cleanup_1 . trimArray ( actionValue ) ;
12
- values_1 . forEach ( function ( value ) {
13
- if ( current . indexOf ( value ) === - 1 && values_1 . indexOf ( value ) === - 1 ) {
14
- result . pages [ page ] . tasks [ task ] [ type ] . push ( value ) ;
15
- }
11
+ var values = cleanup_1 . trimArray ( actionValue ) ;
12
+ values . forEach ( function ( v ) {
13
+ current . add ( v ) ;
16
14
} ) ;
17
15
}
18
16
else {
19
- if ( current . indexOf ( actionValue ) === - 1 ) {
20
- result . pages [ page ] . tasks [ task ] [ type ] . push ( actionValue ) ;
21
- }
17
+ current . add ( actionValue ) ;
22
18
}
19
+ result . pages [ page ] . tasks [ task ] [ type ] = Array . from ( current ) ;
23
20
return result ;
24
21
}
25
- function addToTasks ( result , line , index ) {
22
+ function addToTasks ( _a ) {
23
+ var result = _a . result , line = _a . line , _b = _a . index , page = _b . page , task = _b . task ;
26
24
var action = match_1 . isAction ( line ) ;
27
- var page = index . page , task = index . task ;
28
25
var currentTask = result . pages [ page ] . tasks [ task ] ;
29
26
var trimmedContent = line . slice ( action . length + 2 , line . length - 1 ) ;
30
27
var actionValue = cleanup_1 . trimQuotes ( trimmedContent ) ;
31
28
var isActionArray = match_1 . isArray ( cleanup_1 . trimQuotes ( actionValue ) ) ;
32
29
switch ( action ) {
33
30
case 'test' :
34
- result = doAction ( 'tests' , isActionArray , actionValue , result , line , index ) ;
31
+ result = doAction ( {
32
+ type : 'tests' ,
33
+ isArray : isActionArray ,
34
+ actionValue : actionValue ,
35
+ result : result ,
36
+ page : page ,
37
+ task : task ,
38
+ } ) ;
35
39
break ;
36
40
case 'hint' :
37
- result = doAction ( 'hints' , isActionArray , actionValue , result , line , index ) ;
41
+ result = doAction ( {
42
+ type : 'hints' ,
43
+ isArray : isActionArray ,
44
+ actionValue : actionValue ,
45
+ result : result ,
46
+ page : page ,
47
+ task : task ,
48
+ } ) ;
38
49
break ;
39
50
case 'continue' :
40
51
break ;
@@ -44,8 +55,8 @@ function addToTasks(result, line, index) {
44
55
}
45
56
if ( ! ! isActionArray ) {
46
57
var arrayOfActions = JSON . parse ( isActionArray ) ;
47
- arrayOfActions . forEach ( function ( value ) {
48
- value = cleanup_1 . trimCommandValue ( cleanup_1 . trimQuotes ( value . trim ( ) ) ) ;
58
+ arrayOfActions . forEach ( function ( v ) {
59
+ var value = cleanup_1 . trimCommandValue ( cleanup_1 . trimQuotes ( v . trim ( ) ) ) ;
49
60
result . pages [ page ] . tasks [ task ] . actions . push ( value ) ;
50
61
} ) ;
51
62
}
0 commit comments