Skip to content

Instantly share code, notes, and snippets.

@erichocean
Created November 8, 2010 09:53
Show Gist options
  • Save erichocean/667530 to your computer and use it in GitHub Desktop.
Save erichocean/667530 to your computer and use it in GitHub Desktop.
/**
Invokes the callback for each index. Otherwise works just like regular
forEach().
@param {Function} callback
@param {Object} target
@returns {SC.IndexSet} receiver
*/
forEachIndex: function(callback, target) {
var content = this._content,
cur = 0,
source = this.source,
next = content[cur];
if (target === undefined) target = null ;
while (next !== 0) {
while(cur < next) {
callback.call(target, cur++, this, source) ;
}
cur = Math.abs(next);
next = content[cur];
}
return this ;
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment