How to use the define function from mime

Find comprehensive JavaScript mime.define code examples handpicked from public code repositorys.

148
149
150
151
152
153
154
155
156
157
mime.getExtension('text/plain');               // ⇨ 'txt'
mime.getExtension('application/json');         // ⇨ 'json'
mime.getExtension('text/html; charset=utf8');  // ⇨ 'html'
```

### mime.define(typeMap[, force = false])

Define [more] type mappings.

`typeMap` is a map of type -> extensions, as documented in `new Mime`, above.
fork icon320
star icon0
watch icon21

8
9
10
11
12
13
14
15
16
17
// constants
const ENV = process.env;
const NODE_ENV = ENV.NODE_ENV || 'development';
const PUBLIC_DIR = path.join(__dirname, 'public');

const customMime = mime.define({
    'text/javascript': ['js']
}, true);

const STATIC_OPTS = {
fork icon268
star icon0
watch icon62

1
2
3
4
5
6
7
8
9
10

const mime = require('mime');
const charset = require('charset');


exports.define = mappings => mime.define(mappings, true);

let customGetType = (file, defaultValue) => null; // eslint-disable-line no-unused-vars

exports.setCustomGetType = (fn) => { customGetType = fn; };
fork icon200
star icon974
watch icon32