Urara-Blog/node_modules/.pnpm-store/v3/files/d1/1790a1986bba027ab8510a2c5c8f3f8850fbf5999dd336b2706d150b3c34b1a1b3f4df15ce276d0c45859f6e39f0e65e03622f4a1c3d20871a3f1049dd9019
2022-08-14 01:14:53 +08:00

28 lines
562 B
Text

var toString = require('./toString');
/** Used to generate unique IDs. */
var idCounter = 0;
/**
* Generates a unique ID. If `prefix` is given, the ID is appended to it.
*
* @static
* @since 0.1.0
* @memberOf _
* @category Util
* @param {string} [prefix=''] The value to prefix the ID with.
* @returns {string} Returns the unique ID.
* @example
*
* _.uniqueId('contact_');
* // => 'contact_104'
*
* _.uniqueId();
* // => '105'
*/
function uniqueId(prefix) {
var id = ++idCounter;
return toString(prefix) + id;
}
module.exports = uniqueId;