r/node • • Oct 04 '23

My first Node Package: Efficient Language Detector

ELD is a fast and accurate natural language detector, written 100% in Javascript, no dependencies. I believe it is the fastest non compiled detector, at its level of accuracy.

https://github.com/nitotm/efficient-language-detector-js

I've been programming for years but this is the first time I publish a package, so I would appreciate any feedback you have on the project's structure, code quality, documentation, or any other aspect you feel could be improved.

6 Upvotes

2 comments sorted by

2

u/bernhorst Oct 30 '23

Hey Nito,

thanks for sharing your module, this is really useful!

Since you asked for comments, here are my two cents:

  • you are using top level await, making it harder for other projects to consume or bundle your library

  • exporting type declarations would probably increase adoption

I found this module because I had a pressing need to add language identification to one of my project and none of the existing libraries fit the bill - too slow, too inaccurate, or unable to bundle into a browser app.
Unfortunately, the top level await also prohibited me from bundling yours with esbuild. I was in a hurry, so instead of supplying pull-requests, I did a quick fork and refactor, I hope you don't mind. The result is a typescript port of eld with the subset handling ripped out (because I didn't need that), no browser build, and some other minor adjustments. I didn't publish it to npm, because I have no interest in starting a competing library, I just needed something that I could quickly integrate into my own project. Feel free to steal back anything you may find useful from here: https://github.com/bkw/eldr

Thanks again for sharing and apologies again for forking instead of collaborating properly. I tried to keep the license and references to your original project in place. Keep up the good work, the detection results and performance are top notch!

2

u/nitotm Oct 30 '23 edited Oct 30 '23

Hi, thanks.

I didn't like the "await" too much, but I did not find another way to deliver the functionality I wanted; So I will check your solution and I might implement it.

"exporting type declarations", the idea with this particular repository was to be Javascript vanilla, not sure if the best approach would be a separate Typescript repository, or have different versions on the same repo. What is your opinion?