primevue-mirror/components/lib/utils/UniqueComponentId.js

12 lines
214 B
JavaScript
Raw Normal View History

const lastIds = {};
2019-10-08 11:22:32 +00:00
export default function (prefix = 'pv_id_') {
if (!lastIds.hasOwnProperty(prefix)) {
lastIds[prefix] = 0;
}
2022-09-14 11:26:01 +00:00
lastIds[prefix]++;
return `${prefix}${lastIds[prefix]}`;
2022-09-14 11:26:01 +00:00
}