File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed
Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -13,17 +13,15 @@ export type WorkflowConfig = {
1313export class Workflow {
1414 private readonly _name : string ;
1515 private readonly _config : WorkflowConfig ;
16- private readonly _jobs : Record < string , Job > = { } ;
16+ private readonly _jobs : Job [ ] = [ ] ;
1717
1818 public constructor ( name : string , config : WorkflowConfig ) {
1919 this . _name = name ;
2020 this . _config = config ;
2121 }
2222
2323 public addJob ( ...jobs : Job [ ] ) : Workflow {
24- for ( const job of jobs ) {
25- this . _jobs [ job . id ] = job ;
26- }
24+ this . _jobs . push ( ...jobs ) ;
2725 return this ;
2826 }
2927
@@ -40,9 +38,10 @@ export class Workflow {
4038
4139 concurrency : concurrencyJSON ( this . _config . concurrency ) ,
4240
43- jobs : Object . fromEntries (
44- Object . entries ( this . _jobs ) . map ( ( [ name , job ] ) => [ name , job . toJSON ( ) ] ) ,
45- ) ,
41+ jobs : this . _jobs . reduce < Record < string , unknown > > ( ( acc , job ) => {
42+ acc [ job . id ] = job . toJSON ( ) ;
43+ return acc ;
44+ } , { } ) ,
4645 } ;
4746 }
4847}
You can’t perform that action at this time.
0 commit comments