@atlaskit/adf-schema
Version:
Shared package that contains the ADF-schema (json) and ProseMirror node/mark specs
15 lines • 454 B
JavaScript
export const generateUuid = () =>
// @ts-ignore TS1501: This regular expression flag is only available when targeting 'es6' or later.
'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/gu, c => {
const r = Math.random() * 16 | 0;
return (c === 'x' ? r : r & 0x3 | 0x8).toString(16);
});
let staticValue = false;
export const uuid = {
setStatic(value) {
staticValue = value;
},
generate() {
return staticValue || generateUuid();
}
};