lnsocket

A minimal C library for connecting to the lightning network
git clone git://jb55.com/lnsocket
Log | Files | Refs | Submodules | README | LICENSE

lnsocket_pre.js (569B)


      1 Module.getRandomValue = (function() {
      2 	const window_ = "object" === typeof window ? window : this
      3 	const crypto_ = typeof window_.crypto !== "undefined" ? window_.crypto : window_.msCrypto;
      4 
      5 	let randomBytesNode
      6 	let fn
      7 	if (!crypto_) {
      8 		randomBytesNode = require('crypto').randomBytes
      9 		fn = randomValuesNode 
     10 	} else {
     11 		fn = randomValuesStandard
     12 	}
     13 
     14 	function randomValuesNode() {
     15 		return randomBytesNode(1)[0] >>> 0
     16 	}
     17 
     18 	function randomValuesStandard() {
     19 		var buf = new Uint32Array(1);
     20 		crypto_.getRandomValues(buf);
     21 		return buf[0] >>> 0;
     22 	};
     23 
     24 	return fn
     25 })()