1.1.0 • Published 7 years ago

plasma.mime v1.1.0

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

plasma.mime

license npm npm

plasma.mime is a simple mime type utility.

It uses the mime-db package as a source of mime type information.

Installation

npm install plasma.mime

Content Type Lookup

The contentType function provides a simple mechanism to get a content type name by file extension. Previous lookup results are cached by default to decrease lookup time for the same extension next time.

const { contentType } = require('plasma.mime');

The first parameter is the extension name to lookup.

contentType('css'); // -> 'text/css'

// A single leading dot is allowed:
contentType('.json'); // -> 'application/json'

// Setting the second parameter to false performs a lookup without using the cache:
contentType('css', false); // -> 'text/css'

// Failed lookups will return null:
contentType('.no-such-extname'); // -> null
1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

2.2.0

7 years ago