cleanup: rm iQ.grep; using .filter instead.

This commit is contained in:
Michael Yoshitaka Erlewine 2010-07-13 20:23:04 -04:00
parent 0782572076
commit 426e63d8c5
2 changed files with 6 additions and 22 deletions

View File

@ -996,22 +996,6 @@ iQ.extend({
return first;
},
// ----------
// Function: grep
grep: function( elems, callback, inv ) {
var ret = [];
// Go through the array, only saving the items
// that pass the validator function
for ( var i = 0, length = elems.length; i < length; i++ ) {
if ( !inv !== !callback( elems[ i ], i ) ) {
ret.push( elems[ i ] );
}
}
return ret;
},
// ----------
// Function: timeout
// wraps setTimeout with try/catch

View File

@ -386,7 +386,7 @@ window.Subscribable.prototype = {
this.subscribers[eventName] = [];
var subs = this.subscribers[eventName];
var existing = iQ.grep(subs, function(element) {
var existing = subs.filter(function(element) {
return element.refObject == refObject;
});
@ -408,9 +408,9 @@ window.Subscribable.prototype = {
if (!this.subscribers[eventName])
return;
this.subscribers[eventName] = iQ.grep(this.subscribers[eventName], function(element) {
return element.refObject == refObject;
}, true);
this.subscribers[eventName] = this.subscribers[eventName].filter(function(element) {
return element.refObject != refObject;
});
},
// ----------
@ -458,8 +458,8 @@ window.Subscribable.prototype = {
return;
this.onCloseSubscribers = this.onCloseSubscribers.filter(function(element) {
return element.referenceElement == referenceElement;
}, true);
return element.referenceElement != referenceElement;
});
},
// ----------