From 4fd26bbe91eaf2fe7fa25294ef354ba25ae67b13 Mon Sep 17 00:00:00 2001 From: Alessio Gravili Date: Mon, 20 Jan 2025 22:48:27 -0700 Subject: [PATCH] perf: less array.include calls --- packages/lexical-markdown/src/MarkdownExport.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/packages/lexical-markdown/src/MarkdownExport.ts b/packages/lexical-markdown/src/MarkdownExport.ts index 55a9a6caa66..ea6d3ef700d 100644 --- a/packages/lexical-markdown/src/MarkdownExport.ts +++ b/packages/lexical-markdown/src/MarkdownExport.ts @@ -44,13 +44,9 @@ export function createMarkdownExport( // code will be exported as `**Bold Code**`, as the code format will be applied first, and the bold format // will be applied second and thus skipped entirely, as the code format will prevent any further formatting. .sort((a, b) => { - if (a.format.includes('code') && !b.format.includes('code')) { - return 1; - } else if (!a.format.includes('code') && b.format.includes('code')) { - return -1; - } else { - return 0; - } + return ( + Number(a.format.includes('code')) - Number(b.format.includes('code')) + ); }); return (node) => {