Created
October 21, 2010 14:34
-
-
Save arieh/638585 to your computer and use it in GitHub Desktop.
Adds a Break function to $each (Mootools 1.3)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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