Skip to content

Commit feb43a1

Browse files
committed
Update canvas.ts
1 parent a3cc842 commit feb43a1

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

packages/scan/src/new-outlines/canvas.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,11 @@ const TOTAL_FRAMES = 45;
1616
const PRIMARY_COLOR = '115,97,230';
1717
// const SECONDARY_COLOR = '128,128,128';
1818

19-
function getLabelTextPart(
20-
partsEntries: [number, string[]][],
21-
partsLength: number,
22-
index: number,
23-
): string {
24-
const [count, names] = partsEntries[index];
19+
function getLabelTextPart([count, names]: [number, string[]]): string {
2520
let part = `${names.slice(0, MAX_PARTS_LENGTH).join(', ')} ×${count}`;
2621
if (part.length > MAX_LABEL_LENGTH) {
2722
part = `${part.slice(0, MAX_LABEL_LENGTH)}…`;
2823
}
29-
if (index !== partsLength - 1) {
30-
part += ', ';
31-
}
3224
return part;
3325
}
3426

@@ -52,10 +44,9 @@ export const getLabelText = (outlines: ActiveOutline[]): string => {
5244
const partsEntries = Array.from(countByNames.entries()).sort(
5345
([countA], [countB]) => countB - countA,
5446
);
55-
const partsLength = partsEntries.length;
56-
let labelText = getLabelTextPart(partsEntries, partsLength, 0);
57-
for (let i = 1; i < partsLength; i++) {
58-
labelText += getLabelTextPart(partsEntries, partsLength, i);
47+
let labelText = getLabelTextPart(partsEntries[0]);
48+
for (let i = 1, len = partsEntries.length; i < len; i++) {
49+
labelText += ', ' + getLabelTextPart(partsEntries[i]);
5950
}
6051

6152
if (labelText.length > MAX_LABEL_LENGTH) {

0 commit comments

Comments
 (0)