unique-id.js 262 B

1234567891011121314
  1. var uniqueId = function () {
  2. var map = {};
  3. return function (prefix) {
  4. prefix = prefix || 'g';
  5. if (!map[prefix]) {
  6. map[prefix] = 1;
  7. } else {
  8. map[prefix] += 1;
  9. }
  10. return prefix + map[prefix];
  11. };
  12. }();
  13. module.exports = uniqueId;