{"id":30180612,"url":"https://github.com/eliassjogreen/deno_tokenizer","last_synced_at":"2025-08-12T08:01:59.440Z","repository":{"id":40483439,"uuid":"207000798","full_name":"denosaurs/tokenizer","owner":"denosaurs","description":"⚙️ A simple tokenizer for deno","archived":false,"fork":false,"pushed_at":"2022-05-05T12:37:32.000Z","size":39,"stargazers_count":16,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-05T20:12:32.856Z","etag":null,"topics":["deno","lexer","tokenizer"],"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/denosaurs.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}},"created_at":"2019-09-07T17:13:37.000Z","updated_at":"2025-02-11T20:46:53.000Z","dependencies_parsed_at":"2022-08-09T21:50:41.323Z","dependency_job_id":null,"html_url":"https://github.com/denosaurs/tokenizer","commit_stats":null,"previous_names":["eliassjogreen/deno_tokenizer"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/denosaurs/tokenizer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denosaurs%2Ftokenizer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denosaurs%2Ftokenizer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denosaurs%2Ftokenizer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denosaurs%2Ftokenizer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/denosaurs","download_url":"https://codeload.github.com/denosaurs/tokenizer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denosaurs%2Ftokenizer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270024697,"owners_count":24514054,"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","status":"online","status_checked_at":"2025-08-12T02:00:09.011Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["deno","lexer","tokenizer"],"created_at":"2025-08-12T08:01:27.847Z","updated_at":"2025-08-12T08:01:59.419Z","avatar_url":"https://github.com/denosaurs.png","language":"TypeScript","funding_links":[],"categories":["Modules","Uncategorized","基础设施"],"sub_categories":["Online Playgrounds","Assistants","Uncategorized","Utils","JAM Stack/静态站点"],"readme":"# Tokenizer [![Badge License]][License]\n\n*A simple **Deno** library*\n\n---\n\n\u003cdiv align = center\u003e\n\n[![Badge Status]][Actions]\n\n\u003c/div\u003e\n\n---\n\n\u003cbr\u003e\n\n## Examples\n\n```js\nimport { Tokenizer } from 'https://deno.land/x/tokenizer/mod.ts';\n\nconst input = 'abc 123 HELLO [a cool](link)';\n\nconst rules = [{ \n    type : 'HELLO' ,\n    pattern : 'HELLO' \n},{ \n    type : 'WORD' ,\n    pattern : /[a-zA-Z]+/ \n},{ \n    type : 'DIGITS' ,\n    pattern : /\\d+/ ,\n    value : m =\u003e Number.parseInt(m.match)\n},{ \n    type : 'LINK' ,\n    pattern : /\\[([^\\[]+)\\]\\(([^\\)]+)\\)/\n},{ \n    type : 'SPACE' , \n    pattern : / / ,\n    ignore: true // Or leave type blank and remove \"ignore: true\"\n}];\n\nconst tokenizer = new Tokenizer(input,rules);\n```\n\n\u003cbr\u003e\n\n### Option A\n\n```js\nconsole.log(...tokenizer);\n```\n\n```\n{ type: \"WORD\", match: \"abc\", value: \"abc\", groups: [], position: { start: 0, end: 3 } },\n{ type: \"DIGITS\", match: \"123\", value: 123, groups: [], position: { start: 4, end: 7 } },\n{ type: \"HELLO\", match: \"HELLO\", value: \"HELLO\", groups: [], position: { start: 8, end: 13 } },\n{ type: \"LINK\", match: \"[a cool](link)\", value: \"[a cool](link)\", groups: [ \"a cool\", \"link\" ], position: { start: 14, end: 28 } }\n```\n\n\u003cbr\u003e\n\n### Option B\n\n```js\nwhile(!tokenizer.done)\n    console.log(tokenizer.next().value);\n```\n\n```\n{ type: \"WORD\", match: \"abc\", value: \"abc\", groups: [], position: { start: 0, end: 3 } }\n```\n```\n{ type: \"DIGITS\", match: \"123\", value: 123, groups: [], position: { start: 4, end: 7 } }\n```\n```\n{ type: \"HELLO\", match: \"HELLO\", value: \"HELLO\", groups: [], position: { start: 8, end: 13 } }\n```\n```\n{ type: \"LINK\", match: \"[a cool](link)\", value: \"[a cool](link)\", groups: [ \"a cool\", \"link\" ], position: { start: 14, end: 28 } }\n```\n\n\u003cbr\u003e\n\n### Option C\n\n```js\n// Add a parameter to the tokenize method to override the source string\nconsole.log(tokenizer.tokenize());\n```\n\n```\n[{ type: \"WORD\", match: \"abc\", value: \"abc\", groups: [], position: { start: 0, end: 3 } },\n { type: \"DIGITS\", match: \"123\", value: 123, groups: [], position: { start: 4, end: 7 } },\n { type: \"HELLO\", match: \"HELLO\", value: \"HELLO\", groups: [], position: { start: 8, end: 13 } },\n { type: \"LINK\", match: \"[a cool](link)\", value: \"[a cool](link)\", groups: [ \"a cool\", \"link\" ], position: { start: 14, end: 28 } } ]\n```\n\n## TODO\n- [x] Custom patterns using functions\n- [x] Add position information to Token\n- [x] Array patterns (Multiple patterns for the same rule)\n- [x] Documentation\n- [x] Better error handling\n- [x] Group matching\n- [x] Value transform\n- [ ] More and better tests for everything\n- [ ] Examples\n- [ ] Line and column information? Or just a helper function to get line and column from index\n- [ ] BNF / EBNF ?\n- [ ] Generate a tokenizer\n\n\n\u003c!-----------------------------------------------------------------------------\u003e\n\n[Badge License]: https://img.shields.io/badge/License-MIT-yellow.svg?style=for-the-badge\n[Badge Status]: https://github.com/eliassjogreen/deno_tokenizer/workflows/Tests/badge.svg\n\n\n[Actions]: https://github.com/eliassjogreen/deno_tokenizer/actions\n[License]: LICENSE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feliassjogreen%2Fdeno_tokenizer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feliassjogreen%2Fdeno_tokenizer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feliassjogreen%2Fdeno_tokenizer/lists"}