Skip to content

Commit ca2a026

Browse files
committed
add some dry to clean-up
1 parent e7304be commit ca2a026

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

Diff for: src/transform/transformResult.ts

+17-16
Original file line numberDiff line numberDiff line change
@@ -224,14 +224,7 @@ function processCompleted(
224224
incremental.push(incrementalResult);
225225
}
226226

227-
context.pendingResultsById.delete(completedResult.id);
228-
const path = pendingResult.path.join('.');
229-
const labels = context.pendingLabelsByPath.get(path);
230-
invariant(labels != null);
231-
labels.delete(label);
232-
if (labels.size === 0) {
233-
context.pendingLabelsByPath.delete(path);
234-
}
227+
deletePendingResult(context, pendingResult, label);
235228
continue;
236229
}
237230

@@ -283,18 +276,26 @@ function processCompleted(
283276

284277
incremental.push(incrementalResult);
285278

286-
context.pendingResultsById.delete(completedResult.id);
287-
const path = pendingResult.path.join('.');
288-
const labels = context.pendingLabelsByPath.get(path);
289-
invariant(labels != null);
290-
labels.delete(label);
291-
if (labels.size === 0) {
292-
context.pendingLabelsByPath.delete(path);
293-
}
279+
deletePendingResult(context, pendingResult, label);
294280
}
295281
return incremental;
296282
}
297283

284+
function deletePendingResult(
285+
context: TransformationContext,
286+
pendingResult: PendingResult,
287+
label: string,
288+
): void {
289+
context.pendingResultsById.delete(pendingResult.id);
290+
const path = pendingResult.path.join('.');
291+
const labels = context.pendingLabelsByPath.get(path);
292+
invariant(labels != null);
293+
labels.delete(label);
294+
if (labels.size === 0) {
295+
context.pendingLabelsByPath.delete(path);
296+
}
297+
}
298+
298299
function transformInitialResult<
299300
T extends ExecutionResult | InitialIncrementalExecutionResult,
300301
>(context: TransformationContext, result: T): T {

0 commit comments

Comments
 (0)