-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
spellSuggest, promises, and express #55
Comments
Very similar to nodejs/node#5691 |
Hi @samartioli, thanks for reporting this and the great example you've setup! I was able to reproduce this on linux! I tested this with the new In the next version, Below, I briefly outline some of the changes I made in order to test the
function spellSuggestPromise(utterance) {
return new Promise(function(resolve, reject) {
dict.suggest(utterance, function(err, correct, suggestion, origWord) { // 1
console.log(err, correct, suggestion, origWord);
if (err) {
// return setImmediate(reject, error);
return reject(error);
}
if (suggestion.length > 0) { // 2
return resolve(suggestion[0]); // 3
// return setImmediate(resolve, suggestion);
}
return resolve(utterance);
// return setImmediate(resolve, origWord);
});
});
} Again, thanks for your patience and time setting up |
I am currently experiencing this with the master branch, and resorting to using setImmediate for now. Should I be using the |
The NAN implementation isn't complete (see #37). I'll look into this in the master branch. |
@Wulf any update on this? Hunspell.prototype.isCorrectP = function(word) {
var self = this;
return new Promise(function(resolve, reject) {
self.dictionary.isCorrect(word, function(err, correct, origWord){
// because "color" is a defined word in the US English dictionary
// the output will be: null, true, "color"
if(err) reject(err)
else return setImmediate(resolve, correct);
});
});
};
Hunspell.prototype.spellSuggestionsP = function(word) {
var self = this;
return new Promise(function(resolve, reject) {
self.dictionary.spellSuggestions(word, function(err, correct, suggestions, origWord){
// because "calor" is not a defined word in the US English dictionary
// the output will be: null, false, [ 'carol','valor','color','cal or','cal-or','caloric','calorie'], 'calor'
if(err) reject(err)
else return setImmediate(resolve, suggestions);
});
});
};
Hunspell.prototype.stemP = function(word) {
var self = this;
return new Promise(function(resolve, reject) {
self.dictionary.stem(word, function(err, stems){
// the output will be: null, [telling, tell]
if(err) reject(err)
else return setImmediate(resolve, stems);
});
});
}; |
@samartioli @ashutoshrishi @loretoparisi thanks for your patience everyone. Async methods return If you're still around, please let me know if the new version fixes the issue:
The API has changed a bit, but feel free to reference the type declaration file. |
I got a chance to verify that this doesn't occur with Nodehun v3 on node version 10, 11 and 12. I changed the definition of the
Thanks again for reporting this in a detailed manner and making it easy for us to reproduce the error. I'm going to close this issue, but feel free to reopen it or continue the discussion. |
spellSuggest does not behave as expected when the callback is wrapped in a promise.
I created a repo to demonstrate the issue
The text was updated successfully, but these errors were encountered: