{"_id":"balanced-match@5.0.0","bugs":{"url":"https://github.com/juliangruber/balanced-match/issues"},"dist":{"shasum":"5ae883e49b7c8db6516c8f6d781e5a5452b8eac2","tarball":"http://registry-npm.ywwl.com/balanced-match/download/balanced-match-5.0.0.tgz","fileCount":13,"integrity":"sha512-6Gu87QhScJ8cFLMS0Vm8GMeQpG1oOBkh6xlJ2wxUP1FQD1mjV9YLWQFEYy6F3aQwiJQNE/en7KGVea6f8hTMGA==","signatures":[{"sig":"MEUCIQCBlmb7on2AZqR/RwknNKCXq+uKD75+XaFz53pHlon11AIgOba8uzUaRwXH4eHVh8Ah7BYseZ3pPnawnzvqbyWoTC0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCICkNgBeLleK67Gwu3VvbCX3ju/Z1oJrkP4WH2Ynkdf/+AiAVc8mgA+z3E3CQwuNbc0IwtB1E72mcYq6efrcCP5l7gw=="}],"unpackedSize":17854,"size":4212,"noattachment":false,"key":"/balanced-match/-/balanced-match-5.0.0.tgz"},"main":"./dist/commonjs/index.js","name":"balanced-match","tshy":{"exports":{".":"./src/index.ts","./package.json":"./package.json"}},"type":"module","types":"./dist/commonjs/index.d.ts","module":"./dist/esm/index.js","engines":{"node":"20 || >=22"},"exports":{".":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"require":{"types":"./dist/commonjs/index.d.ts","default":"./dist/commonjs/index.js"}},"./package.json":"./package.json"},"gitHead":"d1216d8782c34933a821e71f1bdeaf9a0b40ae31","license":"MIT","scripts":{"snap":"tap","test":"tap","format":"prettier --write .","prepare":"tshy","presnap":"npm run prepare","pretest":"npm run prepare","typedoc":"typedoc --tsconfig .tshy/esm.json ./src/*.ts","benchmark":"node benchmark/index.js","preversion":"npm test","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags"},"version":"5.0.0","_npmUser":{"name":"juliangruber","email":"julian@juliangruber.com"},"homepage":"https://github.com/juliangruber/balanced-match#readme","keywords":["match","regexp","test","balanced","parse"],"repository":{"url":"git://github.com/juliangruber/balanced-match.git","type":"git"},"_npmVersion":"11.13.0","description":"Match balanced character pairs, like \"{\" and \"}\"","directories":{},"maintainers":[{"name":"juliangruber","email":"julian@juliangruber.com"}],"_nodeVersion":"24.16.0","_hasShrinkwrap":false,"devDependencies":{"tap":"^21.6.2","tshy":"^3.0.2","mkdirp":"^3.0.1","typedoc":"^0.28.20","prettier":"^3.3.2","@types/node":"^25.2.1","@types/brace-expansion":"^1.1.2"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/balanced-match_5.0.0_1792171499578_0.4637005414660229"},"readme":"# balanced-match\n\nMatch balanced string pairs, like `{` and `}` or `<b>` and\n`</b>`. Supports regular expressions as well!\n\n## Example\n\nGet the first matching pair of braces:\n\n```js\nimport { balanced } from 'balanced-match'\n\nconsole.log(balanced('{', '}', 'pre{in{nested}}post'))\nconsole.log(balanced('{', '}', 'pre{first}between{second}post'))\nconsole.log(\n  balanced(/\\s+\\{\\s+/, /\\s+\\}\\s+/, 'pre  {   in{nest}   }  post'),\n)\n```\n\nThe matches are:\n\n```bash\n$ node example.js\n{ start: 3, end: 14, pre: 'pre', body: 'in{nested}', post: 'post' }\n{ start: 3,\n  end: 9,\n  pre: 'pre',\n  body: 'first',\n  post: 'between{second}post' }\n{ start: 3, end: 17, pre: 'pre', body: 'in{nest}', post: 'post' }\n```\n\n## API\n\n### const m = balanced(a, b, str)\n\nFor the first non-nested matching pair of `a` and `b` in `str`, return an\nobject with those keys:\n\n- **start** the index of the first match of `a`\n- **end** the index of the matching `b`\n- **pre** the preamble, `a` and `b` not included\n- **body** the match, `a` and `b` not included\n- **post** the postscript, `a` and `b` not included\n\nIf there's no match, `undefined` will be returned.\n\nIf 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', '}']`.\n\n### const r = range(a, b, str)\n\nFor the first non-nested matching pair of `a` and `b` in `str`, return an\narray with indexes: `[ <a index>, <b index> ]`.\n\n```js\nimport { range } from 'balanced-match'\n\nconsole.log(range('{', '}', 'pre{in{nested}}post'))\n// [ 3, 14 ]\n```\n\nIf there's no match, `undefined` will be returned.\n\nIf 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]`.\n","publish_time":1792171499672,"_cnpm_publish_time":1792171499672,"dist-tags":{"latest":"5.0.0"}}