]> BookStack Code Mirror - bookstack/blobdiff - resources/js/services/util.js
respective book and chapter structure added.
[bookstack] / resources / js / services / util.js
index 942456d9dedb475ce3e6e05ad0a06ccdf2513ffd..1264d105860e11ae68e9f7d53cbbfd02ea878837 100644 (file)
@@ -84,6 +84,17 @@ export function uniqueId() {
     return (`${S4() + S4()}-${S4()}-${S4()}-${S4()}-${S4()}${S4()}${S4()}`);
 }
 
+/**
+ * Generate a random smaller unique ID.
+ *
+ * @returns {string}
+ */
+export function uniqueIdSmall() {
+    // eslint-disable-next-line no-bitwise
+    const S4 = () => (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
+    return S4();
+}
+
 /**
  * Create a promise that resolves after the given time.
  * @param {int} timeMs