aboutsummaryrefslogtreecommitdiff
path: root/uuid.lua
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-09-06 12:46:39 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-09-06 12:48:16 -0700
commita35d010dfe2b2769cf13ae508952c279aecb3aac (patch)
tree69ce1fcd0123832599d2766d361a8a8b43fcfb4b /uuid.lua
parente1bc075bb5319b3903f66e141810dcb9ef53042e (diff)
Removed the mandatory "_" prefix for Nomsu variables, renamed "list" and
"dict" to "List" and "Dict", or in Nomsu's environment, "_List" and "_Dict", removed uuid.lua and replaced it with core/id.nom for handling IDs.
Diffstat (limited to 'uuid.lua')
-rw-r--r--uuid.lua24
1 files changed, 0 insertions, 24 deletions
diff --git a/uuid.lua b/uuid.lua
deleted file mode 100644
index ac4df1e..0000000
--- a/uuid.lua
+++ /dev/null
@@ -1,24 +0,0 @@
--- A simple UUID function based on RFC 4122: http://www.ietf.org/rfc/rfc4122.txt
-local unpack = unpack or table.unpack
-local function uuid()
- local r = math.random
- -- Set all the other bits to randomly (or pseudo-randomly) chosen values.
- local bytes = {
- r(2^(4*8)), --time-low
- r(2^(2*8)), --time-mid
- r(2^(2*8-4)), --time-high-and-version
- r(2^(1*8-2)), --clock-seq-and-reserved
- r(2^(1*8)), --clock-seq-low
- r(2^(3*8)), r(2^(3*8)), --node
- }
- -- Set the four most significant bits (bits 12 through 15) of the
- -- time_hi_and_version field to the 4-bit version number from
- -- Section 4.1.3.
- bytes[3] = bytes[3] + 0x4000
- -- Set the two most significant bits (bits 6 and 7) of the
- -- clock_seq_hi_and_reserved to zero and one, respectively.
- bytes[4] = bytes[4] + 0xC0
- return ("%08x-%04x-%04x-%02x%02x-%6x%6x"):format(unpack(bytes))
-end
-
-return uuid