Spaces:
Paused
Paused
Download node_modules/brorand/index.js from Leon4gr45/UserSyncFrontend: direct link, hf CLI and curl.
- Browser
- Download file 1.51 kB
-
https://huggingface.co/spaces/Leon4gr45/UserSyncFrontend/resolve/main/node_modules/brorand/index.js
- Command line
-
hf download hf://spaces/Leon4gr45/UserSyncFrontend/node_modules/brorand/index.js
-
curl -L -o index.js https://huggingface.co/spaces/Leon4gr45/UserSyncFrontend/resolve/main/node_modules/brorand/index.js
1.51 kB
| var r; | |
| module.exports = function rand(len) { | |
| if (!r) | |
| r = new Rand(null); | |
| return r.generate(len); | |
| }; | |
| function Rand(rand) { | |
| this.rand = rand; | |
| } | |
| module.exports.Rand = Rand; | |
| Rand.prototype.generate = function generate(len) { | |
| return this._rand(len); | |
| }; | |
| // Emulate crypto API using randy | |
| Rand.prototype._rand = function _rand(n) { | |
| if (this.rand.getBytes) | |
| return this.rand.getBytes(n); | |
| var res = new Uint8Array(n); | |
| for (var i = 0; i < res.length; i++) | |
| res[i] = this.rand.getByte(); | |
| return res; | |
| }; | |
| if (typeof self === 'object') { | |
| if (self.crypto && self.crypto.getRandomValues) { | |
| // Modern browsers | |
| Rand.prototype._rand = function _rand(n) { | |
| var arr = new Uint8Array(n); | |
| self.crypto.getRandomValues(arr); | |
| return arr; | |
| }; | |
| } else if (self.msCrypto && self.msCrypto.getRandomValues) { | |
| // IE | |
| Rand.prototype._rand = function _rand(n) { | |
| var arr = new Uint8Array(n); | |
| self.msCrypto.getRandomValues(arr); | |
| return arr; | |
| }; | |
| // Safari's WebWorkers do not have `crypto` | |
| } else if (typeof window === 'object') { | |
| // Old junk | |
| Rand.prototype._rand = function() { | |
| throw new Error('Not implemented yet'); | |
| }; | |
| } | |
| } else { | |
| // Node.js or Web worker with no crypto support | |
| try { | |
| var crypto = require('crypto'); | |
| if (typeof crypto.randomBytes !== 'function') | |
| throw new Error('Not supported'); | |
| Rand.prototype._rand = function _rand(n) { | |
| return crypto.randomBytes(n); | |
| }; | |
| } catch (e) { | |
| } | |
| } | |