Skip to content

Commit a5af1c1

Browse files
committed
add util.uuid
1 parent 7e051af commit a5af1c1

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

Functional.moon

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,12 @@ _util = {
726726
s = delta/v
727727
h = 60*(r == v and (g-b)/delta or g == v and (b-r)/delta + 2 or (r-g)/delta + 4)
728728
return h > 0 and h or h+360, s, v/255
729+
730+
uuid: ->
731+
-- https://gist.github.com/jrus/3197011
732+
"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"\gsub "[xy]", (c) ->
733+
v = c == "x" and math.random(0, 0xf) or math.random 8, 0xb
734+
return "%x"\format v
729735
}
730736

731737
_unicode = {

0 commit comments

Comments
 (0)