Uses N-API to bind to the macOS native spell-checker (part of the Cocoa framework):
- Only a minimal set of operations are currently implemented:
testSpelling,getSpellingSuggestions,addWordandremoveWord(all apply to a single word only) - Addon binary is pre-bundled. Doesn't require any install-time scripts
- Uses the stable
napi.hC++ API (withNAPI_VERSION = 8). It should not generally require recompilation for new different Node.js versions - Should work in different versions of Electron.js without recompilation
- Supports both x64 and arm64 versions of macOS
npm install macos-spellchecker
import { createMacosSpellChecker, getSupportedLanguages } from 'macos-spellchecker'
console.log(getSupportedLanguages())
// Output: [ 'en', 'en_CA', 'en_GB', 'en_AU', 'en_IN', ... 'hi', 'pa', 'te', 'ko' ]
const checker = createMacosSpellChecker('en')
console.log(checker.testSpelling('Hello'))
// Output: true
console.log(checker.testSpelling('Hellow'))
// Output: false
console.log(checker.getSpellingSuggestions('Hellow'))
// Output: [
// 'Hallow', 'Hollow', 'Hello', 'Hellos', 'Hallows',
// 'Henlow', 'Mellow', 'Yellow'
// ]
checker.dispose()checker.addWord('Hellow')checker.removeWord('Hellow')The library is bundled with pre-built addons, so recompilation shouldn't be needed.
If you still want to compile yourself, for a modification or a fork:
- In the
addonsdirectory, runnpm install, which would install the necessary build tools. Then runnpm run build-x64(x64) ornpm run build-arm64(arm64). - Resulting binaries should be written to the
addons/bindirectory
MIT