Skip to content

Instantly share code, notes, and snippets.

@dhigginbotham
Last active August 29, 2015 14:14
Show Gist options
  • Save dhigginbotham/9508330bb79568a7500f to your computer and use it in GitHub Desktop.
Save dhigginbotham/9508330bb79568a7500f to your computer and use it in GitHub Desktop.
var supported = [
{
name: 'Html',
regex: /\.(html?)/gi
},{
name: 'Css',
regex: /\.(css)/gi
},{
name: 'Js',
regex: /\.(js)/gi
},{
name: 'Swf',
regex: /\.(swf)/gi
},{
name: 'Img',
regex: /\.(gif|png|jpe?g|bmp)/gi
}
];
var pub = {};
function makeTypes(done) {
if (supported.length > 0) {
var type = supported.shift()
pub['is' + type.name] = function(val) {
var match = val.match(type.regex);
return (match ? match.length > 0 : false);
};
makeTypes(done);
} else {
done(pub);
}
}
makeTypes(function(types) {
module.exports = types;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment