Skip to content

Commit 026d913

Browse files
committed
Optimize uuid
1 parent 9b84417 commit 026d913

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/util/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ export function getPointDistance (pointOne, pointTwo) {
3838
return Math.sqrt(minusX * minusX + minusY * minusY)
3939
}
4040

41-
export function uuid () {
42-
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
41+
export function uuid (hasHyphen) {
42+
return (hasHyphen ? 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx' : 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx').replace(/[xy]/g, function (c) {
4343
const r = Math.random() * 16 | 0
4444
const v = c == 'x' ? r : (r & 0x3 | 0x8)
4545
return v.toString(16)
46-
})
46+
})
4747
}

0 commit comments

Comments
 (0)