bpmn-elements
Version:
Executable workflow elements based on BPMN 2.0
25 lines (19 loc) • 543 B
JavaScript
const safePattern = /[./\\#*:\s]/g;
export function generateId() {
return Math.random().toString(16).substring(2, 12);
}
export function brokerSafeId(id) {
return id.replace(safePattern, '_');
}
export function getUniqueId(prefix) {
return `${brokerSafeId(prefix)}_${generateId()}`;
}
export function getOptionsAndCallback(optionsOrCallback, callback) {
let options;
if (typeof optionsOrCallback === 'function') {
callback = optionsOrCallback;
} else {
options = optionsOrCallback;
}
return [options, callback];
}