Sha256: 5526b1388b92c2ac6d80da02d1602e20023644b61eb5d09a84ce9fad464ad328

Contents?: true

Size: 562 Bytes

Versions: 302

Compression:

Stored size: 562 Bytes

Contents

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;

Version data entries

302 entries across 278 versions & 33 rubygems

Version Path
babel-schmooze-sprockets-0.1.1 node_modules/babel-plugin-transform-es2015-modules-commonjs/node_modules/lodash/uniqueId.js
babel-schmooze-sprockets-0.1.1 node_modules/babel-plugin-transform-es2015-function-name/node_modules/lodash/uniqueId.js
babel-schmooze-sprockets-0.1.1 node_modules/babel-plugin-transform-es2015-duplicate-keys/node_modules/lodash/uniqueId.js
babel-schmooze-sprockets-0.1.1 node_modules/babel-plugin-transform-es2015-classes/node_modules/lodash/uniqueId.js
babel-schmooze-sprockets-0.1.1 node_modules/babel-plugin-transform-es2015-block-scoping/node_modules/lodash/uniqueId.js
babel-schmooze-sprockets-0.1.1 node_modules/babel-helper-replace-supers/node_modules/lodash/uniqueId.js
babel-schmooze-sprockets-0.1.1 node_modules/babel-helper-regex/node_modules/lodash/uniqueId.js
babel-schmooze-sprockets-0.1.1 node_modules/babel-helper-optimise-call-expression/node_modules/lodash/uniqueId.js
babel-schmooze-sprockets-0.1.1 node_modules/babel-helper-hoist-variables/node_modules/lodash/uniqueId.js
babel-schmooze-sprockets-0.1.1 node_modules/babel-plugin-transform-regenerator/node_modules/lodash/uniqueId.js
babel-schmooze-sprockets-0.1.1 node_modules/babel-helper-function-name/node_modules/lodash/uniqueId.js
babel-schmooze-sprockets-0.1.1 node_modules/babel-helper-define-map/node_modules/lodash/uniqueId.js
babel-schmooze-sprockets-0.1.1 node_modules/babel-helper-call-delegate/node_modules/lodash/uniqueId.js
babel-schmooze-sprockets-0.1.1 node_modules/babel-generator/node_modules/lodash/uniqueId.js
babel-schmooze-sprockets-0.1.1 node_modules/babel-core/node_modules/lodash/uniqueId.js
babel-schmooze-sprockets-0.1.1 node_modules/babel-plugin-transform-strict-mode/node_modules/lodash/uniqueId.js
babel-schmooze-sprockets-0.1.1 node_modules/babel-register/node_modules/lodash/uniqueId.js
babel-schmooze-sprockets-0.1.1 node_modules/babel-template/node_modules/lodash/uniqueId.js
babel-schmooze-sprockets-0.1.1 node_modules/babel-helper-get-function-arity/node_modules/lodash/uniqueId.js
babel-schmooze-sprockets-0.1.1 node_modules/babel-plugin-transform-es2015-sticky-regex/node_modules/lodash/uniqueId.js