1790a1986bba027ab8510a2c5c8f3f8850fbf5999dd336b2706d150b3c34b1a1b3f4df15ce276d0c45859f6e39f0e65e03622f4a1c3d20871a3f1049dd9019 562 B

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;