![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
find-matching-bracket
Advanced tools
Find matching bracket in Js/Ts/Cs code (including string Template literals interpolation)
Find matching bracket in Js/Ts/Cs code (including string Template literals interpolation)
/**
* if throwErrors is true, it throw (stop) with info.
* else it return matching position,
* or:
* -2 if startPostion don't match start bracket
* -3 if end bracket dont match start bracket
* -1 if cursor comes to end of code without finding maching bracket
*
* @param code
* @param startPosition position for staing bracket
* @param throwErrors default false - if true: throw error with information
* @returns
*/
export default function matchBracket(code: string, startPosition: number, throwErrors = false): number;
matchBracket example:
const code = "{ }";
const endPosition = matchBracket(code, 0);
// endPosition = 2
Complex ex:
const code =
"function foo(s: string) {\n" + // <- start pos 24
" var str = `text with repeat ${new Array(2).fill(s).map(s=>{ return s + '-{}-' }).join('')} ends here `;\n" +
" return { return: str }\n" +
"}"; // <- return this position 160 (What we need to find!)
const endPosition = matchBracket(code, 24);
// endPosition = 160
const includeBoth = code.substring(24, 161); // 160+1 to include the end bracket
const excludeBoth = code.substring(25, 160); // 24+1 to exclude start bracket
Bracket that can be matchs:
${
and $"
can only be matched inside string templates (js an cs templates)
Matching bracket:
name | start | end | node |
---|---|---|---|
lineComment | // | \n | |
multilineComment | /* | */ | |
angle | < | > | |
peparentheses | ( | ) | |
square | [ | ] | |
curly | { | } | |
double | " | " | |
single | ' | ' | |
jsTemplate | ` | ` | |
cSharpTemplate | $" | " | |
escapeJsTemaple | ${ | } | only in jsTemplate |
inCSharpTemaple | { | } | only in cSharpTemplate |
FAQs
Find matching bracket in Js/Ts/Cs code (including string Template literals interpolation)
We found that find-matching-bracket demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.