Skip to content

Commit 635afae

Browse files
committed
add cljs.core/random-uuid
1 parent 25e4945 commit 635afae

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/main/cljs/cljs/core.cljs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9534,6 +9534,19 @@ Maps become Objects. Arbitrary keys are encoded to by key->js."
95349534
(defn uuid [s]
95359535
(UUID. s nil))
95369536

9537+
(defn random-uuid []
9538+
(letfn [(hex [] (.toString (rand-int 15) 16))]
9539+
(let [rhex (.toString (bit-or 0x8 (bit-and 0x3 (rand-int 14))) 16)]
9540+
(uuid
9541+
(str (hex) (hex) (hex) (hex)
9542+
(hex) (hex) (hex) (hex) "-"
9543+
(hex) (hex) (hex) (hex) "-"
9544+
"4" (hex) (hex) (hex) "-"
9545+
rhex (hex) (hex) (hex) "-"
9546+
(hex) (hex) (hex) (hex)
9547+
(hex) (hex) (hex) (hex)
9548+
(hex) (hex) (hex) (hex))))))
9549+
95379550
;;; ExceptionInfo
95389551

95399552
(defn- pr-writer-ex-info [obj writer opts]

0 commit comments

Comments
 (0)