You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Synchronous reads are blocking and will stop your server from responding to subsequent requests while it completes. Not a big deal here, but in a real project it can be a problem. It's best to avoid synchronous operations if possible.
You are also reading the orderedDict.json every time you call the autocomplete function. This is quite inefficient.
A better solution which would avoid having to change the API of your autocomplete function to be asynchronous would be to read the orderedDict.json into memory when the server starts. Then your function would simply reference an in-memory object (relatively fast) instead of reading a file (relatively slow).
The text was updated successfully, but these errors were encountered:
functionstartServer(){dictionaryFile.readDictionary(null,null,function(){server.listen(port,function(){console.log("Dictionary loaded, server listening to port "+port+", ready to accept requests");});})}startServer();
Here: https://github.com/fac-u/autocompleter/blob/master/src/autocomplete.js#L7
Synchronous reads are blocking and will stop your server from responding to subsequent requests while it completes. Not a big deal here, but in a real project it can be a problem. It's best to avoid synchronous operations if possible.
You are also reading the
orderedDict.json
every time you call theautocomplete
function. This is quite inefficient.A better solution which would avoid having to change the API of your
autocomplete
function to be asynchronous would be to read theorderedDict.json
into memory when the server starts. Then your function would simply reference an in-memory object (relatively fast) instead of reading a file (relatively slow).The text was updated successfully, but these errors were encountered: