{"id":16309086,"url":"https://github.com/susisu/meaw","last_synced_at":"2025-03-16T14:30:42.536Z","repository":{"id":46995481,"uuid":"88229168","full_name":"susisu/meaw","owner":"susisu","description":"Utility for Unicode East Asian Width :cat2:","archived":false,"fork":false,"pushed_at":"2024-09-22T01:43:03.000Z","size":1048,"stargazers_count":18,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-12T11:22:52.641Z","etag":null,"topics":["eastasianwidth","javascript","javascript-library","unicode"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/meaw","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/susisu.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2017-04-14T03:26:05.000Z","updated_at":"2025-01-10T13:05:51.000Z","dependencies_parsed_at":"2022-09-01T10:31:00.283Z","dependency_job_id":"30a091df-4123-4f72-84db-bbd6ff1bdb97","html_url":"https://github.com/susisu/meaw","commit_stats":{"total_commits":169,"total_committers":5,"mean_commits":33.8,"dds":0.08875739644970415,"last_synced_commit":"5feac8371799580929ca210a988ce1d647227b0d"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/susisu%2Fmeaw","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/susisu%2Fmeaw/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/susisu%2Fmeaw/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/susisu%2Fmeaw/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/susisu","download_url":"https://codeload.github.com/susisu/meaw/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243818172,"owners_count":20352629,"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":["eastasianwidth","javascript","javascript-library","unicode"],"created_at":"2024-10-10T21:19:38.196Z","updated_at":"2025-03-16T14:30:42.225Z","avatar_url":"https://github.com/susisu.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# meaw\n\n[![CI](https://github.com/susisu/meaw/workflows/CI/badge.svg)](https://github.com/susisu/meaw/actions?query=workflow%3ACI)\n\nUtilities for [Unicode East Asian Width (EAW)](http://www.unicode.org/reports/tr11/).\n\n## Installation\n\n``` shell\n# npm\nnpm i --save meaw\n# yarn\nyarn add meaw\n# pnpm\npnpm add meaw\n```\n\n## Usage\n\n### `getEAW()`\n\nGets the [EAW property](http://www.unicode.org/reports/tr11/) of a character.\n\n``` javascript\nimport { getEAW } from \"meaw\";\n\n// Narrow\nassert(getEAW(\"A\") === \"Na\");\n// Wide\nassert(getEAW(\"あ\") === \"W\");\nassert(getEAW(\"安\") === \"W\");\nassert(getEAW(\"🍣\") === \"W\");\n// Fullwidth\nassert(getEAW(\"Ａ\") === \"F\");\n// Halfwidth\nassert(getEAW(\"ｱ\") === \"H\");\n// Ambiguous\nassert(getEAW(\"∀\") === \"A\");\nassert(getEAW(\"→\") === \"A\");\nassert(getEAW(\"Ω\") === \"A\");\nassert(getEAW(\"Я\") === \"A\");\n// Neutral\nassert(getEAW(\"ℵ\") === \"N\");\n\n// character position (in code unit) can be specified\nassert(getEAW(\"ℵAあＡｱ∀\", 2) === \"W\");\n```\n\n### `computeWidth()`\n\n**Deprecated.** To calculate the visual width of a string, it is recommended to split the string into graphemes (using [`Intl.Segmenter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter) or libraries like [graphemer](https://github.com/flmnt/graphemer)) and then calculate the widths of them.\n\nComputes an approximate width of a string based on the [EAW properties](http://www.unicode.org/reports/tr11/) of the characters.\nBy default, characters with property Wide (W) or Fullwidth (F) are treated as wide (= 2) and others are as narrow (= 1).\n\n``` javascript\nimport { computeWidth } from \"meaw\";\n\nassert(computeWidth(\"Aあ🍣Ω\") === 6);\n// character width for each EAW property can be customized\nassert(computeWidth(\"Aあ🍣Ω\", { \"A\": 2 }) === 7);\n```\n\n## Development\n\n### Setup\n\n``` shell\ngit clone https://github.com/susisu/meaw.git\ncd meaw\npnpm i\n```\n\n### Scripts\n\n| Name        | Description                                                       |\n| ----------- | ----------------------------------------------------------------- |\n| `fetch`     | fetch the latest version of the EAW definition file               |\n| `generate`  | generate source script from the EAW definition file               |\n| `format`    | run Prettier                                                      |\n| `lint`      | run ESLint                                                        |\n| `typecheck` | run `tsc --noEmit`                                                |\n| `test`      | execute tests                                                     |\n| `build`     | build scripts                                                     |\n\n## License\n\n[MIT License](http://opensource.org/licenses/mit-license.php)\n\n## Author\n\nSusisu ([GitHub](https://github.com/susisu), [Twitter](https://twitter.com/susisu2413))\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsusisu%2Fmeaw","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsusisu%2Fmeaw","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsusisu%2Fmeaw/lists"}