Gathering detailed insights and metrics for balanced-match
Gathering detailed insights and metrics for balanced-match
Gathering detailed insights and metrics for balanced-match
Gathering detailed insights and metrics for balanced-match
@types/balanced-match
TypeScript definitions for balanced-match
balanced-match-all
Recursively match balanced string pairs, like { and } or <b> and </b> using balanced-match and add level information to the matches.
@retypes/balanced-match
Packaged ReasonML bindings for balanced-match
@teamteanpm2024/quam-magnam-animi
security holding package
npm install balanced-match
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
125 Stars
113 Commits
39 Forks
6 Watchers
1 Branches
15 Contributors
Updated on Nov 01, 2024
Latest Version
3.0.1
Package Id
balanced-match@3.0.1
Unpacked Size
12.04 kB
Size
4.63 kB
File Count
5
NPM Version
9.6.7
Node Version
20.3.1
Published on
Oct 07, 2023
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
4
Match balanced string pairs, like {
and }
or <b>
and </b>
. Supports regular expressions as well!
Get the first matching pair of braces:
1import balanced from 'balanced-match' 2 3console.log(balanced('{', '}', 'pre{in{nested}}post')) 4console.log(balanced('{', '}', 'pre{first}between{second}post')) 5console.log(balanced(/\s+\{\s+/, /\s+\}\s+/, 'pre { in{nest} } post'))
The matches are:
1$ node example.js 2{ start: 3, end: 14, pre: 'pre', body: 'in{nested}', post: 'post' } 3{ start: 3, 4 end: 9, 5 pre: 'pre', 6 body: 'first', 7 post: 'between{second}post' } 8{ start: 3, end: 17, pre: 'pre', body: 'in{nest}', post: 'post' }
For the first non-nested matching pair of a
and b
in str
, return an
object with those keys:
a
b
a
and b
not includeda
and b
not includeda
and b
not includedIf there's no match, undefined
will be returned.
If the str
contains more a
than b
/ there are unmatched pairs, the first match that was closed will be used. For example, {{a}
will match ['{', 'a', '']
and {a}}
will match ['', 'a', '}']
.
For the first non-nested matching pair of a
and b
in str
, return an
array with indexes: [ <a index>, <b index> ]
.
If there's no match, undefined
will be returned.
If the str
contains more a
than b
/ there are unmatched pairs, the first match that was closed will be used. For example, {{a}
will match [ 1, 3 ]
and {a}}
will match [0, 2]
.
With npm do:
1npm install balanced-match
To report a security vulnerability, please use the Tidelift security contact. Tidelift will coordinate the fix and disclosure.
(MIT)
Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
4 existing vulnerabilities detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
Found 4/19 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More