11"use strict" ;
22var cleanup_1 = require ( './cleanup' ) ;
33var 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 ;
66 if ( result . pages [ page ] . tasks [ task ] [ type ] === undefined ) {
77 result . pages [ page ] . tasks [ task ] [ type ] = [ ] ;
88 }
9- var current = result . pages [ page ] . tasks [ task ] [ type ] ;
9+ var current = new Set ( result . pages [ page ] . tasks [ task ] [ type ] ) ;
1010 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 ) ;
1614 } ) ;
1715 }
1816 else {
19- if ( current . indexOf ( actionValue ) === - 1 ) {
20- result . pages [ page ] . tasks [ task ] [ type ] . push ( actionValue ) ;
21- }
17+ current . add ( actionValue ) ;
2218 }
19+ result . pages [ page ] . tasks [ task ] [ type ] = Array . from ( current ) ;
2320 return result ;
2421}
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 ;
2624 var action = match_1 . isAction ( line ) ;
27- var page = index . page , task = index . task ;
2825 var currentTask = result . pages [ page ] . tasks [ task ] ;
2926 var trimmedContent = line . slice ( action . length + 2 , line . length - 1 ) ;
3027 var actionValue = cleanup_1 . trimQuotes ( trimmedContent ) ;
3128 var isActionArray = match_1 . isArray ( cleanup_1 . trimQuotes ( actionValue ) ) ;
3229 switch ( action ) {
3330 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+ } ) ;
3539 break ;
3640 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+ } ) ;
3849 break ;
3950 case 'continue' :
4051 break ;
@@ -44,8 +55,8 @@ function addToTasks(result, line, index) {
4455 }
4556 if ( ! ! isActionArray ) {
4657 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 ( ) ) ) ;
4960 result . pages [ page ] . tasks [ task ] . actions . push ( value ) ;
5061 } ) ;
5162 }
0 commit comments