remove Ox.Break

This commit is contained in:
rolux 2012-07-05 10:58:08 +02:00
commit bda90f6b6b
44 changed files with 152 additions and 165 deletions

View file

@ -84,15 +84,6 @@ this.Ox = function(value) {
return Ox.wrap(value);
};
/*@
Ox.Break <f> Breaks from `Ox.forEach` and `Ox.loop`
@*/
Ox.Break = function() {
throw Ox.BreakError;
};
Ox.BreakError = new SyntaxError('Illegal Ox.Break() statement');
/*@
Ox.load <f> Loads one or more modules
A module named "Foo" provides `Ox.Foo/Ox.Foo.js`, in which it defines one
@ -283,7 +274,7 @@ Ox.loop <f> For-loop, functional-style
step <n> Step value
fn <f> Iterator function
i <n> Counter value
> Ox.loop(10, function(i) { i == 4 && Ox.Break(); })
> Ox.loop(10, function(i) { if (i == 4) { return false; } })
4
> Ox.loop(0, 3, 2, function() {})
4
@ -295,17 +286,9 @@ Ox.loop = function() {
step = length == 4 ? arguments[2] : (start <= stop ? 1 : -1),
iterator = arguments[length - 1],
i;
try {
for (i = start; step > 0 ? i < stop : i > stop; i += step) {
// iterator(i);
if (iterator(i) === false) {
// console.warn('Returning false in Ox.loop is deprecated.');
break;
}
}
} catch (error) {
if (error !== Ox.BreakError) {
throw error;
for (i = start; step > 0 ? i < stop : i > stop; i += step) {
if (iterator(i) === false) {
break;
}
}
return i;