File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -64,16 +64,25 @@ function uuid.generate_time_safe()
64
64
end
65
65
66
66
function uuid .type (id )
67
- return lib .uuid_type (parse (id ))
67
+ local parsed = parse (id )
68
+ return parsed and lib .uuid_type (parsed )
68
69
end
69
70
70
71
function uuid .variant (id )
71
- return lib .uuid_variant (parse (id ))
72
+ local parsed = parse (id )
73
+ return parsed and lib .uuid_variant (parsed )
72
74
end
73
75
74
76
function uuid .time (id )
75
- local secs = lib .uuid_time (parse (id ), tvl )
76
- return tonumber (secs ), tonumber (tvl .tv_usec )
77
+ local parsed = parse (id )
78
+ if parsed then
79
+ local secs = lib .uuid_time (parsed , tvl )
80
+ return tonumber (secs ), tonumber (tvl .tv_usec )
81
+ end
82
+ end
83
+
84
+ function uuid .is_valid (id )
85
+ return not not parse (id )
77
86
end
78
87
79
88
mt .__call = uuid .generate
You can’t perform that action at this time.
0 commit comments