You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
317 B
15 lines
317 B
'use strict';
|
|
|
|
const mimeTypes = require('mime-types');
|
|
const LRU = require('ylru');
|
|
|
|
const typeLRUCache = new LRU(100);
|
|
|
|
module.exports = type => {
|
|
let mimeType = typeLRUCache.get(type);
|
|
if (!mimeType) {
|
|
mimeType = mimeTypes.contentType(type);
|
|
typeLRUCache.set(type, mimeType);
|
|
}
|
|
return mimeType;
|
|
};
|
|
|