Skip to content

Instantly share code, notes, and snippets.

@arieh
Created October 21, 2010 14:34
Show Gist options
  • Save arieh/638585 to your computer and use it in GitHub Desktop.
Save arieh/638585 to your computer and use it in GitHub Desktop.
Adds a Break function to $each (Mootools 1.3)
function BreakException(){}
function Break(){throw new BreakException;}
(function(window,undef){
window['$each'] = function(obj,func,bind){
try{
switch (typeOf(obj)){
case 'object':
Object.each(obj,func,bind);
break;
case 'array':
Array.each(obj,func,bind);
break;
}
}catch (e){
if (false == (e instanceof BreakException)) throw e;
}
}
})(this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment