uuid-random
Generate random UUIDv4
with better statistical dispersion
than Math.random()
.
Install
npm install uuid-random
Performance
This is the fastest pure javascript UUIDv4 generator I have found, almost 5x
faster than comparable libraries.
npm package | performance |
---|
uuid | 370k ops/sec |
node-uuid | 370k ops/sec |
uuid-random | 1.618M ops/sec |
Yep, the golden ratio.
Features
- 0.3k minified + gzipped
- Uses better RNG when possible
- Works in browser or node
- Very fast!
Example Usage
Node
var uuid = require('uuid-random');
uuid();
Browser
<script src="uuid-random.min.js"></script>
<script>
uuid();
</script>
Rationale
Math.random()
sucks for uuid generation.
After digging through npm and
stackoverflow,
I settled on using node-uuid to take
advantage of better RNG when possible.
I wasn't happy with the solution so I combined code from the best libs and
researched a much faster, more compact
version that still used the best RNG available to the platform.
This library does one thing very well: generate UUIDv4 (random).
License
MIT