{"versions":{"0.0.2":{"name":"clustr","type":"module","version":"0.0.2","packageManager":"pnpm@10.12.4","description":"Safely extract UTF-8 grapheme clusters from byte streams","author":{"name":"Makito","email":"i@maki.to"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/sumimakito/clustr.git"},"exports":{".":"./dist/index.js","./package.json":"./package.json"},"main":"./dist/index.js","module":"./dist/index.js","types":"./dist/index.d.ts","engines":{"node":">=22.10.0"},"scripts":{"build":"tsdown","lint":"NODE_OPTIONS='--experimental-strip-types' eslint --flag unstable_native_nodejs_ts_config","test":"vitest"},"devDependencies":{"@antfu/eslint-config":"^4.16.2","@tsconfig/strictest":"^2.0.5","@types/node":"^24.0.12","cspell":"^9.1.3","eslint":"^9.30.1","tsdown":"^0.12.9","typescript":"^5.8.3","vitest":"^3.2.4"},"_id":"clustr@0.0.2","gitHead":"6f8db69115779bbb3359178676876e58fe9cd235","bugs":{"url":"https://github.com/sumimakito/clustr/issues"},"homepage":"https://github.com/sumimakito/clustr#readme","_nodeVersion":"23.11.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-zgaCIkMDV3OBftIvXuxVJ3Tek46Wu217GF4hGuncRTXhnPK0fiQp7uaV8/JvYQgbK0eUz9lblTKLYf+HbIrL6Q==","shasum":"5445db61d7ffdf6c900c522636cad833abd28b07","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/clustr/-/clustr-0.0.2.tgz","fileCount":8,"unpackedSize":6407,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIFDVZyU3C35hEMCA0L+LXr9Tx/3yfmJtXq10Iiw5Z3f1AiAIcJiFPn2fv+MRviyEYLv40HUMfgsJsSi0n1j1k/bSDg=="}],"size":2448},"_npmUser":{"name":"anonymous","email":"sumimakito@hotmail.com"},"directories":{},"maintainers":[{"name":"anonymous","email":"sumimakito@hotmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/clustr_0.0.2_1752347456136_0.08560516474902435"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-07-12T19:10:56.325Z","publish_time":1752347456325,"_source_registry_name":"default","contributors":[]},"0.0.3":{"name":"clustr","type":"module","version":"0.0.3","packageManager":"pnpm@10.12.4","description":"Stream UTF-8 bytes and read grapheme clusters safely","author":{"name":"Makito","email":"i@maki.to"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/sumimakito/clustr.git"},"exports":{".":"./dist/index.js","./package.json":"./package.json"},"main":"./dist/index.js","module":"./dist/index.js","types":"./dist/index.d.ts","engines":{"node":">=22.10.0"},"scripts":{"build":"tsdown","lint":"eslint","test":"vitest"},"devDependencies":{"@tsconfig/strictest":"catalog:","@types/node":"catalog:","tsdown":"catalog:","typescript":"catalog:","vitest":"catalog:"},"_id":"clustr@0.0.3","gitHead":"6317ae7b58be7f290efbdcf10cdeb4c60055014d","bugs":{"url":"https://github.com/sumimakito/clustr/issues"},"homepage":"https://github.com/sumimakito/clustr#readme","_nodeVersion":"23.11.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-nGJZKUSi2K83migJ7sJj/JYNVbT0L81b7fFNcQ3XIgkXqkeG1tpO1NtISDjr3Unnjqsztzvp/p+8JgBhpAc87g==","shasum":"379c3f9535b7d9b308abf7fc36658ad67a15f53b","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/clustr/-/clustr-0.0.3.tgz","fileCount":7,"unpackedSize":9828,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCICkC88kmbxzDmlV/3scZnR6r0URDLd7uBhNlZKbJZKP7AiEAvOdPUSdDILHdf0fsQ0yinKwx7kFJi2uwmFcTlQDlylw="}],"size":2904},"_npmUser":{"name":"anonymous","email":"sumimakito@hotmail.com"},"directories":{},"maintainers":[{"name":"anonymous","email":"sumimakito@hotmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/clustr_0.0.3_1752777292949_0.6208290923540294"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-07-17T18:34:53.115Z","publish_time":1752777293115,"_source_registry_name":"default","contributors":[]},"0.0.4":{"name":"clustr","type":"module","version":"0.0.4","description":"Stream UTF-8 bytes and read grapheme clusters safely","author":{"name":"Makito","email":"i@maki.to"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/sumimakito/clustr.git"},"exports":{".":"./dist/index.js","./package.json":"./package.json"},"main":"./dist/index.js","module":"./dist/index.js","types":"./dist/index.d.ts","engines":{"node":">=22.10.0"},"devDependencies":{"@tsconfig/strictest":"^2.0.5","@types/node":"^24.0.12","tsdown":"^0.12.9","typescript":"^5.8.3","vitest":"^3.2.4"},"scripts":{"build":"tsdown","bump":"bumpp --no-tag --no-push --sign","lint":"eslint --cache .","lint:fix":"eslint --cache . --fix","test":"vitest"},"_id":"clustr@0.0.4","bugs":{"url":"https://github.com/sumimakito/clustr/issues"},"homepage":"https://github.com/sumimakito/clustr#readme","_integrity":"sha512-oe0vq2xLO2JK1Z6pWK9YB8PsBC9W5R2llinYxmhAtDhJS4Wa7AHErNx1nYJ7SE7bc4S7RJ5D51KKbP/1oRZYPw==","_resolved":"/tmp/7ffac4289e78e7f1179230ce8d1f2625/clustr-0.0.4.tgz","_from":"file:clustr-0.0.4.tgz","_nodeVersion":"24.4.1","_npmVersion":"11.4.2","dist":{"integrity":"sha512-oe0vq2xLO2JK1Z6pWK9YB8PsBC9W5R2llinYxmhAtDhJS4Wa7AHErNx1nYJ7SE7bc4S7RJ5D51KKbP/1oRZYPw==","shasum":"3467fcfaa81ac29060344d9b7a36e5e127c56f0b","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/clustr/-/clustr-0.0.4.tgz","fileCount":9,"unpackedSize":14693,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIBRgyLYR0IYx/HPOOozvaRd1UPy6e4dgMgmyJ8sNLyyQAiBuL2z5cbh3szbMXLLn88Hqgd3flrTc3kVAzCAUi2t8EA=="}],"size":4781},"_npmUser":{"name":"anonymous","email":"sumimakito@hotmail.com"},"directories":{},"maintainers":[{"name":"anonymous","email":"sumimakito@hotmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/clustr_0.0.4_1753197364177_0.6162059529212802"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-07-22T15:16:04.330Z","publish_time":1753197364330,"_source_registry_name":"default","contributors":[]},"0.0.5":{"name":"clustr","type":"module","version":"0.0.5","description":"Stream UTF-8 bytes and read grapheme clusters safely","author":{"name":"Makito","email":"i@maki.to"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/sumimakito/clustr.git"},"exports":{".":"./dist/index.js","./package.json":"./package.json"},"main":"./dist/index.js","module":"./dist/index.js","types":"./dist/index.d.ts","engines":{"node":">=22.10.0"},"devDependencies":{"@tsconfig/strictest":"^2.0.5","@types/node":"^24.0.12","tsdown":"^0.12.9","typescript":"^5.8.3","vitest":"^3.2.4"},"scripts":{"build":"tsdown","bump":"bumpp --no-tag --no-push --sign","lint":"eslint --cache .","lint:fix":"eslint --cache . --fix","test":"vitest"},"_id":"clustr@0.0.5","bugs":{"url":"https://github.com/sumimakito/clustr/issues"},"homepage":"https://github.com/sumimakito/clustr#readme","_integrity":"sha512-ppZJaNPC7eWIV2hJLYEz9s6cD2GZJjzDriDdkMAHi1z8h0ZC06+XO3SoRXsiLsP38rjNbejx8hduPn5bYxJ/aA==","_resolved":"/tmp/64e6e1d6bbcd37e7e3352599e0cf53dc/clustr-0.0.5.tgz","_from":"file:clustr-0.0.5.tgz","_nodeVersion":"24.4.1","_npmVersion":"11.4.2","dist":{"integrity":"sha512-ppZJaNPC7eWIV2hJLYEz9s6cD2GZJjzDriDdkMAHi1z8h0ZC06+XO3SoRXsiLsP38rjNbejx8hduPn5bYxJ/aA==","shasum":"b94f58272bfa693eef19da4a46e2cee270f0263b","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/clustr/-/clustr-0.0.5.tgz","fileCount":9,"unpackedSize":13538,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDvpWppYE6CY8N5UlucZGQhuxqEEn1A97Qtk+HdTtHe3gIhAN5YZMnfdbIcE09LWAQrMeSdip2Iq2Ug3WVufIx4qEg7"}],"size":4799},"_npmUser":{"name":"anonymous","email":"sumimakito@hotmail.com"},"directories":{},"maintainers":[{"name":"anonymous","email":"sumimakito@hotmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/clustr_0.0.5_1753197893865_0.4924645435823576"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-07-22T15:24:54.046Z","publish_time":1753197894046,"_source_registry_name":"default","contributors":[]},"0.0.6":{"name":"clustr","type":"module","version":"0.0.6","description":"Stream UTF-8 bytes and read grapheme clusters safely","author":{"name":"Makito","email":"i@maki.to"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/sumimakito/clustr.git"},"keywords":["emoji","grapheme","grapheme cluster","readable-stream","stream","streaming","unicode","utf8","zwj-sequences"],"exports":{".":"./dist/index.js","./package.json":"./package.json"},"main":"./dist/index.js","module":"./dist/index.js","types":"./dist/index.d.ts","engines":{"node":">=22.10.0"},"devDependencies":{"@tsconfig/strictest":"^2.0.5","@types/node":"^24.0.12","tsdown":"^0.12.9","typescript":"^5.8.3","vitest":"^3.2.4"},"scripts":{"build":"tsdown","bump":"bumpp --no-tag --no-push --sign","lint":"eslint --cache .","lint:fix":"eslint --cache . --fix","test":"vitest"},"_id":"clustr@0.0.6","bugs":{"url":"https://github.com/sumimakito/clustr/issues"},"homepage":"https://github.com/sumimakito/clustr#readme","_integrity":"sha512-OZIoc5Nn/hXX0iF3NS5DDs0prLFxoeAdWAsX3Drd8e4oRzUBda5R7XIoWBN4/9jWn1dlUorppYhU4wQEQ/JFmw==","_resolved":"/tmp/c037ceed7cbdcf18c81542fdeb3055d5/clustr-0.0.6.tgz","_from":"file:clustr-0.0.6.tgz","_nodeVersion":"24.4.1","_npmVersion":"11.4.2","dist":{"integrity":"sha512-OZIoc5Nn/hXX0iF3NS5DDs0prLFxoeAdWAsX3Drd8e4oRzUBda5R7XIoWBN4/9jWn1dlUorppYhU4wQEQ/JFmw==","shasum":"7e05993f3814818c99318ba1b8d8d04703b060ef","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/clustr/-/clustr-0.0.6.tgz","fileCount":9,"unpackedSize":13713,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIE4CXbA02lp8ruo5Wkwj1Ctiol2DBD7anQ62he+UdwOtAiEAlVYPzmAWit0pJ6XiLpaikn+D7nzajdvSW8hpjRDC4eY="}],"size":4863},"_npmUser":{"name":"anonymous","email":"sumimakito@hotmail.com"},"directories":{},"maintainers":[{"name":"anonymous","email":"sumimakito@hotmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/clustr_0.0.6_1753198066123_0.9064221464362305"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-07-22T15:27:46.312Z","publish_time":1753198066312,"_source_registry_name":"default","contributors":[]},"1.0.2":{"name":"clustr","type":"module","version":"1.0.2","description":"Stream UTF-8 bytes and read grapheme clusters safely","author":{"name":"Makito","email":"i@maki.to"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/sumimakito/clustr.git"},"keywords":["emoji","grapheme","grapheme cluster","readable-stream","stream","streaming","unicode","utf8","zwj-sequences"],"exports":{".":"./dist/index.js","./package.json":"./package.json"},"main":"./dist/index.js","module":"./dist/index.js","types":"./dist/index.d.ts","engines":{"node":">=22.10.0"},"devDependencies":{"@tsconfig/strictest":"^2.0.5","@types/node":"^24.0.12","tsdown":"^0.12.9","typescript":"^5.8.3","vitest":"^3.2.4"},"scripts":{"build":"tsdown","bump":"bumpp --no-tag --no-push --sign","lint":"eslint --cache .","lint:fix":"eslint --cache . --fix","test":"vitest"},"_id":"clustr@1.0.2","bugs":{"url":"https://github.com/sumimakito/clustr/issues"},"homepage":"https://github.com/sumimakito/clustr#readme","_integrity":"sha512-Zvxo5inxwvoGMI0R+cXV+5nVbl/Gw7zYV1Msn9mn7loC6CK941CjvsBplgClJV83T4UXID+SXhtfVulfaBat5w==","_resolved":"/tmp/71864d01b1ee9dba98a6670a0f1bebed/clustr-1.0.2.tgz","_from":"file:clustr-1.0.2.tgz","_nodeVersion":"24.4.1","_npmVersion":"11.4.2","dist":{"integrity":"sha512-Zvxo5inxwvoGMI0R+cXV+5nVbl/Gw7zYV1Msn9mn7loC6CK941CjvsBplgClJV83T4UXID+SXhtfVulfaBat5w==","shasum":"29dca7c3750e4414ca7fdb368e1766dff3a3beee","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/clustr/-/clustr-1.0.2.tgz","fileCount":9,"unpackedSize":13713,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIFwVLVR9QIvUkkbrk0SLKZof5JOyo2pBPYUjA1AI40jwAiEAwU7By6ZK1fp3itS17b01pAemL5KIXU7WoMp7t0Yg/WI="}],"size":4863},"_npmUser":{"name":"anonymous","email":"sumimakito@hotmail.com"},"directories":{},"maintainers":[{"name":"anonymous","email":"sumimakito@hotmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/clustr_1.0.2_1753200565233_0.4073937867563735"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-07-22T16:09:25.421Z","publish_time":1753200565421,"_source_registry_name":"default","contributors":[]}},"dist-tags":{"latest":"1.0.2"},"name":"clustr","time":{"created":"2022-01-27T01:14:04.836Z","modified":"2025-07-22T16:09:36.192Z","0.0.2":"2025-07-12T19:10:56.325Z","0.0.3":"2025-07-17T18:34:53.115Z","0.0.4":"2025-07-22T15:16:04.330Z","0.0.5":"2025-07-22T15:24:54.046Z","0.0.6":"2025-07-22T15:27:46.312Z","1.0.2":"2025-07-22T16:09:25.421Z"},"readme":"<div align=\"center\">\n\n# Clustr\n\nStream UTF-8 bytes and read grapheme clusters safely\n\n[![Netlify Status](https://api.netlify.com/api/v1/badges/4a46ffaa-fe7e-4bd4-add7-9dc892370f1e/deploy-status)](https://app.netlify.com/projects/try-clustr/deploys) [![NPM Version](https://img.shields.io/npm/v/clustr?style=flat)](https://www.npmjs.com/package/clustr)\n\n[Try Clustr](https://try-clustr.netlify.app/)\n\n</div>\n\nIn UTF-8, a grapheme cluster is a sequence of one or more code points that can be rendered as a single character. For example, the Emoji ZWJ Sequences:\n\n```\n[...'👨‍🚀']\n→ (3) ['👨', '‍', '🚀']\n[...'👩‍👩‍👧‍👧']\n→ (7) ['👩', '‍', '👩', '‍', '👧', '‍', '👧']\n```\n\nOf course, it's not as easy as splitting by ZWJ characters. In complex scripts like Indic languages, where a single character can also be represented by multiple code points:\n\n```\n[...'क्षि']\n→ (4) ['क', '्', 'ष', 'ि']\n```\n\nYou may learn more about grapheme clusters in [*Unicode® Standard Annex #29: Unicode Text Segmentation*](https://unicode.org/reports/tr29/).\n\nBesides the built-in Intl.Segmenter API, there are a few libraries that can correctly split grapheme clusters from a string, but few of them accept byte streams directly.\n\nClustr aims to help you iterate grapheme clusters from a stream of UTF-8 bytes, making it easy to read them correctly, safely, and as early as possible.\n\n## Installation\n\n```bash\n# if PNPM\npnpm add clustr\n\n# else if NPM\nnpm install clustr\n\n# else if Yarn\nyarn add clustr\n```\n\n## Usage\n\n```ts\nimport { readGraphemeClusters } from 'clustr'\n\nfunction createStream(text: string) {\n  const bytes = new TextEncoder().encode(text)\n  let pullIndex = 0\n\n  return new ReadableStream<Uint8Array>({\n    pull(controller) {\n      if (pullIndex < bytes.length) {\n        controller.enqueue(new Uint8Array([bytes[pullIndex++]!]))\n      }\n      else {\n        controller.close()\n      }\n    },\n  })\n}\n\nconst stream = createStream('👨‍🚀👩‍🚀💇‍♀️🚵‍♂️🚵‍♀️👩‍👩‍👧‍👧')\nconst reader = stream.getReader()\n\nfor await (const cluster of readGraphemeClusters(reader)) {\n  console.log(cluster)\n}\n```\n\n## Use case\n\nSometimes, you may want the message to appear in a stream-like manner with fancy animations in your chat bubble, like this:\n\n![](docs/airi-chat-bubble.gif)\n\nWe built many UI components at [Project AIRI](https://github.com/moeru-ai/airi), where we use this library to safely split the elements to be animated in the chat bubble shown above. You should definitely check it out if you are also interested in meeting an AI soulmate.\n\n## License\n\n```\nCopyright 2025 Makito\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the “Software”), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\nof the Software, and to permit persons to whom the Software is furnished to do\nso, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```","users":{}}