Created
July 7, 2019 12:00
-
-
Save ungarson/c0bbf1285bc49935db0a6d4dca004610 to your computer and use it in GitHub Desktop.
ID generation in javascript
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
export default function* generateIDS(fromID) { | |
while (true) { | |
yield fromID++; | |
} | |
} | |
// Example of usage | |
// const generator = generateIDS(0); | |
// const MichaelID = generator.next().value; | |
// const DimaID = generator.next().value; | |
// console.log(MichaelID); // 0 | |
// console.log(DimaID); // 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment