cfinke / Typo.js

A client-side JavaScript spellchecker that uses Hunspell-style dictionaries.
Other
501 stars 110 forks source link

Asynchronous file load using the file protocol (file://) #43

Open gevyaniv opened 8 years ago

gevyaniv commented 8 years ago

Thank you for taking the time to develop this library.

A small issue I found: In the _readFile method, the code is checking for status 200 (line 238) in order to resolve the promise. Some environments, like Cordova iOS, return status 0 as success. See the following post. Adding (req.status === 200 || req.status === 0) can solve the problem.

It would also be great if you can if you can return the Promise all the way to the initial load of the library. I think is the Typo constructor that calls the readDataFile. This will give the user the option to handle Promise rejections, which are not currently handled by the library.

kofifus commented 8 years ago

see promise implementation here https://github.com/cfinke/Typo.js/pull/50