[Pkg-javascript-commits] [node-diffie-hellman] 76/88: browser: decrease constructor state

Bastien Roucariès rouca at moszumanska.debian.org
Thu May 4 10:19:18 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-diffie-hellman.

commit 0c0b7cdeba65a54744f82f9aa5182932e9b8c6d0
Author: Daniel Cousens <dcousens at users.noreply.github.com>
Date:   Tue Jan 12 13:22:06 2016 +1100

    browser: decrease constructor state
---
 browser.js | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/browser.js b/browser.js
index ba0d903..995af6e 100644
--- a/browser.js
+++ b/browser.js
@@ -10,11 +10,13 @@ function getDiffieHellman(mod) {
   return new DH(prime, gen);
 }
 
+var encodings = {
+  'binary': true, 'hex': true, 'base64': true
+}
+
 function createDiffieHellman(prime, enc, generator, genc) {
-  if (Buffer.isBuffer(enc) || (typeof enc === 'string' && ['hex', 'binary', 'base64'].indexOf(enc) === -1)) {
-    genc = generator;
-    generator = enc;
-    enc = undefined;
+  if (Buffer.isBuffer(enc) || encodings[enc] === undefined) {
+    return createDiffieHellman(prime, 'binary', enc, generator)
   }
 
   enc = enc || 'binary';

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-diffie-hellman.git



More information about the Pkg-javascript-commits mailing list