/**
* Copyright IBM Corp. 2020, 2022
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
/**
* Stores the latast id to increment
*
* @type {number} Number stored for the next ID
* @private
*/
var _lastId = 0;
/**
* Creates a unique ID to use
*
* @param {string=} prefix Prefix to set for the id
* @returns {string} Unique ID
* @example
* import { uniqueid } from '@carbon/ibmdotcom-utilities';
*
* const id1 = uniqueid(); // id1
* const id2 = uniqueid(); // id2
* const id3 = uniqueid('prefix'); // prefix3
* const id4 = uniqueid('prefix-'); // prefix-4
*/
function uniqueid() {
var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'id';
_lastId++;
return "".concat(prefix).concat(_lastId);
}
export default uniqueid;