{"id":23909087,"url":"https://github.com/BHznJNs/multi-counter","last_synced_at":"2025-09-10T17:32:18.694Z","repository":{"id":251927902,"uuid":"838869931","full_name":"BHznJNs/multilang-counter","owner":"BHznJNs","description":"A simple and light-weight word counter with multi-language support.","archived":false,"fork":false,"pushed_at":"2024-08-08T08:34:26.000Z","size":30,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-12T16:48:00.817Z","etag":null,"topics":["internationalization","multilanguage-support","word-counter","wordcounter"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BHznJNs.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":"2024-08-06T13:59:24.000Z","updated_at":"2024-08-08T08:34:30.000Z","dependencies_parsed_at":"2024-08-07T10:19:24.482Z","dependency_job_id":null,"html_url":"https://github.com/BHznJNs/multilang-counter","commit_stats":null,"previous_names":["bhznjns/multi-counter","bhznjns/multilang-counter"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BHznJNs%2Fmultilang-counter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BHznJNs%2Fmultilang-counter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BHznJNs%2Fmultilang-counter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BHznJNs%2Fmultilang-counter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BHznJNs","download_url":"https://codeload.github.com/BHznJNs/multilang-counter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232548654,"owners_count":18540154,"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":["internationalization","multilanguage-support","word-counter","wordcounter"],"created_at":"2025-01-05T05:16:15.682Z","updated_at":"2025-09-10T17:32:18.657Z","avatar_url":"https://github.com/BHznJNs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# multi-counter\n\nA simple and light-weight word counter and reading time calculator with multi-language support.\n\n## Example\n\nCount words in a paragraph:\n\n```javascript\nimport { countWords } from \"multilang-counter\"\n\ncountWords(\"Hello World!\") // 2\ncountWords(\"你好，世界！\") // 4\ncountWords(\"こんにちは、世界!\") // 7\ncountWords(\"مرحبا، بالعالم!\") // 2\ncountWords(\"Привет, мир!\") // 2\n\n// for mixed paragraph\ncountWords(\"Hello World! 你好，世界！\") // 6\n```\n\nEliminate the required reading time for a paragraph:\n\n```javascript\nimport { readingTime } from \"multilang-counter\"\n\n// returns 4 with a unit of minutes, since the default reading rate is 300 words per min.\nreadingTime(\"...a paragraph with 1200 words...\")\n\n// returns 3 with a unit of minutes, since the reading rate is set to 400 words per min.\nreadingTime(\"...a paragraph with 1200 words...\", 400)\n\n// use different reading rate to the different languages in a paragraph\nreadingTime(\"...a paragraph consists of multiple languages...\", {\n    cjk: 300, // Chinese, Japanese, Korean\n    eu: 250,  // European languages\n    gr: 250,  // Greek\n    ar: 250,  // Arabic\n    cy: 250,  // Cyrillic\n    num: 300, // Number\n})\n```\n\n## Usage\n\n### Install \u0026 Import\n\n```bash\nnpm i @bhznjns/multi-counter\n```\n\n```javascript\nimport { countWords, readingTime, tokenize } from \"@bhznjns/multi-counter\"\n```\n\n### API\n\n|    Method    | Description | Arguments |\n|     ---      |     ---     |    ---    |\n| `countWords` | Calculates the number of words in a given string | `text` |\n| `readingTime` | Estimates the required reading time for a given string  | `text`, `wordsPerMin` |\n| `tokenize` | Tokenizes multi-lingual text, separating CJK by characters and others by words, excluding punctuation | `text` |\n\n#### wordsPerMin: ReadingRate\n\n```typescript\ntype ReadingRate = number | {\n    cjk?: number,\n    eu?: number,\n    gr?: number,\n    ar?: number,\n    cy?: number,\n    num?: number,\n    default?: number,\n}\n```\n\nCan be a number or an object.\n\ndefault: `300`\n\nWhen it is a number, the `readingTime` applies the same reading rate to scripts of all languages; When it is a object, the reading rate of the given field will be applied to the corresponding language.\n\n- `cjk` -\u003e Chinese, Japanese, Korean\n- `eu` -\u003e European languages\n- `gr` -\u003e Greek\n- `ar` -\u003e Arabic\n- `cy` -\u003e Cyrillic\n- `num` -\u003e Number\n- `default` -\u003e Default value to fields above, if it is undefined, it will be set to `300`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBHznJNs%2Fmulti-counter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBHznJNs%2Fmulti-counter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBHznJNs%2Fmulti-counter/lists"}