mirror of
https://github.com/crazy-max/ghaction-upx.git
synced 2024-12-24 17:16:08 -07:00
32 lines
579 B
JavaScript
32 lines
579 B
JavaScript
|
'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]
|
||
|
}));
|
||
|
};
|