Package Exports
- node-balanced
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (node-balanced) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Balanced
balanced string matching, and replacing.
install
npm install node-balanced
example time
lets say you have
{
@hello 1 {
a {
b {
c {
}
}
}
}
@hello 2 {
a {
b {
c {
}
}
}
}
@hello 3 {
a {
b {
c {
}
}
}
}
}
and you would like to replace the @hello block easily, balanced allows you to do this
var balanced = require('node-balanced');
balanced.replacements({
source: source,
start: /@hello \d \{/,
right: '{',
left: '}',
replace: function (source, opening, closing) {
return opening + source + closing;
}
});
this is a simple and efficient way to make balanced replacements, without a parser.
matching
you can get balanced matches by doing the following
var balanced = require('node-balanced');
balanced.matches({
source: source,
start: /@hello \d \{/,
right: '{',
left: '}'
});