diff options
Diffstat (limited to 'resources/app/node_modules/ext-name/index.js')
-rw-r--r-- | resources/app/node_modules/ext-name/index.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/resources/app/node_modules/ext-name/index.js b/resources/app/node_modules/ext-name/index.js new file mode 100644 index 0000000..59ac1f6 --- /dev/null +++ b/resources/app/node_modules/ext-name/index.js @@ -0,0 +1,31 @@ +'use strict'; +const extList = require('ext-list'); +const sortKeysLength = require('sort-keys-length'); + +module.exports = str => { + const obj = sortKeysLength.desc(extList()); + const exts = Object.keys(obj).filter(x => str.endsWith(x)); + + if (exts.length === 0) { + return []; + } + + return exts.map(x => ({ + ext: x, + mime: obj[x] + })); +}; + +module.exports.mime = str => { + const obj = sortKeysLength.desc(extList()); + const exts = Object.keys(obj).filter(x => obj[x] === str); + + if (exts.length === 0) { + return []; + } + + return exts.map(x => ({ + ext: x, + mime: obj[x] + })); +}; |