]> git.example.dev Git - binbsis50.git/commitdiff
removed prng module
authorLuigi Pinca <luigipinca@gmail.com>
Sat, 1 Jul 2023 11:02:13 +0000 (13:02 +0200)
committerLuigi Pinca <luigipinca@gmail.com>
Sat, 1 Jul 2023 12:00:48 +0000 (14:00 +0200)
lib/prng.js [deleted file]
lib/rooms.js
routes/site.js

diff --git a/lib/prng.js b/lib/prng.js
deleted file mode 100644 (file)
index ad3e774..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-'use strict';
-
-const crypto = require('crypto');
-
-const rrange = 4294967296;
-
-/**
- * Return an integer, pseudo-random number in the range [0, 2^32).
- */
-
-const nextInt = function() {
-  return crypto.randomBytes(4).readUInt32BE(0);
-};
-
-/**
- * Return a floating-point, pseudo-random number in the range [0, 1).
- */
-
-const rand = function() {
-  return nextInt() / rrange;
-};
-
-/**
- * Return an integer, pseudo-random number in the range [0, max).
- */
-
-exports.randInt = function(max) {
-  return Math.floor(rand() * max);
-};
index bd404888d24f1c25d1dec1e87617a97d51886981..865e5193eae7b8ff3257748d95cc36386476481a 100644 (file)
@@ -3,7 +3,7 @@
 const amatch = require('./match');
 const clients = require('./redis-clients');
 const config = require('../config');
-const randInt = require('./prng').randInt;
+const randomInt = require('crypto').randomInt;
 const updateStats = require('./stats');
 const utils = require('./utils');
 
@@ -513,7 +513,7 @@ Room.prototype.resetPoints = function(roundonly) {
 Room.prototype.sendLoadTrack = function() {
   this.status = Room.LOADING;
 
-  const index = randInt(this.trackscount);
+  const index = randomInt(this.trackscount);
   const room = this;
 
   songsdb.zrange(this.roomname, index, index, function(err, res) {
index f1ce13b481d2ba2a18f987a3094be475fe88648b..4375291730d5d5072e3d44a58b3f698be04519aa 100644 (file)
@@ -5,7 +5,7 @@ const config = require('../config');
 const db = require('../lib/redis-clients').songs;
 const http = require('http');
 const parallel = require('async/parallel');
-const randInt = require('../lib/prng').randInt;
+const randomInt = require('crypto').randomInt;
 const randomSlogan = require('../lib/utils').randomSlogan;
 const rooms = require('../lib/rooms').rooms;
 
@@ -15,7 +15,7 @@ const rooms = require('../lib/rooms').rooms;
 
 const subTask = function(genre) {
   return function(callback) {
-    const index = randInt(rooms[genre].trackscount);
+    const index = randomInt(rooms[genre].trackscount);
     db.zrange(genre, index, index, function(err, res) {
       if (err) {
         return callback(err);