main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
560 bytes
|
Rev | Line | |
---|
[d565449] | 1 | import toString from './toString.js';
|
---|
| 2 |
|
---|
| 3 | /** Used to generate unique IDs. */
|
---|
| 4 | var idCounter = 0;
|
---|
| 5 |
|
---|
| 6 | /**
|
---|
| 7 | * Generates a unique ID. If `prefix` is given, the ID is appended to it.
|
---|
| 8 | *
|
---|
| 9 | * @static
|
---|
| 10 | * @since 0.1.0
|
---|
| 11 | * @memberOf _
|
---|
| 12 | * @category Util
|
---|
| 13 | * @param {string} [prefix=''] The value to prefix the ID with.
|
---|
| 14 | * @returns {string} Returns the unique ID.
|
---|
| 15 | * @example
|
---|
| 16 | *
|
---|
| 17 | * _.uniqueId('contact_');
|
---|
| 18 | * // => 'contact_104'
|
---|
| 19 | *
|
---|
| 20 | * _.uniqueId();
|
---|
| 21 | * // => '105'
|
---|
| 22 | */
|
---|
| 23 | function uniqueId(prefix) {
|
---|
| 24 | var id = ++idCounter;
|
---|
| 25 | return toString(prefix) + id;
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | export default uniqueId;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.