优化uuid, 增加有序特性

master
yutent 2023-06-02 18:53:02 +08:00
parent 5281159c21
commit 20639ab038
2 changed files with 4 additions and 3 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "crypto.js", "name": "crypto.js",
"version": "3.1.0", "version": "3.1.1",
"description": "原生crypto加密模块的二次封装,简化常用加密函数的使用", "description": "原生crypto加密模块的二次封装,简化常用加密函数的使用",
"keywords": [ "keywords": [
"md5", "md5",

View File

@ -89,11 +89,12 @@ export function uuid(pipe = '-') {
var str = origin.randomUUID() var str = origin.randomUUID()
var now = (~~(Date.now() / 1000)).toString(16) var now = (~~(Date.now() / 1000)).toString(16)
__inc__++
if (__inc__ > 65535) { if (__inc__ > 65535) {
__inc__ = 1 __inc__ = 1
} }
str += __inc__.toString(16)
str = __inc__.toString(16) + str
__inc__++
return now + pipe + MAC + pipe + str.slice(0, 4) + pipe + str.slice(-8) return now + pipe + MAC + pipe + str.slice(0, 4) + pipe + str.slice(-8)
} }