{"id":28469228,"url":"https://github.com/elzup/peeler","last_synced_at":"2025-07-01T15:32:19.972Z","repository":{"id":32636699,"uuid":"138532384","full_name":"elzup/peeler","owner":"elzup","description":"parser for only bracket.","archived":false,"fork":false,"pushed_at":"2025-07-01T00:53:50.000Z","size":687,"stargazers_count":3,"open_issues_count":7,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-01T01:38:49.980Z","etag":null,"topics":["bootstrap","brackets","nest","parser","syntax","tree"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elzup.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-06-25T02:09:13.000Z","updated_at":"2025-07-01T00:52:51.000Z","dependencies_parsed_at":"2023-01-14T21:47:31.853Z","dependency_job_id":"8e8ba88a-5dbe-417d-9afd-1cdd0fdca14b","html_url":"https://github.com/elzup/peeler","commit_stats":{"total_commits":154,"total_committers":4,"mean_commits":38.5,"dds":0.538961038961039,"last_synced_commit":"d6c8498e4ea11605007718c9d45911a3aa20c74b"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/elzup/peeler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elzup%2Fpeeler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elzup%2Fpeeler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elzup%2Fpeeler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elzup%2Fpeeler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elzup","download_url":"https://codeload.github.com/elzup/peeler/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elzup%2Fpeeler/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262881391,"owners_count":23378888,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bootstrap","brackets","nest","parser","syntax","tree"],"created_at":"2025-06-07T08:30:57.190Z","updated_at":"2025-07-01T15:32:19.962Z","avatar_url":"https://github.com/elzup.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# peeler [![npm version](https://badge.fury.io/js/elzup.svg)](https://badge.fury.io/js/elzup) ![GitHub Actions](https://github.com/elzup/peeler/workflows/Node%20CI/badge.svg)\n\n[![NPM](https://nodei.co/npm/peeler.png)](https://nodei.co/npm/peeler/)\n\n\u003e parser for only bracket.\n\n## Install\n\n```\n$ npm install peeler\n$ yarn add peeler\n```\n\n## Usage\n\n```js\nimport peeler from 'peeler'\n```\n\n```js\npeeler('before(hit)after')\n[ { nodeType: 'text',\n    pos: { start: 0, end: 6, depth: 0 },\n    content: 'before' },\n  { nodeType: 'bracket',\n    pos: { start: 6, end: 10, depth: 0 },\n    open: '(',\n    close: ')',\n    nodes:\n     [ { nodeType: 'text',\n         pos: { start: 7, end: 10, depth: 1 },\n         content: 'hit' } ] },\n  { nodeType: 'text',\n    pos: { start: 11, end: 16, depth: 0 },\n    content: 'after' } ]\n```\n\n```js\npeeler('aa(bb{cc}bb)aa')\n[ { nodeType: 'text',\n    pos: { start: 0, end: 2, depth: 0 },\n    content: 'aa' },\n  { nodeType: 'bracket',\n    pos: { start: 2, end: 11, depth: 0 },\n    open: '(',\n    close: ')',\n    nodes:\n     [ { nodeType: 'text',\n         pos: { start: 3, end: 5, depth: 1 },\n         content: 'bb' },\n       { nodeType: 'bracket',\n         pos: { start: 5, end: 8, depth: 1 },\n         open: '{',\n         close: '}',\n         nodes:\n          [ { nodeType: 'text',\n              pos: { start: 6, end: 8, depth: 2 },\n              content: 'cc' } ] },\n       { nodeType: 'text',\n         pos: { start: 9, end: 11, depth: 1 },\n         content: 'bb' } ] },\n  { nodeType: 'text',\n    pos: { start: 12, end: 14, depth: 0 },\n    content: 'aa' } ]\n```\n\n## API\n\n### peeler(name, [option])\n\n#### input\n\nType: `string`\n\ntext to parse.\n\n#### return\n\nType: PNode[]\n\n```\ntype PNode = PNodeText | PNodeBracket\ntype PNodeText = {\n  nodeType: 'text',     // plain text part\n  content: string,  // innerText\n  pos: {\n    start: number,    // position of text\n    end: number,\n    depth: number,    // nest count\n  }\n}\n\ntype PNodeBracket = {\n  nodeType: 'bracket',\n  open: string,     // bracket charactor\n  close: string,\n  nodes: PNode[],   // children nodes\n  pos: {\n    start: number,\n    end: number,\n    depth: number,\n  },\n}\n```\n\n### pair option\n\ndefault `['()', '{}', '[]']`\n\n```js\n\u003e peeler('[(__)]', { pairs: ['[]', '\u003c\u003e'] }) // skip '(' bracket\n[ { nodeType: 'bracket',\n    pos: { start: 0, end: 5, depth: 0 },\n    open: '[',\n    close: ']',\n    nodes:\n     [ { nodeType: 'text',\n         pos: { start: 1, end: 5, depth: 1 },\n         content: '(__)' } ] } ]\n```\n\n### quotes option\n\ndefault `[]`\n\n```js\n\u003e peeler(`( \u003c escape [[( \u003e \" ' \\\\\" \" )`, {\n    quotes: [ `\"`, `'`, `\u003c\u003e`, /* pair enable */ ],\n  })\n\n[ { nodeType: 'bracket',\n    open: '(',\n    close: ')',\n    nodes:\n      [ { nodeType: 'text',\n          pos: { start: 1, end: 26, depth: 1 },\n          content: ` \u003c escape [[( \u003e \" ' \\\\\" \" ` } ],\n    pos: { start: 0, depth: 0, end: 26 },\n    content: `( \u003c escape [[( \u003e \" ' \\\\\" \" )`,\n    innerContent: ` \u003c escape [[( \u003e \" ' \\\\\" \" ` } ]\n```\n\n### default Options\n\n```\nconst defaultOptions: Options = {\n  pairs: ['()', '{}', '[]'],\n  nestMax: 100,\n  escape: '\\\\',\n  includeEmpty: false,\n  quotes: [],\n}\n```\n\n## more example\n\n```js\nimport peeler from '.'\nimport type { PNode } from './types'\n\nconst print = (node: PNode) =\u003e {\n  const nest = '- '.repeat(node.pos.depth)\n  if (node.nodeType === 'text') {\n    console.log(nest + node.content)\n    return\n  } else {\n    console.log(nest + node.open)\n    node.nodes.map(print)\n    console.log(nest + node.close)\n  }\n}\n\npeeler(`(hello(world(\\\\\\\\('ω'\\\\)/){[A](B)}))`).map(print)\n```\n\n```\n(\n- hello\n- (\n- - world\n- - (\n- - - \\('ω')/\n- - )\n- - {\n- - - [\n- - - - A\n- - - ]\n- - - (\n- - - - B\n- - - )\n- - }\n- )\n)\n```\n\n## Related works\n\n- [texter](https://github.com/elzup/texter)\n\n## License\n\nMIT © [elzup](https://elzup.com)\n\n## Contributors\n\nThanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore --\u003e\n| [\u003cimg src=\"https://avatars3.githubusercontent.com/u/2284908?v=4\" width=\"100px;\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eelzup\u003c/b\u003e\u003c/sub\u003e](https://elzup.com)\u003cbr /\u003e[💻](https://github.com/elzup/peeler/commits?author=elzup \"Code\") [⚠️](https://github.com/elzup/peeler/commits?author=elzup \"Tests\") |\n| :---: |\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\nThis project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felzup%2Fpeeler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felzup%2Fpeeler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felzup%2Fpeeler/lists"}