Skip to content

Commit

Permalink
add more b than a use case
Browse files Browse the repository at this point in the history
  • Loading branch information
stevemao committed Jul 17, 2016
1 parent 86c146d commit 0cd4299
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -47,7 +47,7 @@ object with those keys:
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 `['{', 'a', '']`.
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', '}']`.
### var r = balanced.range(a, b, str)
Expand All @@ -56,7 +56,7 @@ 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 ]`.
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]`.
## Installation
Expand Down
7 changes: 7 additions & 0 deletions test/balanced.js
Expand Up @@ -23,6 +23,13 @@ test('balanced', function(t) {
body: 'in',
post: 'post'
});
t.deepEqual(balanced('{', '}', 'pre{in}po}st'), {
start: 3,
end: 6,
pre: 'pre',
body: 'in',
post: 'po}st'
});
t.deepEqual(balanced('{', '}', 'pre}{in{nest}}post'), {
start: 4,
end: 13,
Expand Down

0 comments on commit 0cd4299

Please sign in to comment.