Skip to content

Commit a526ce0

Browse files
committed
refactor(pptx): issue paths without a nested ternary
1 parent 13e5cfc commit a526ce0

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

‎packages/pptx/src/deck.ts‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,12 +199,13 @@ export function slideRegions(slide: Slide) {
199199

200200
type Path = (string | number)[];
201201

202-
const pathString = (path: Path) =>
203-
path
204-
.map((key, index) =>
205-
typeof key === "number" ? `[${key}]` : index === 0 ? key : `.${key}`,
206-
)
207-
.join("");
202+
function pathKey(key: string | number, index: number) {
203+
if (typeof key === "number") return `[${key}]`;
204+
if (index === 0) return key;
205+
return `.${key}`;
206+
}
207+
208+
const pathString = (path: Path) => path.map(pathKey).join("");
208209

209210
function issueAt(path: Path, message: string): DeckIssue {
210211
const [, slide] = path;

0 commit comments

Comments
 (0)