Last active
May 10, 2017 12:14
-
-
Save schabluk/59d956f0705896f8bf1eafa8888651c0 to your computer and use it in GitHub Desktop.
Create ordinal numbers
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
class Store { | |
// Ordinal numbers sequence. | |
ordinal = null | |
// Ordinal numbers generator. | |
ordinalGenerator = function * () { | |
let i = 0 | |
while (true) { | |
yield i++ | |
} | |
} | |
constructor () { | |
// Initialize ordinal generator sequence. | |
this.ordinal = this.ordinalGenerator() | |
this.ordinal.next().value | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment