{"id":25070300,"url":"https://github.com/shelfio/fast-chunk-string","last_synced_at":"2025-10-14T00:37:35.334Z","repository":{"id":44410108,"uuid":"115637897","full_name":"shelfio/fast-chunk-string","owner":"shelfio","description":"Chunk string into equal substrings with unicode support","archived":false,"fork":false,"pushed_at":"2025-10-05T06:24:24.000Z","size":452,"stargazers_count":18,"open_issues_count":5,"forks_count":4,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-10-05T08:31:26.202Z","etag":null,"topics":["chunk-string","node-module","nodejs","npm-package","string-manipulation","unicode"],"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/shelfio.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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2017-12-28T15:52:09.000Z","updated_at":"2025-10-05T06:24:27.000Z","dependencies_parsed_at":"2024-02-01T01:27:23.512Z","dependency_job_id":"43091281-3a46-4c6e-98e1-7a4219ec644b","html_url":"https://github.com/shelfio/fast-chunk-string","commit_stats":{"total_commits":304,"total_committers":9,"mean_commits":33.77777777777778,"dds":0.5625,"last_synced_commit":"03a4f0c9aaa4b395d22ded5ca757e1ad99f81079"},"previous_names":["vladgolubev/fast-chunk-string"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/shelfio/fast-chunk-string","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shelfio%2Ffast-chunk-string","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shelfio%2Ffast-chunk-string/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shelfio%2Ffast-chunk-string/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shelfio%2Ffast-chunk-string/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shelfio","download_url":"https://codeload.github.com/shelfio/fast-chunk-string/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shelfio%2Ffast-chunk-string/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279017358,"owners_count":26086052,"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-10-13T02:00:06.723Z","response_time":61,"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":["chunk-string","node-module","nodejs","npm-package","string-manipulation","unicode"],"created_at":"2025-02-06T21:19:40.294Z","updated_at":"2025-10-14T00:37:35.330Z","avatar_url":"https://github.com/shelfio.png","language":"TypeScript","readme":"# fast-chunk-string [![CircleCI](https://img.shields.io/circleci/project/shelfio/fast-chunk-string.svg)](https://circleci.com/gh/shelfio/fast-chunk-string)\n\n\u003e Chunk string into equal substrings with unicode support\n\nCredits to [stackoverflow.com/a/29202760/2727317](https://stackoverflow.com/a/29202760/2727317)\n\n## Install\n\n```\n$ yarn add @shelf/fast-chunk-string\n```\n\n## Usage\n\n```js\nimport fastChunkString from '@shelf/fast-chunk-string';\n\n// the fastest way\nfastChunkString('unicorns', {size: 2, unicodeAware: false});\n// =\u003e ['un', 'ic', 'or', 'ns']\n\n// ignore unicode, still fast but inaccurate\nfastChunkString('😀😃😄😁', {size: 2, unicodeAware: false});\n// =\u003e ['😀', '😃', '😄', '😁']\n\n// respect unicode, slow but accurate\nfastChunkString('😀😃😄😁', {size: 2, unicodeAware: true});\n// =\u003e ['😀😃', '😄😁']\n```\n\n## Benchmarks\n\nRun via `yarn benchmark`. Measured on M2 Max.\n\n```\nRunning \"Without Unicode\" suite...\nProgress: 100%\n\n  ~33 kb split by 2 kb:\n    14 106 903 ops/s, ±1.71%    | 86.19% slower\n\n  ~33 kb split by 1 mb:\n    100 461 043 ops/s, ±1.45%   | 1.63% slower\n\n  ~330 kb split by 2 kb:\n    1 600 485 ops/s, ±0.63%     | 98.43% slower\n\n  ~330 kb split by 1 mb:\n    102 125 168 ops/s, ±1.50%   | fastest\n\n  ~3.3 mb split by 2 kb:\n    161 507 ops/s, ±1.19%       | 99.84% slower\n\n  ~3.3 mb split by 1 mb:\n    41 773 807 ops/s, ±1.54%    | 59.1% slower\n\n  ~33 mb split by 2 kb:\n    11 098 ops/s, ±0.25%        | slowest, 99.99% slower\n\n  ~33 mb split by 1 mb:\n    5 506 349 ops/s, ±0.58%     | 94.61% slower\n\nFinished 8 cases!\n  Fastest: ~330 kb split by 1 mb\n  Slowest: ~33 mb split by 2 kb\nRunning \"Unicode Aware\" suite...\nProgress: 100%\n\n  ~33 kb split by 2 kb with unicodeAware:\n    847 ops/s, ±0.99%   | 12.14% slower\n\n  ~33 kb split by 1 mb with unicodeAware:\n    964 ops/s, ±0.25%   | fastest\n\n  ~330 kb split by 2 kb with unicodeAware:\n    71 ops/s, ±0.76%    | slowest, 92.63% slower\n\n  ~330 kb split by 1 mb with unicodeAware:\n    90 ops/s, ±0.94%    | 90.66% slower\n\nFinished 4 cases!\n  Fastest: ~33 kb split by 1 mb with unicodeAware\n  Slowest: ~330 kb split by 2 kb with unicodeAware\n```\n\n## Recent optimizations — September 2025\n\nSeptember 2025 improvements were delivered autonomously by the gpt-5-codex model. We treated the hot paths like any latency-sensitive service and tuned the slowest sections:\n\n- Single-pass unicode chunking – length and slicing now come from the same `runes()` walk, eliminating the extra `string-length` scan and keeping multicodepoint graphemes intact.\n- Consolidated ASCII loop – collapsed the fast path into one traversal with early exits for empty inputs and oversized chunk sizes to trim per-call overhead.\n- Fractional-size parity – restored the legacy `slice` coercion semantics so non-integer chunk sizes behave exactly as before, backed by new regression tests.\n\nThe result is steadier throughput in the ASCII suite (for example ~33 kb split by 1 mb climbs from 85.6M to 100.5M ops/s) and a 9–10× lift in the unicode-aware scenarios (e.g. 33 kb splits rise from ~101 ops/s to ~964 ops/s) while preserving behaviour for combining marks and emoji ligatures.\n\n## See Also\n\n- [fast-normalize-spaces](https://github.com/shelfio/fast-normalize-spaces)\n- [fast-natural-order-by](https://github.com/shelfio/fast-natural-order-by)\n- [fast-uslug](https://github.com/shelfio/fast-uslug)\n\n## Publish\n\n```sh\n$ git checkout master\n$ yarn version\n$ yarn publish\n$ git push origin master --tags\n```\n\n## License\n\nMIT © [Shelf](https://shelf.io)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshelfio%2Ffast-chunk-string","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshelfio%2Ffast-chunk-string","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshelfio%2Ffast-chunk-string/lists"}