Skip to content

Commit 5e2a4dc

Browse files
committed
chore: refactor
1 parent 4063f1b commit 5e2a4dc

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

lib/package/workflow.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,15 @@ export type WorkflowConfig = {
1313
export 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
}

0 commit comments

Comments
 (0)