2.0.0 • Published 8 years ago

mime-nofs v2.0.0

Weekly downloads
771
License
MIT
Repository
github
Last release
8 years ago

mime-nofs

Comprehensive MIME type mapping API based on mime-db module.


Build Status Build Status NPM version

This is a fork of node-mime from Robert Kieffer (broofa).
I removed the file-system dependency to be able to use it within the browser and other system.
Added a prioritization of non ???/x-??? mime types to fulfill the tests.

NPM


Install

Install with npm:

npm install mime-nofs

Contributing / Testing

npm run test

Command Line

mime [path_string]

E.g.

> mime scripts/jquery.js
application/javascript

API - Queries

mime.lookup(path)

Get the mime type associated with a file, if no mime type is found application/octet-stream is returned. Performs a case-insensitive lookup using the extension in path (the substring after the last '/' or '.'). E.g.

var mime = require('mime');

mime.lookup('/path/to/file.txt');         // => 'text/plain'
mime.lookup('file.txt');                  // => 'text/plain'
mime.lookup('.TXT');                      // => 'text/plain'
mime.lookup('htm');                       // => 'text/html'

mime.default_type

Sets the mime type returned when mime.lookup fails to find the extension searched for. (Default is application/octet-stream.)

mime.extension(type)

Get the default extension for type

mime.extension('text/html');                 // => 'html'
mime.extension('application/octet-stream');  // => 'bin'

mime.charsets.lookup()

Map mime-type to charset

mime.charsets.lookup('text/plain');        // => 'UTF-8'

(The logic for charset lookups is pretty rudimentary. Feel free to suggest improvements.)

API - Defining Custom Types

Custom type mappings can be added on a per-project basis via the following APIs.

mime.define()

Add custom mime/extension mappings

mime.define({
    'text/x-some-format': ['x-sf', 'x-sft', 'x-sfml'],
    'application/x-my-type': ['x-mt', 'x-mtt'],
    // etc ...
});

mime.lookup('x-sft');                 // => 'text/x-some-format'

The first entry in the extensions array is returned by mime.extension(). E.g.

mime.extension('text/x-some-format'); // => 'x-sf'

Release History

VersionDateDescription
2.0.02015-11-06initial fork from (node-mime 1.3.4)https://github.com/broofa/node-mime/releases/tag/v1.3.4; Changed build to js file; Removed load method; Added prioritization of non ???/x-??? mime types;

NPM

Other projects

NameDescription
aws-s3-formGenerate a signed and ready to use formdata to put files to s3 directly from the browser. Signing is done by using AWS Signature Version 4
node-cacheSimple and fast NodeJS internal caching. Node internal in memory cache like memcached.
domelA simple dom helper if you want to get rid of jQuery
backlunrA solution to bring Backbone Collections together with the browser fulltext search engine Lunr.js
obj-schemaSimple module to validate an object by a predefined schema
rsmqA really simple message queue based on Redis
rsmq-clia terminal client for rsmq
rest-rsmqREST interface for.
redis-notificationsA redis based notification engine. It implements the rsmq-worker to safely create notifications and recurring reports.
redis-sessionsAn advanced session store for NodeJS and Redis
connect-redis-sessionsA connect or express middleware to simply use the redis sessions. With redis sessions you can handle multiple sessions per user_id.
systemhealthNode module to run simple custom checks for your machine or it's connections. It will use redis-heartbeat to send the current state to redis.
task-queue-workerA powerful tool for background processing of tasks that are run by making standard http requests.
soyerSoyer is small lib for serverside use of Google Closure Templates with node.js.
grunt-soy-compileCompile Goggle Closure Templates ( SOY ) templates inclding the handling of XLIFF language files.

The MIT License (MIT)

Copyright © 2015 M. Peter

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.