microsoft / vscode-languagedetection

An npm package that uses ML to detect source code languages
MIT License
116 stars 12 forks source link

Export the loadModel method #22

Open lawvs opened 8 months ago

lawvs commented 8 months ago

Loading the model can be time-consuming because it may need to be downloaded from the network.

It would be beneficial to make modelOperations.loadModel public. This would allow developers to preload the model as needed, even though we can also load the model by executing modelOperations.runModel('').

https://github.com/microsoft/vscode-languagedetection/blob/100acd12e5035fed1806b69a77faccc6432a81f3/lib/index.ts#L152-L170

Furthermore, a new isReady method is very helpful for developers.

public isReady() {
  return !!this._model;
}

By the way, this package is awesome! I deployed it in guesslang-worker and tried to use it in blocksuite and its performance was excellent.