From abe49d49c24792be84030bd4cb78f203f45c8f6d Mon Sep 17 00:00:00 2001 From: Ean Milligan Date: Tue, 1 Jul 2025 02:18:38 -0400 Subject: [PATCH] add group balance checker --- src/artigen/utils/parenBalance.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/artigen/utils/parenBalance.ts b/src/artigen/utils/parenBalance.ts index 2b4fc1a..1e208c7 100644 --- a/src/artigen/utils/parenBalance.ts +++ b/src/artigen/utils/parenBalance.ts @@ -53,10 +53,12 @@ const checkBalance = (conf: MathConf[], openStr: string, closeStr: string, error }; // assertXBalance verifies the entire conf has balanced X +export const assertGroupBalance = (conf: MathConf[]) => checkBalance(conf, '{', '}', 'Group', false, 0); export const assertParenBalance = (conf: MathConf[]) => checkBalance(conf, '(', ')', 'Paren', false, 0); export const assertPrePostBalance = (conf: MathConf[]) => checkBalance(conf, config.prefix, config.postfix, 'PrefixPostfix', false, 0); // getMatchingXIdx gets the matching X, also partially verifies the conf has balanced X +export const getMatchingGroupId = (conf: MathConf[], openIdx: number): number => checkBalance(conf, '{', '}', 'Group', true, openIdx); export const getMatchingInternalId = (conf: MathConf[], openIdx: number): number => checkBalance(conf, openInternal, closeInternal, 'Internal', true, openIdx); export const getMatchingParenId = (conf: MathConf[], openIdx: number): number => checkBalance(conf, '(', ')', 'Paren', true, openIdx); export const getMatchingPostfixId = (conf: MathConf[], openIdx: number): number => checkBalance(conf, config.prefix, config.postfix, 'PrefixPostfix', true, openIdx);