Skip to content

Commit

Permalink
refactor deterministic ids
Browse files Browse the repository at this point in the history
  • Loading branch information
barduinor committed Sep 11, 2023
1 parent 3f1cc43 commit e55e713
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/DeterministicIds.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const uuid = require('uuid')
const NAMESPACE = '33c4e6fc-44cb-4190-b19f-4a02821bc8c3'

const genIDDeterm = (objectJSON) => {
const id = uuid.v5(JSON.stringify(objectJSON), NAMESPACE)
return id
}

const genIDRandom = () => {
const id = uuid.v4()
return id
}

module.exports = {
genIDDeterm: genIDDeterm,
genIDRandom: genIDRandom
}

0 comments on commit e55e713

Please sign in to comment.