
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
bracket-match
Advanced tools
一个轻量级括号匹配工具,用于在代码或文本中查找匹配的括号/括号对,支持自定义括号类型和多字符括号。
(), [], {}, <>, 甚至多字符括号)npm install bracket-match
import { bracketMatch } from 'bracket-match';
// 定义括号列表(每个对象包含left和right属性)
const bracketList = [
{ left: '((', right: ')' }, // 多字符左括号
{ left: '(', right: '))' }, // 多字符右括号
{ left: '(((', right: ')))' } // 对称多字符括号
];
// 查找左括号匹配
const result = bracketMatch({
bracketList,
rowIndex: 0, // 起始行索引
bracketString: '(' // 要查找的括号字符串
});
console.log(result);
// {
// balanced: false,
// leftRowIndex: 0,
// rightRowIndex: 0,
// leftBracketIndex: 1,
// rightBracketIndex: 0
// }
bracketMatch(options)
Object | null - 匹配结果对象(未找到时返回null),包含:
const bracketList = [
{ left: '((', right: ')' },
{ left: '(', right: '))' }
];
// 查找第0行的"(( "(完整左括号)
const result = bracketMatch({
bracketList,
rowIndex: 0,
bracketString: '(('
});
console.log(result);
// {
// balanced: true,
// leftRowIndex: 0,
// rightRowIndex: 1,
// leftBracketIndex: 0,
// rightBracketIndex: 1
// }
const bracketList = [
{ left: '((', right: ')' },
{ left: '(', right: '))' }
];
// 查找第1行的"))"(完整右括号)
const result = bracketMatch({
bracketList,
rowIndex: 1,
bracketString: '))'
});
console.log(result);
// {
// balanced: true,
// leftRowIndex: 0,
// rightRowIndex: 1,
// leftBracketIndex: 0,
// rightBracketIndex: 1
// }
项目包含基础测试用例,可通过以下命令运行:
npm test
FAQs
A utility to match brackets/parentheses in code or text
We found that bracket-match demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.