I am trying to check the spelling of individual words synchronously in Node.js. All of the libraries I have found (spellchecker, teacher, speller, ...) have asynchronous calls, and that doesn't work for me.
Here is the structure of my code:
function mycheck(w) {
spell.check(w, function(err, correct, suggestions) {
if (correct) {
return true;
}
else {
return false;
}
});
}
The problem is, mycheck is always undefined, because spell.check is asynchronous. Also, I can't just make mycheck be asynchronous, because that doesn't fit with the rest of my program.
Is there another way to spell check (synchronously) or a way to make this work synchronously? I am ok with using some kind of "helper" package to make the function synchronous.
Thanks so much! :D
Node.JS is an asynchronous language, don't try and force it to become synchronous, make mycheck async instead, and adapt the rest of your application before it can't be salvaged anymore