From 026d9139c4aa922e6beb1fc209df820fd26fae1b Mon Sep 17 00:00:00 2001 From: jiaming743 <743192023@qq.com> Date: Thu, 2 Jul 2020 11:00:19 +0800 Subject: [PATCH] Optimize uuid --- src/util/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/util/index.js b/src/util/index.js index 7c0c15a..e729add 100644 --- a/src/util/index.js +++ b/src/util/index.js @@ -38,10 +38,10 @@ export function getPointDistance (pointOne, pointTwo) { return Math.sqrt(minusX * minusX + minusY * minusY) } -export function uuid () { - return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { +export function uuid (hasHyphen) { + return (hasHyphen ? 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx' : 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx').replace(/[xy]/g, function (c) { const r = Math.random() * 16 | 0 const v = c == 'x' ? r : (r & 0x3 | 0x8) return v.toString(16) - }) + }) }