From 0e82a35c4c471cc0b0ce16d4e6891e90e8d498a9 Mon Sep 17 00:00:00 2001 From: Khanh Hoang Date: Wed, 30 Sep 2015 17:55:38 +0700 Subject: [PATCH] Update bCrypt.js I config some code from the `genSalt(rounds, callback)` function --- bCrypt.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/bCrypt.js b/bCrypt.js index 5246f47..4ddcfb2 100644 --- a/bCrypt.js +++ b/bCrypt.js @@ -582,9 +582,19 @@ function genSalt(rounds, callback) { error - First parameter to the callback detailing any errors. salt - Second parameter to the callback providing the generated salt. */ + + if (arguments.length == 0) + throw new Error("No args"); + + if (typeof rounds === 'function') { + callback = rounds; + rounds = 10; + } + if(!callback) { - throw "No callback function was given." + throw new Error("No callback function was given."); } + process.nextTick(function() { var result = null; var error = null;