diff --git a/Array.js b/Array.js index eb06803..23c9668 100644 --- a/Array.js +++ b/Array.js @@ -24,6 +24,9 @@ var STOP = module.STOP = object.STOP +var stoppable = +module.stoppable = + generator.stoppable //--------------------------------------------------------------------- @@ -492,7 +495,7 @@ object.Mixin('ArrayProtoMixin', 'soft', { // XXX this should handle throwing STOP!!! // ...might also ne a good idea to isolate the STOP mechanics // into a spearate module/package... - iter: function*(handler=undefined){ + iter: stoppable(function*(handler=undefined){ if(handler){ var i = 0 for(var e of this){ @@ -504,7 +507,7 @@ object.Mixin('ArrayProtoMixin', 'soft', { } else { yield res } } } else { - yield* this }}, + yield* this }}), // Stoppable iteration... diff --git a/generator.js b/generator.js index 26ceb96..81e2db1 100644 --- a/generator.js +++ b/generator.js @@ -86,6 +86,7 @@ var ITERATOR_PROTOTYPES = [ //--------------------------------------------------------------------- +// XXX should this be part of object??? var stoppable = module.stoppable = function(func){