random.js
This file
Path
random.js
15 lines · 359 bytes · JavaScript
Last changed by
Speed up random generatorAndrey Sitnikbefore adoptionfd51e72
History of this fileTake it
12345678910111213141516var crypto = require('crypto')
if (crypto.randomFillSync) { var buffers = { } module.exports = function (bytes) { var buffer = buffers[bytes] if (!buffer) { buffer = Buffer.allocUnsafe(bytes) if (bytes <= 255) buffers[bytes] = buffer } return crypto.randomFillSync(buffer) }} else { module.exports = crypto.randomBytes}