{"name":"balanced-match","description":"Match balanced character pairs, like \"{\" and \"}\"","version":"4.0.4","repository":{"type":"git","url":"git://github.com/juliangruber/balanced-match.git"},"exports":{"./package.json":"./package.json",".":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"require":{"types":"./dist/commonjs/index.d.ts","default":"./dist/commonjs/index.js"}}},"type":"module","scripts":{"preversion":"npm test","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags","prepare":"tshy","pretest":"npm run prepare","presnap":"npm run prepare","test":"tap","snap":"tap","format":"prettier --write .","benchmark":"node benchmark/index.js","typedoc":"typedoc --tsconfig .tshy/esm.json ./src/*.ts"},"devDependencies":{"@types/brace-expansion":"^1.1.2","@types/node":"^25.2.1","mkdirp":"^3.0.1","prettier":"^3.3.2","tap":"^21.6.2","tshy":"^3.0.2","typedoc":"^0.28.5"},"keywords":["match","regexp","test","balanced","parse"],"license":"MIT","engines":{"node":"18 || 20 || >=22"},"tshy":{"exports":{"./package.json":"./package.json",".":"./src/index.ts"}},"main":"./dist/commonjs/index.js","types":"./dist/commonjs/index.d.ts","module":"./dist/esm/index.js","_id":"balanced-match@4.0.4","gitHead":"adf286f7c6142102f932c8d7c7066463741a0036","bugs":{"url":"https://github.com/juliangruber/balanced-match/issues"},"homepage":"https://github.com/juliangruber/balanced-match#readme","_nodeVersion":"22.14.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==","shasum":"bfb10662feed8196a2c62e7c68e17720c274179a","tarball":"http://registry-npm.ywwl.com/balanced-match/download/balanced-match-4.0.4.tgz","fileCount":13,"unpackedSize":17584,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDybrxbk42Achkx5R4DEljgHEAByz+vDnfh6X/udxaxOAIgF6eTvZqu76P9yBtJhkA+6G6WCVzu10FhiZVW8swnUic="}],"size":4199,"noattachment":false,"key":"/balanced-match/-/balanced-match-4.0.4.tgz"},"_npmUser":{"name":"juliangruber","email":"julian@juliangruber.com"},"directories":{},"maintainers":[{"name":"juliangruber","email":"julian@juliangruber.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/balanced-match_4.0.4_1771760305795_0.22783138922162038"},"_hasShrinkwrap":false,"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 = balanced.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\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":1771760305951,"_cnpm_publish_time":1771760305951,"dist-tags":{"latest":"5.0.0"}}