UNPKG

feeles-ide

Version:

The hackable and serializable IDE to make learning material

20 lines (16 loc) 1.45 kB
import _toConsumableArray from 'babel-runtime/helpers/toConsumableArray'; import _slicedToArray from 'babel-runtime/helpers/slicedToArray'; import _Map from 'babel-runtime/core-js/map'; export default function validateType(name, mimeType) { return types.has(name) && types.get(name).test(mimeType); } var mimes = new _Map([['none', /^$/i], ['text', /^text\/plain$/i], ['html', /^text\/html$/i], ['css', /^text\/css$/i], ['javascript', /^(text|application)\/javascript$/i], ['json', /^(text|application)\/json$/i], ['yaml', /^text\/(x-)?yaml/], ['markdown', /^text\/(x-)?markdown$/i], ['glsl', /^text\/(x-)?glsl/i], ['image', /^image\/.*$/i], ['audio', /^audio\/.*$/i]]); var metas = [['text', [mimes.get('none'), mimes.get('text'), mimes.get('html'), mimes.get('css'), mimes.get('javascript'), mimes.get('json'), mimes.get('yaml'), mimes.get('markdown'), mimes.get('glsl')]], ['blob', [mimes.get('image'), mimes.get('audio')]], ['config', [mimes.get('json')]], ['*', [/.*/]], ['.text.plane', [mimes.get('text')]], ['.text.html.basic', [mimes.get('html')]], ['.source.js', [mimes.get('javascript')]], ['.source.gfm', [mimes.get('markdown')]]].map(function (_ref) { var _ref2 = _slicedToArray(_ref, 2), key = _ref2[0], regExps = _ref2[1]; return [key, new RegExp(regExps.map(function (regExp) { return regExp.source; }).join('|'), 'i')]; }); var types = new _Map([].concat(_toConsumableArray(mimes), _toConsumableArray(metas)));