I'm tying to write an ES6 module that detects which environment it is running on and create a unique hex ID if it is node, or if it is browser. I do not want to use browser libraries or a bundler.
In node.js:
const crypto = require('crypto')
let id = crypto.randomBytes(48, function(err, buffer) {
return buffer.toString('hex')
})
console.log(id)
In both browser and node without a bundler:
???? unsure, from on my research on how to accomplish the same thing.