update SpellChecker from nodehun v2 to nodehun v3 (#223)

* update SpellChecker from nodehun v2 to nodehun v3
This commit is contained in:
EugeneZverev
2020-11-18 09:00:20 +03:00
committed by GitHub
parent c300a9221c
commit c538bf53c7
3 changed files with 20 additions and 9 deletions

View File

@ -270,9 +270,17 @@
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz",
"integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk="
},
"node-addon-api": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-3.0.2.tgz",
"integrity": "sha512-+D4s2HCnxPd5PjjI0STKwncjXTUKKqm74MDMz9OPXavjsGmjkvwgLtA5yoxJUdmpj52+2u+RrXgPipahKczMKg=="
},
"nodehun": {
"version": "git+https://git@github.com/ONLYOFFICE/nodehun.git#631d3f3c48500bf2f2ec44f8a676423d5c92e3d3",
"from": "git+https://git@github.com/ONLYOFFICE/nodehun.git#631d3f3c48500bf2f2ec44f8a676423d5c92e3d3"
"version": "git+https://git@github.com/ONLYOFFICE/nodehun.git#30616cbcced690df879ea978771829ae4c04d340",
"from": "git+https://git@github.com/ONLYOFFICE/nodehun.git#30616cbcced690df879ea978771829ae4c04d340",
"requires": {
"node-addon-api": "*"
}
},
"on-finished": {
"version": "2.3.0",

View File

@ -8,7 +8,7 @@
"co": "^4.6.0",
"config": "^2.0.1",
"express": "^4.16.4",
"nodehun": "git+https://git@github.com/ONLYOFFICE/nodehun.git#631d3f3c48500bf2f2ec44f8a676423d5c92e3d3",
"nodehun": "git+https://git@github.com/ONLYOFFICE/nodehun.git#30616cbcced690df879ea978771829ae4c04d340",
"sockjs": "^0.3.19"
},
"pkg": {

View File

@ -54,6 +54,7 @@ function spell(type, word, id) {
} else {
if (arrExistDictionaries[id]) {
let pathTmp = path.join(pathDictionaries, allLanguages[id], allLanguages[id] + '.');
dict = arrDictionaries[id] = new nodehun(pathTmp + 'aff', pathTmp + 'dic');
}
}
@ -61,13 +62,15 @@ function spell(type, word, id) {
if (dict) {
if ("spell" === type) {
// use setImmediate because https://github.com/nodejs/node/issues/5691
dict.isCorrect(word, function (err, correct, origWord) {
return setImmediate(resolve, !err && correct);
});
dict.spell(word)
.then(isCorrect => {
return setImmediate(resolve, isCorrect);
});
} else if ("suggest" === type) {
dict.spellSuggestions(word, function (err, correct, suggestions, origWord) {
return setImmediate(resolve, suggestions);
});
dict.suggest(word)
.then(suggestions => {
return setImmediate(resolve, suggestions);
});
}
} else {
return setImmediate(resolve, true);