{"id":16831155,"url":"https://github.com/chearon/itemizer","last_synced_at":"2025-10-05T18:28:18.664Z","repository":{"id":57278437,"uuid":"227039194","full_name":"chearon/itemizer","owner":"chearon","description":"Segment a JS string into script, emoji, and bidi parts","archived":false,"fork":false,"pushed_at":"2023-03-12T23:46:29.000Z","size":206,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-11T04:11:53.168Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chearon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2019-12-10T05:50:20.000Z","updated_at":"2024-11-16T10:10:14.000Z","dependencies_parsed_at":"2024-10-13T11:42:35.798Z","dependency_job_id":"9c5396e9-cf19-4c2b-a1a9-730b03f653e9","html_url":"https://github.com/chearon/itemizer","commit_stats":{"total_commits":29,"total_committers":1,"mean_commits":29.0,"dds":0.0,"last_synced_commit":"97b17663965127750a932c406a4e7af49adb6da9"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chearon%2Fitemizer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chearon%2Fitemizer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chearon%2Fitemizer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chearon%2Fitemizer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chearon","download_url":"https://codeload.github.com/chearon/itemizer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248339225,"owners_count":21087215,"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-13T11:42:27.670Z","updated_at":"2025-10-05T18:28:13.622Z","avatar_url":"https://github.com/chearon.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# itemizer\n\nDice up JS strings by script, emoji and bidi direction. Hand ported from Pango with the help of [SheenBidi](https://github.com/Tehreer/SheenBidi) and [emoji-segmenter](https://github.com/google/emoji-segmenter), both of which are compiled and distributed in WebAssembly form.\n\nA useful text-stack component if you want to do your own font selection and shaping in JS, or if you need more power to customize the display of different scripts or emojis in a browser.\n\n## API\n\nThe module itself is a promise since WASM loads asynchronously:\n\n```javascript\nconst {emoji, script, bidi} = await require('itemizer');\n```\n\nEach of the values on the resolved object have the same API but iterate different things. The emoji iterator stops at boundaries between text and emoji sequences:\n\n```javascript\nconst str = 'I 👏🏼 proper i18n support';\nlet last = 0;\nfor (const {i, isEmoji} of emoji(str)) {\n  console.log(str.slice(last, i)); // logs 3 times\n  last = i;\n}\n```\n\nThe bidi iterator has the same API:\n\n\n```javascript\nconst str = 'Latin is common ពួកគេទាំងអស់   ';\n\nlet last = 0;\nfor (const {i, dir} of bidi(str, 0 /* base level (ex. 1 for RTL) */)) {\n  console.log(str.slice(last, i)); // logs 2 times\n  last = i;\n}\n```\nand so does the script iterator's API:\n\n```javascript\nconst str = 'Latin is common ពួកគេទាំងអស់   ';\n\nfor (const {i, script} of script(str)) {\n  console.log(script); // logs 2 times\n}\n```\n\n## Bigger example\n\nCheck out the repo and run\n\n```bash\n$ node test.js\n```\n\n## Building the WebAssembly locally\n\n1. Get [ragel](http://www.colm.net/open-source/ragel/) from your package manager\n2. Get [WASI (sysroot version)](https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-19/wasi-sysroot-19.0.tar.gz)\n3. Get LLVM Clang 9+ from your package manager\n4. Open the makefile and set `RL`, `WASI_SYSROOT` `CXX` according to steps 1, 2, 3\n5. `make`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchearon%2Fitemizer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchearon%2Fitemizer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchearon%2Fitemizer/lists"}