]> BookStack Code Mirror - bookstack/blobdiff - resources/js/services/util.js
Covered app icon setting with testing
[bookstack] / resources / js / services / util.js
index b44b7de6c2f62365e20fbddba8fda6b51115c0b8..1a56ebf6ce8595a29cab4f48fbd9422f9a9649a2 100644 (file)
@@ -6,9 +6,9 @@
  * N milliseconds. If `immediate` is passed, trigger the function on the
  * leading edge, instead of the trailing.
  * @attribution https://davidwalsh.name/javascript-debounce-function
- * @param func
- * @param wait
- * @param immediate
+ * @param {Function} func
+ * @param {Number} wait
+ * @param {Boolean} immediate
  * @returns {Function}
  */
 export function debounce(func, wait, immediate) {
@@ -60,4 +60,14 @@ export function escapeHtml(unsafe) {
         .replace(/>/g, ">")
         .replace(/"/g, """)
         .replace(/'/g, "'");
+}
+
+/**
+ * Generate a random unique ID.
+ *
+ * @returns {string}
+ */
+export function uniqueId() {
+    const S4 = () => (((1+Math.random())*0x10000)|0).toString(16).substring(1);
+    return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4());
 }
\ No newline at end of file