1
0
Fork 0
mirror of https://github.com/seejohnrun/haste-server.git synced 2024-11-22 04:31:21 +00:00

Removed usage of random-js

Replaced random-js with vanilla JS random
This commit is contained in:
Klas af Geijerstam 2017-06-26 17:39:32 +02:00 committed by GitHub
parent 8e9205cecc
commit dbf4f6b5dd

View file

@ -1,8 +1,5 @@
var rand = require('random-js');
var fs = require('fs') var fs = require('fs')
var dictionary; var dictionary;
var randomEngine = rand.engines.nativeMath;
var random;
var DictionaryGenerator = function(options) { var DictionaryGenerator = function(options) {
//Options //Options
@ -20,7 +17,6 @@ var DictionaryGenerator = function(options) {
for(var i = 0; i < this.dictionary.length; i++) for(var i = 0; i < this.dictionary.length; i++)
this.dictionary[i] = this.dictionary[i].replace(/\W/g,''); this.dictionary[i] = this.dictionary[i].replace(/\W/g,'');
this.random = rand.integer(0, this.dictionary.length);
}); });
}; };
@ -28,7 +24,7 @@ var DictionaryGenerator = function(options) {
DictionaryGenerator.prototype.createKey = function(keyLength) { DictionaryGenerator.prototype.createKey = function(keyLength) {
var text = ''; var text = '';
for(var i = 0; i < keyLength; i++) for(var i = 0; i < keyLength; i++)
text += this.dictionary[random(randomEngine)]; text += this.dictionary[Math.floor(Math.random()*this.dictionary.length];
return text; return text;
}; };