Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit fbb8bba

Browse files
authored
Merge pull request #2 from atom/master
Catch up with atom/node-spellchecker.
2 parents df90479 + a03caf3 commit fbb8bba

14 files changed

+687
-540
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ env:
3232
matrix:
3333
- NODE_VERSION=8.9.3
3434
- NODE_VERSION=10
35+
- NODE_VERSION=12

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,42 @@ When using Hunspell, this will not modify the .dic file; new words must be added
5454
`word` - String word to add.
5555

5656
Returns nothing.
57+
58+
### new Spellchecker()
59+
60+
In addition to the above functions that are used on a default instance, a new instance of SpellChecker can be instantiated with the use of the `new` operator. The same methods are available with the instance but the dictionary and underlying API can be changed independently from the default instance.
61+
62+
```javascript
63+
const checker = new SpellChecker.Spellchecker()
64+
```
65+
66+
#### SpellChecker.Spellchecker.setSpellcheckerType(type)
67+
68+
Overrides the library selection for checking. Without this, the checker will use [Hunspell](http://hunspell.github.io/) on Linux, the [Spell Checking API](https://docs.microsoft.com/en-us/windows/desktop/intl/spell-checker-api) for Windows, and [NSSpellChecker](https://developer.apple.com/documentation/appkit/nsspellchecker) on Macs.
69+
70+
If the environment variable `SPELLCHECKER_PREFER_HUNSPELL` is set to any value, the library will fallback to always using the Hunspell implementation.
71+
72+
This is the same behavior as calling `setSpellcheckerType` with the `USE_SYSTEM_DEFAULTS` constant:
73+
74+
```coffeescript
75+
checker = new SpellChecker.Spellchecker
76+
checker.setSpellcheckerType SpellChecker.USE_SYSTEM_DEFAULTS
77+
```
78+
79+
To always use the system API and not fallback to Hunspell regardless of the environment variable, use the `ALWAYS_USE_SYSTEM` constant:
80+
81+
```coffeescript
82+
checker = new SpellChecker.Spellchecker
83+
checker.setSpellcheckerType SpellChecker.ALWAYS_USE_SYSTEM
84+
```
85+
86+
Likewise, Hunspell can be forced with the `ALWAYS_USE_HUNSPELL` constant.
87+
88+
```javascript
89+
const checker = new SpellChecker.Spellchecker();
90+
checker.setSpellcheckerType(SpellChecker.ALWAYS_USE_SYSTEM);
91+
```
92+
93+
On Linux, Hunspell is always used regardless of the setting. This method must also be called before any spelling is done otherwise it will throw an error.
94+
95+
This returns nothing.

appveyor.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ environment:
44
- nodejs_version: '10'
55
SPELLCHECKER_PREFER_HUNSPELL: true
66
- nodejs_version: '8'
7-
- nodejs_version: '6'
87

98
install:
109
- ps: Install-Product node $env:nodejs_version

lib/spellchecker.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,8 @@ module.exports = {
103103
getAvailableDictionaries: getAvailableDictionaries,
104104
getCorrectionsForMisspelling: getCorrectionsForMisspelling,
105105
getDictionaryPath: getDictionaryPath,
106-
Spellchecker: Spellchecker
106+
Spellchecker: Spellchecker,
107+
USE_SYSTEM_DEFAULTS: 0,
108+
ALWAYS_USE_SYSTEM: 1,
109+
ALWAYS_USE_HUNSPELL: 2,
107110
};

package-lock.json

Lines changed: 50 additions & 49 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"main": "./lib/spellchecker.js",
33
"name": "spellchecker",
44
"description": "Bindings to native spellchecker",
5-
"version": "3.5.3",
5+
"version": "3.7.0",
66
"license": "MIT",
77
"repository": {
88
"type": "git",
@@ -16,10 +16,10 @@
1616
"test": "jasmine-focused --captureExceptions --coffee spec/"
1717
},
1818
"devDependencies": {
19-
"jasmine-focused": "1.x"
19+
"jasmine-focused": "^1.0.7"
2020
},
2121
"dependencies": {
2222
"any-promise": "^1.3.0",
23-
"nan": "^2.10.0"
23+
"nan": "^2.14.0"
2424
}
2525
}

0 commit comments

Comments
 (0)