Skip to content

Commit

Permalink
go back to closure instead of using bind for match function
Browse files Browse the repository at this point in the history
  • Loading branch information
Isao Yagi committed Jul 12, 2013
1 parent d586b2d commit 543c3ac
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion index.js
Expand Up @@ -34,6 +34,18 @@ function arrayify(arg) {
});
}

/**
* Close a string over a str.match, because str.match can't be used as a
* functor, and using String.prototype.match.bind(str) is expensive.
* @param {string} string to match
* @return {function} for use as argument to ignore.some()
*/
function match(str) {
return function(re) {
return str.match(re);
}
}

/**
* @constructor
* @param {array} ignore Array of strings or regexes for exclusion matching
Expand Down Expand Up @@ -116,7 +128,7 @@ Scan.prototype.getStatCb = function(item, list) {
type = 'error';
self.errors++;

} else if (self.ignore.some(''.match.bind(item))) {
} else if (self.ignore.some(match(item))) {
type = 'ignored';

} else {
Expand Down

0 comments on commit 543c3ac

Please sign in to comment.