{"id":21995083,"url":"https://github.com/redhataccess/token-slice","last_synced_at":"2026-04-19T04:32:22.685Z","repository":{"id":77524646,"uuid":"361791541","full_name":"redhataccess/token-slice","owner":"redhataccess","description":"A simple library for extracting text wrapped with tokens.","archived":false,"fork":false,"pushed_at":"2021-08-12T13:46:26.000Z","size":551,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-10T10:27:26.227Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://redhataccess.github.io/token-split/","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/redhataccess.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}},"created_at":"2021-04-26T15:01:54.000Z","updated_at":"2021-08-12T13:46:27.000Z","dependencies_parsed_at":"2023-09-06T01:38:22.642Z","dependency_job_id":null,"html_url":"https://github.com/redhataccess/token-slice","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":"metachris/typescript-boilerplate","purl":"pkg:github/redhataccess/token-slice","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redhataccess%2Ftoken-slice","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redhataccess%2Ftoken-slice/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redhataccess%2Ftoken-slice/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redhataccess%2Ftoken-slice/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/redhataccess","download_url":"https://codeload.github.com/redhataccess/token-slice/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redhataccess%2Ftoken-slice/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31994943,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T20:23:30.271Z","status":"online","status_checked_at":"2026-04-19T02:00:07.110Z","response_time":55,"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":[],"created_at":"2024-11-29T21:12:17.114Z","updated_at":"2026-04-19T04:32:22.670Z","avatar_url":"https://github.com/redhataccess.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# token-slice\n\n[![Build and test status](https://github.com/redhataccess/token-slice/workflows/Lint%20and%20test/badge.svg)](https://github.com/redhataccess/token-slice/actions?query=workflow%3A%22Build+and+test%22)\n\ntoken-slice is a small library for extracting text wrapped with arbitrary tokens.  Please do not use it for [parsing HTML](https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454).\n\n```js\nimport { createTokenSlicer } from \"token-slice\";\n\nconst tok = createTokenSlicer({\n  tokens: [\n    {\n      name: \"token1\",\n      start: \"a\",\n      end: \"c\",\n    }\n  ]\n});\n\n// provide an input string\nconst output = tok.tokenize(\"abc\");\n\n// output equals:\n{\n  input: \"abc\",\n  config: { /* copy of the config object passed into createTokenSlicer */ },\n  result: [\n    {\n      definition: {name: \"test_token\", start: \"a\", end: \"c\"},\n      inner: {\n        content: \"b\",\n        startIndex: 1,\n        endIndex: 2,\n      },\n      outer: {\n        content: \"abc\",\n        startIndex: 0,\n        endIndex: 3,\n      },\n    }\n  ]\n}\n```\n## References\n\nThis repo was set up based on the template outlined in [Starting a TypeScript Project in 2021](https://www.metachris.com/2021/03/bootstrapping-a-typescript-node.js-project/), recommend checking out the post!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredhataccess%2Ftoken-slice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fredhataccess%2Ftoken-slice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredhataccess%2Ftoken-slice/lists"}