Created
August 26, 2013 16:40
-
-
Save eduardo-matos/6343599 to your computer and use it in GitHub Desktop.
Infinite iterator in Dojo
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
| define('InfiniteIterator', [ | |
| 'dojox/collections/_base', | |
| 'dojo/_base/lang' | |
| ], function ( | |
| dxc, | |
| lang | |
| ) { | |
| 'use strict'; | |
| function InfiniteIterator(array) { | |
| var rawIterator = new dxc.Iterator(array); | |
| var customIterator = lang.delegate(this, rawIterator); | |
| customIterator.get = function () { | |
| this.atEnd()? this.reset(): ''; | |
| return rawIterator.get(arguments); | |
| } | |
| return customIterator; | |
| } | |
| return InfiniteIterator; | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment