{"id":13509597,"url":"https://github.com/kwonoj/hunspell-asm","last_synced_at":"2025-08-12T21:13:10.473Z","repository":{"id":22522569,"uuid":"96595473","full_name":"kwonoj/hunspell-asm","owner":"kwonoj","description":"WebAssembly based Javascript bindings for hunspell spellchecker","archived":false,"fork":false,"pushed_at":"2023-01-14T00:25:15.000Z","size":3479,"stargazers_count":71,"open_issues_count":20,"forks_count":11,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-08-09T08:20:57.205Z","etag":null,"topics":["hunspell","hunspell-asm","spell","spellchecker","typescript","wasm","webassembly"],"latest_commit_sha":null,"homepage":"","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/kwonoj.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}},"created_at":"2017-07-08T04:17:21.000Z","updated_at":"2025-04-17T03:45:58.000Z","dependencies_parsed_at":"2023-01-11T21:39:44.163Z","dependency_job_id":null,"html_url":"https://github.com/kwonoj/hunspell-asm","commit_stats":null,"previous_names":[],"tags_count":37,"template":false,"template_full_name":null,"purl":"pkg:github/kwonoj/hunspell-asm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kwonoj%2Fhunspell-asm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kwonoj%2Fhunspell-asm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kwonoj%2Fhunspell-asm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kwonoj%2Fhunspell-asm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kwonoj","download_url":"https://codeload.github.com/kwonoj/hunspell-asm/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kwonoj%2Fhunspell-asm/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269725730,"owners_count":24465367,"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-08-10T02:00:08.965Z","response_time":71,"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":["hunspell","hunspell-asm","spell","spellchecker","typescript","wasm","webassembly"],"created_at":"2024-08-01T02:01:10.111Z","updated_at":"2025-08-12T21:13:10.449Z","avatar_url":"https://github.com/kwonoj.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","Projects"],"sub_categories":["Others"],"readme":"[![Build Status](https://travis-ci.org/kwonoj/hunspell-asm.svg?branch=master)](https://travis-ci.org/kwonoj/hunspell-asm)\n[![Build status](https://ci.appveyor.com/api/projects/status/7s0r599r9h6r682g?svg=true)](https://ci.appveyor.com/project/kwonoj/hunspell-asm)\n[![codecov](https://codecov.io/gh/kwonoj/hunspell-asm/branch/master/graph/badge.svg)](https://codecov.io/gh/kwonoj/hunspell-asm)\n[![npm](https://img.shields.io/npm/v/hunspell-asm.svg)](https://www.npmjs.com/package/hunspell-asm)\n[![node](https://img.shields.io/badge/node-=\u003e10.0-blue.svg?style=flat)](https://www.npmjs.com/package/hunspell-asm)\n\n# Hunspell-asm\n\n`Hunspell-asm` is isomorphic javascript binding to [hunspell](https://github.com/hunspell/hunspell) spellchecker based on WebAssembly hunspell binary. This module aims to provide thin, lightweight interface to hunspell without requiring native modules.\n\n# Install\n\n```sh\nnpm install hunspell-asm\n```\n\n# Usage\n\n## Loading module asynchronously\n\n`Hunspell-asm` relies on wasm binary of hunspell, which need to be initialized first.\n\n```js\nimport { loadModule } from 'hunspell-asm';\n\nconst hunspellFactory = await loadModule();\n```\n\n`loadModule` loads wasm binary, initialize it, and returns factory function to create instance of hunspell.\n\n```js\nloadModule({ timeout?: number }): Promise\u003cHunspellFactory\u003e\n```\n\nIt allows to specify timeout to wait until wasm binary compliation \u0026 load.\n\n## Mounting files\n\nWasm binary uses different memory spaces allocated for its own and cannot access plain javascript object / or files directly. `HunspellFactory` provides few interfaces to interop file contents into hunspell.\n\n- `mountBuffer(contents: ArrayBufferView, fileName?: string): string` : Mount contents of file.\n- `unmount(mountedFilePath: string)` : Unmount path if it's exists in memory. If it's bufferFile created by `mountBuffer`, unmount will remove those file object in wasm memory as well.\n\nAll of `virtual` paths for mounted filesystem uses unix separator regardless of platform.\n\n## Creating spellchecker\n\nOnce you mounted dic / aff files you can create hunspell spellchecker instance via `HunspellFactory::create`. Each path for files are mounted path and should not be actual path or server endpoint.\n\n```js\ncreate(affPath: string, dictPath: string): Hunspell\n```\n\n`Hunspell` exposes minimal interfaces to spellchecker.\n\n- `spell(word: string): boolean` : Check spelling for word. False for misspelled, True otherwise.\n- `suggest(word: string): Array\u003cstring\u003e` : Get suggestion list for misspelled word. Empty if word is not misspelled or no suggestions.\n- `dispose(): void` : Destroy current instance of hunspell. It is important to note created instance of hunspell will not be destroyed automatically.\n\nThere are simple [examples](https://github.com/kwonoj/hunspell-asm/tree/e0e421fda667fb0d4888a4e0b21877e95540c29c/examples) for each environments using different apis. In each example directory do `npm install \u0026\u0026 npm start`.\n\n## Adding words to dictionary in runtime\n\nHunspell exposes few interfaces allow to add words, or dictionaries in existing dictionary in runtime. This is **runtime** behavior, so it doesn't persist over once instance is disposed.\n\n- `addWord(word: string): void` : add single word to current dictionary.\n- `removeWord(word: string): void` : remove single word from current dictionary.\n- `addWordWithAffix(word: string, affix: string): void`: add word with example word having affix flag to be applied. Second param `affix` is example word, should exists in current dictionary with its own affix flag. Newly added word will have same affix rule as example word.\n- `addDictionary(dictPath): boolean` : Load addtional dictionary into existing hunspell instance. This cannot load additional affi\nx. If function returns false, it means internal slot hunspell manages are full and can't add additional dictionaries.\n\n## Things to note\n\n- Ensure all inputs (aff, dic, word for spell / suggest) are UTF-8 encoded correctly. While hunspell itself supports other encodings, all surrounding interfaces passing buffers are plain javascript doesn't detect / converts encodings automatically.\n\n# Building / Testing\n\nFew npm scripts are supported for build / test code.\n\n- `build`: Transpiles code to ES5 commonjs to `dist`.\n- `test`: Run `hunspell` / `hunspell-asm` test both. Does not require `build` before execute test.\n- `test:hunspell`: Run integration test for actual hunspell wasm binary, using [hunspell's test case](https://github.com/hunspell/hunspell/tree/97d7d559f621176685695fbd51e5d8d3f9e005e3/tests) as-is.\n- `test:hunspell-asm`: Run unit test against `hunspell-asm` interface\n- `lint`: Run lint over all codebases\n- `lint:staged`: Run lint only for staged changes. This'll be executed automatically with precommit hook.\n- `commit`: Commit wizard to write commit message\n\n# License\n\n- Hunspell: [original license](https://github.com/hunspell/hunspell/blob/master/license.hunspell)\n- Hunspell-asm: [MIT](https://github.com/kwonoj/hunspell-asm/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkwonoj%2Fhunspell-asm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkwonoj%2Fhunspell-asm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkwonoj%2Fhunspell-asm/lists"}