Skip to content

Commit

Permalink
Replace reduce with more exact methods
Browse files Browse the repository at this point in the history
  • Loading branch information
FyreByrd committed Feb 4, 2025
1 parent c8552e8 commit dc730ce
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export async function createMany(projectData: RequirePrimitive<Prisma.ProjectsCr
await Promise.all(
projectData.map((pd) => validateProjectBase(pd.OrganizationId, pd.GroupId, pd.OwnerId))
)
).reduce((p, c) => p && c, true);
).every((p) => p);

try {
if (valid) {
Expand Down
5 changes: 1 addition & 4 deletions source/SIL.AppBuilder.Portal/common/workflow/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,12 @@ export class Workflow {
};
}),
inCount: states
.map(([k, v]) => {
.flatMap(([k, v]) => {
return Workflow.filterTransitions(v.on, this.config).map((e) => {
// treat no target on transition as self target
return { from: k, to: Workflow.targetStringFromEvent(e[0]) || k };
});
})
.reduce((p, c) => {
return p.concat(c);
}, [])
.filter((v) => k === v.to).length,
start: k === WorkflowState.Start,
final: v.type === 'final'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,8 @@
resetForm: false
});
let positions: { [key: string]: Springy.Physics.Vector } = $state(
data.machine
.map((s) => {
return { key: s.label, value: new Springy.Physics.Vector(0.0, 0.0) };
})
.reduce(
(p, c) => {
p[c.key] = c.value;
return p;
},
{} as { [key: string]: Springy.Physics.Vector }
)
let positions: Record<string, Springy.Physics.Vector> = $state(
Object.fromEntries(data.machine.map((s) => [s.label, new Springy.Physics.Vector(0.0, 0.0)]))
);
let ready = $state(false);
Expand All @@ -44,11 +34,9 @@
const graph = new Springy.Graph();
graph.loadJSON({
nodes: data.machine.map((s) => s.label),
edges: data.machine
.map((s) => {
return s.connections.map((c) => [s.label, c.target]);
})
.reduce((p, c) => p.concat(c), [])
edges: data.machine.flatMap((s) => {
return s.connections.map((c) => [s.label, c.target]);
})
});
const bounds = Math.ceil(Math.sqrt(graph.nodes.length));
graph.addNodeData('Start', {
Expand Down

0 comments on commit dc730ce

Please sign in to comment.