UNPKG

@logicflow/extension

Version:
32 lines (31 loc) 930 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getBpmnId = exports.IDs = void 0; var IDs = /** @class */ (function () { function IDs() { globalThis._ids = this; this._ids = new Set(); } IDs.prototype.generateId = function () { return 'xxxxxxx'.replace(/[x]/g, function (c) { var r = (Math.random() * 16) | 0; var v = c === 'x' ? r : (r & 0x3) | 0x8; return v.toString(16); }); }; IDs.prototype.next = function () { var id = this.generateId(); while (this._ids.has(id)) { id = this.generateId(); } this._ids.add(id); return id; }; return IDs; }()); exports.IDs = IDs; var ids = (globalThis === null || globalThis === void 0 ? void 0 : globalThis._ids) || new IDs(); function getBpmnId() { return ids.next(); } exports.getBpmnId = getBpmnId;