Skip to content

Commit

Permalink
avniproject/avni-client#1201 | Use uuid package to generate v4 UUIDs
Browse files Browse the repository at this point in the history
  • Loading branch information
1t5j0y committed Nov 30, 2023
1 parent fa9fd3b commit 13416cb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,8 @@
"nyc": {
"sourceMap": false,
"instrument": false
},
"dependencies": {
"uuid": "^9.0.1"
}
}
8 changes: 2 additions & 6 deletions src/utility/General.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Observation from "../Observation";
import Concept from "../Concept";
import QuestionGroup from "../observation/QuestionGroup";
import RepeatableQuestionGroup from "../observation/RepeatableQuestionGroup";
import { v4 as uuidv4 } from 'uuid';

var currentLogLevel;

Expand Down Expand Up @@ -198,13 +199,8 @@ class General {
return picked;
}

//http://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript
static randomUUID() {
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
const r = (Math.random() * 16) | 0,
v = c == "x" ? r : (r & 0x3) | 0x8;
return v.toString(16);
});
return uuidv4();
}

static areEqualShallow(a, b) {
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6446,6 +6446,11 @@ uuid@^3.3.2:
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee"
integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==

uuid@^9.0.1:
version "9.0.1"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.1.tgz#e188d4c8853cc722220392c424cd637f32293f30"
integrity sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==

[email protected]:
version "2.0.3"
resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.0.3.tgz#00f7494d2ae2b688cfe2899df6ed2c54bef91dbe"
Expand Down

0 comments on commit 13416cb

Please sign in to comment.