New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement libmagic in JS #68
Comments
This is not something I intend to work on, but I asked for this issue to be opened in case someone wants a good challenge 🦄🤘 |
Out of curiosity would you want the database downloaded in a build step? Then parse it into js arrays, or let be to be parsed as a stream? Or downloaded post install then parsed in the user program? Not saying I'm going to do it. I'm just curious. :) |
I think it should be compiled to js for maximum speed. I tried to just make a simple runtime parser that loads the magdir files and parses them and then runs those rules on input files, but it was quite slow. And some of the rules in libmagic are quite obscure and tricky to implement correctly. And the detection of many popular file types uses these complicated rules... so i gave up 😅 |
Would the ideal js output be a structure that was meant to be consumed, or a full process with logic?
Looking at the magic database I would agree. |
There's another project, mmmagic, that uses node addons to keep from re-implementing everything in |
Cool! Great find @aaronArinder ! |
FYI, |
I'm gonna close this as I don't see enough value in adopting libmagic. This package already covers most popular formats now, without all the legacy of libmagic, and it also works in the browser. |
The holy grail would be to build a JS parser for the magic database from libmagic and bundle it in the module, so we don't have to reimplement all the format parsing manually in code.
libmagic is the database used by the "file" command in unix. However this is not trivial.
See:
The text was updated successfully, but these errors were encountered: