Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

uniqueId.js 562B

12345678910111213141516171819202122232425262728
  1. var toString = require('./toString');
  2. /** Used to generate unique IDs. */
  3. var idCounter = 0;
  4. /**
  5. * Generates a unique ID. If `prefix` is given, the ID is appended to it.
  6. *
  7. * @static
  8. * @since 0.1.0
  9. * @memberOf _
  10. * @category Util
  11. * @param {string} [prefix=''] The value to prefix the ID with.
  12. * @returns {string} Returns the unique ID.
  13. * @example
  14. *
  15. * _.uniqueId('contact_');
  16. * // => 'contact_104'
  17. *
  18. * _.uniqueId();
  19. * // => '105'
  20. */
  21. function uniqueId(prefix) {
  22. var id = ++idCounter;
  23. return toString(prefix) + id;
  24. }
  25. module.exports = uniqueId;