COLLECTED BY
Organization:
Internet Archive
Focused crawls are collections of frequently-updated webcrawl data from narrow (as opposed to broad or wide) web crawls, often focused on a single domain or subdomain.
The Wayback Machine - https://web.archive.org/web/20201220222644/https://github.com/lodash/lodash/blob/master/uniqueId.js
Permalink
33 lines (29 sloc)
632 Bytes
/** Used to generate unique IDs. */
const idCounter = { }
/**
* Generates a unique ID. If `prefix` is given, the ID is appended to it.
*
* @since 0.1.0
* @category Util
* @param {string } [prefix=''] The value to prefix the ID with.
* @returns {string } Returns the unique ID.
* @see random
* @example
*
* uniqueId('contact_')
* // => 'contact_104'
*
* uniqueId()
* // => '105'
*/
function uniqueId ( prefix= '$lodash$' ) {
if ( !idCounter [ prefix ] ) {
idCounter [ prefix ] = 0
}
const id = ++ idCounter [ prefix ]
if ( prefix === '$lodash$' ) {
return `${ id } `
}
return `${ prefix } ${ id } `
}
export default uniqueId
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.