id-generator.js 309 B

123456789101112131415161718
  1. "use strict";
  2. module.exports = function() {
  3. var idCount = 1;
  4. /**
  5. * Generates a new unique id in the context.
  6. * @public
  7. * @returns {number} A unique id in the context.
  8. */
  9. function generate() {
  10. return idCount++;
  11. }
  12. return {
  13. generate: generate
  14. };
  15. };