Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 23 additions & 13 deletions src/loadbuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,33 @@ function isProvide(node) {
return node[0] == 'call' && node[1] && node[1][1] == 'provide';
}

// Better typeof by Angus. See: http://javascriptweblog.wordpress.com/2011/08/08/fixing-the-javascript-typeof-operator/
var toType = function(obj) {
return ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase()
}

function excluded(item, loadbuilder) {
var excluded = false;
loadbuilder.options.exclude.forEach(function(excl) {
if (typeof(excl)=='string' && excl==item) {
excluded = true;
return;

function matchExclusion (pattern, item) {
var i, l, match = false;

if (toType(pattern) == 'string' && pattern == item) {
return true;
}
if (typeof(excl)=='object') {
excl.forEach(function(exclitem) {
if (exclitem == item) {
excluded = true;
return;
if (toType(pattern) == 'regexp' && pattern.test(item)) {
return true;
}
if (toType(pattern) == 'array') {
for (i = 0, l = pattern.length; i < l; i++) {
match = matchExclusion (pattern[i], item);
if (match) {
break;
}
});
}
return match;
}
});
return excluded;
}
return matchExclusion (loadbuilder.options.exclude, item);
}


Expand Down