Sha256: dc55c574a6aa44845f763ee843150e0c403e139b6fbc93774064ceefaf48e295
Contents?: true
Size: 642 Bytes
Versions: 17
Compression:
Stored size: 642 Bytes
Contents
var pseudoRandomBytes = require('crypto').pseudoRandomBytes var escape = require('base64-url').escape var pseudoRandomBytesProm module.exports = uid function uid(length, cb) { if (cb) { return pseudoRandomBytes(length, function (err, buf) { if (err) return cb(err) cb(null, escapeBuffer(buf)) }) } pseudoRandomBytesProm || (pseudoRandomBytesProm = require('mz/crypto').pseudoRandomBytes) return pseudoRandomBytesProm(length).then(escapeBuffer) } uid.sync = function uid_sync(length) { return escapeBuffer(pseudoRandomBytes(length)) } function escapeBuffer(buf) { return escape(buf.toString('base64')) }
Version data entries
17 entries across 17 versions & 2 rubygems