From dbf4f6b5ddc0c3d34b1f813c660094a37f145146 Mon Sep 17 00:00:00 2001 From: Klas af Geijerstam Date: Mon, 26 Jun 2017 17:39:32 +0200 Subject: [PATCH] Removed usage of random-js Replaced random-js with vanilla JS random --- lib/key_generators/dictionary.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/key_generators/dictionary.js b/lib/key_generators/dictionary.js index 805630b..6bc6c2e 100644 --- a/lib/key_generators/dictionary.js +++ b/lib/key_generators/dictionary.js @@ -1,8 +1,5 @@ -var rand = require('random-js'); var fs = require('fs') var dictionary; -var randomEngine = rand.engines.nativeMath; -var random; var DictionaryGenerator = function(options) { //Options @@ -20,7 +17,6 @@ var DictionaryGenerator = function(options) { for(var i = 0; i < this.dictionary.length; i++) 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) { var text = ''; for(var i = 0; i < keyLength; i++) - text += this.dictionary[random(randomEngine)]; + text += this.dictionary[Math.floor(Math.random()*this.dictionary.length]; return text; };