Skip to content

Commit

Permalink
Revert "add prettier-standard"
Browse files Browse the repository at this point in the history
This reverts commit cf6477e.
  • Loading branch information
juliangruber committed Apr 6, 2021
1 parent bf8f782 commit a062cc8
Show file tree
Hide file tree
Showing 7 changed files with 928 additions and 7,386 deletions.
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
@@ -1,2 +1,2 @@
tidelift: 'npm/balanced-match'
tidelift: "npm/balanced-match"
patreon: juliangruber
14 changes: 7 additions & 7 deletions .travis.yml
@@ -1,15 +1,15 @@
language: node_js
node_js:
- '0.12'
- '4'
- '5'
- '6'
- "0.12"
- "4"
- "5"
- "6"

arch:
- amd64
- ppc64le

matrix:
exclude:
- node_js: '0.12'
arch: ppc64le
exclude:
- node_js: "0.12"
arch: ppc64le
18 changes: 9 additions & 9 deletions README.md
Expand Up @@ -12,11 +12,11 @@ Match balanced string pairs, like `{` and `}` or `<b>` and `</b>`. Supports regu
Get the first matching pair of braces:

```js
var balanced = require('balanced-match')
var balanced = require('balanced-match');

console.log(balanced('{', '}', 'pre{in{nested}}post'))
console.log(balanced('{', '}', 'pre{first}between{second}post'))
console.log(balanced(/\s+\{\s+/, /\s+\}\s+/, 'pre { in{nest} } post'))
console.log(balanced('{', '}', 'pre{in{nested}}post'));
console.log(balanced('{', '}', 'pre{first}between{second}post'));
console.log(balanced(/\s+\{\s+/, /\s+\}\s+/, 'pre { in{nest} } post'));
```

The matches are:
Expand All @@ -39,11 +39,11 @@ $ node example.js
For the first non-nested matching pair of `a` and `b` in `str`, return an
object with those keys:
- **start** the index of the first match of `a`
- **end** the index of the matching `b`
- **pre** the preamble, `a` and `b` not included
- **body** the match, `a` and `b` not included
- **post** the postscript, `a` and `b` not included
* **start** the index of the first match of `a`
* **end** the index of the matching `b`
* **pre** the preamble, `a` and `b` not included
* **body** the match, `a` and `b` not included
* **post** the postscript, `a` and `b` not included
If there's no match, `undefined` will be returned.
Expand Down
16 changes: 7 additions & 9 deletions index.js
Expand Up @@ -6,15 +6,13 @@ function balanced (a, b, str) {

const r = range(a, b, str)

return (
r && {
start: r[0],
end: r[1],
pre: str.slice(0, r[0]),
body: str.slice(r[0] + a.length, r[1]),
post: str.slice(r[1] + b.length)
}
)
return r && {
start: r[0],
end: r[1],
pre: str.slice(0, r[0]),
body: str.slice(r[0] + a.length, r[1]),
post: str.slice(r[1] + b.length)
}
}

function maybeMatch (reg, str) {
Expand Down

0 comments on commit a062cc8

Please sign in to comment.