UniqueID.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. 'use strict';
  2. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3. /**
  4. * Licensed Materials - Property of IBM
  5. * IBM Business Analytics (C) Copyright IBM Corp. 2019
  6. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. */
  8. /**
  9. * @class UnionAPI
  10. * @hideconstructor
  11. * @classdesc Provides access to the the union object associated to this dataitem.
  12. */
  13. define([], function () {
  14. var idCounter = 0;
  15. var lastIdDate = new Date().valueOf();
  16. return function () {
  17. function UniqueId() {
  18. _classCallCheck(this, UniqueId);
  19. }
  20. UniqueId.generate = function generate(prefix) {
  21. var date = new Date().valueOf();
  22. if (date !== lastIdDate) {
  23. idCounter = 0;
  24. lastIdDate = date;
  25. } else {
  26. idCounter++;
  27. }
  28. var datePart = ('0000000000000000' + date.toString(16)).slice(-16);
  29. var countPart = ('00000000' + idCounter.toString(16)).slice(-8);
  30. return [prefix, datePart, '_', countPart].join('');
  31. };
  32. return UniqueId;
  33. }();
  34. });
  35. //# sourceMappingURL=UniqueID.js.map