Node
MIME library uses FreeDesktop shared-mime-info as database.
FreeDesktop shared mime info
contains a large number of common MIME types,
created by converting the existing KDE and GNOME databases to the new format and
merging them together. This database is more suitable for nodejs
desktop
applications.
This package’s building process converts freedesktop.org.xml.in
to a JSON
data file.
FreeDesktop Shared MIME Info database seem to be larger than IANA
standards,
include script files like Ruby
, Python
and many others.
The freedesktop
spec doesn’t seem to have these information.
Use lstat
, the following special file types are also supported
- “inode/directory”
- “inode/blockdevice”
- “inode/chardevice”
- “inode/symlink”
- “inode/fifo”
- “inode/socket”
mime-type
works for extension without leading dot, like
mime_type.lookup("html"); // "text/html"
but
shared_mime.lookup("html"); // false
The idea is that lookup
should mainly be used to determine the file type
according to file’s extension. Under such considerations, “html” is a file
without any extension, even though it has a name like some valid extension. This
change avoids the following issue:
shared_mime.lookup("/home/me/Desktop"); // "inode/directory" not "application/x-desktop"
shared_mime.lookup("some.pdf.gz") // "application/x-gzpdf"
but only two-part extensions
shared_mime.lookup("some.vm.pdf.gz") // "application/x-gzpdf"
npm install freedesktop-shared-mime
The library interface is similar to mime-types, with freedesktop-specific features like:
var shared_mime = require('freedesktop-shared-mime')
shared_mime.lookup(".") // "inode/directory"
shared_mime.lookup("nonexistent_dir/") // "inode/directory"
shared_mime.aliases("text/x-gettext-translation") // ["text/x-po", "application/x-gettext"]
shared_mime.supertype("application/epub+zip") // "application/zip"
shared_mime.comment("application/x-jbuilder-project") // "JBuilder project"
shared_mime.generic_icon("application/rss+xml") // "text-html"
Do we have to use md
format?
use Istanbul
or others for coverage tests.