{"id":15782226,"url":"https://github.com/himanoa/parser-combinator","last_synced_at":"2025-03-31T16:36:47.637Z","repository":{"id":97525363,"uuid":"542736173","full_name":"himanoa/parser-combinator","owner":"himanoa","description":null,"archived":false,"fork":false,"pushed_at":"2022-10-16T14:50:34.000Z","size":54,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-24T00:37:34.300Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/himanoa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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}},"created_at":"2022-09-28T18:27:29.000Z","updated_at":"2022-10-16T23:23:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"45886f87-0797-415b-919e-8999d69bb7b3","html_url":"https://github.com/himanoa/parser-combinator","commit_stats":{"total_commits":50,"total_committers":1,"mean_commits":50.0,"dds":0.0,"last_synced_commit":"c368a3af9210bc1e121422d8a2eedc7dc49e0739"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/himanoa%2Fparser-combinator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/himanoa%2Fparser-combinator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/himanoa%2Fparser-combinator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/himanoa%2Fparser-combinator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/himanoa","download_url":"https://codeload.github.com/himanoa/parser-combinator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246498930,"owners_count":20787422,"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":[],"created_at":"2024-10-04T19:04:33.552Z","updated_at":"2025-03-31T16:36:47.619Z","avatar_url":"https://github.com/himanoa.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @himanoa/parser-combinator\n\nparser-combinator library for typescript\n\n## Install\n\n### npm\n\n`npm i @himanoa/parser-combinator`\n\n## Example\n\n```typescript\nimport { choice, createParser, map, str } from \"@himanoa/parser-combinator\";\n\nconst booleanSymbol = choice([\n  map(str(\"true\"), () =\u003e true),\n  map(str(\"false\"), () =\u003e false),\n]);\n\nconst parser = createParser(booleanSymbol);\n\nconst trueResult = parser(\"true\");\n\nconsole.log(trueResult.kind === \"success\" ? trueResult.value : \"failed parse\");\nconsole.log(trueResult.kind === \"success\" ? trueResult.value : \"failed parse\");\n\nconst falseResult = parser(\"false\");\n\nconsole.log(\n  falseResult.kind === \"success\" ? falseResult.value : \"failed parse\",\n);\nconsole.log(\n  falseResult.kind === \"success\" ? falseResult.value : \"failed parse\",\n);\n\nconst failedResult = parser(\"asdfasdf\");\n\nconsole.log(\n  failedResult.kind === \"success\" ? failedResult.value : \"failed parse\",\n);\nconsole.log(\n  failedResult.kind === \"success\" ? failedResult.value : \"failed parse\",\n);\n```\n\n## API\n\n- anyChar: Parse any token\n- eof: Parse eof token\n- char: Parse `c` token\n- choice: Parse any one matching token from multiple parsers\n- count: Parse parser from zero up to count times\n- and: Parse all parsers\n- many: Parse parser from zero or more tiems returning a Array with the values\n  from p\n- many1: Parse parser from one or more tiems returning a Array with the values\n  from p\n- str: Parse many char token\n- countMinMax: Parse parser from min to max times\n- map: convert `value` when parse success\n- mapErr: convert `expected` when parse failed\n- surround: Parse open followed by parser followed by close\n- not: Reverse parser result\n- skip: Crush parse results with never\n- satisfy: Parses a token and succeeds depending on the result of predicate\n- optional: Parse a token and return a or null. Return null when failed parse.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhimanoa%2Fparser-combinator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhimanoa%2Fparser-combinator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhimanoa%2Fparser-combinator/lists"}