|
812 | 812 | // Validate the salt |
813 | 813 | var minor, offset; |
814 | 814 | if (salt.charAt(0) !== '$' || salt.charAt(1) !== '2') { |
815 | | - err = new Error("Invalid salt version: "+salt.substring(0,2)); |
| 815 | + err = Error("Invalid salt version: "+salt.substring(0,2)); |
816 | 816 | if (callback) { |
817 | 817 | _nextTick(callback.bind(this, err)); |
818 | 818 | return; |
|
1014 | 1014 | * @param {string} s String to hash |
1015 | 1015 | * @param {number|string} salt Salt length to generate or salt to use |
1016 | 1016 | * @param {function(Error, string=)} callback Callback receiving the error, if any, and the resulting hash |
1017 | | - * @param {function(number)=} progressCallback Callback called with the current progress |
| 1017 | + * @param {function(number)=} progressCallback Callback successively called with the percentage of rounds completed |
| 1018 | + * (0.0 - 1.0), maximally once per `MAX_EXECUTION_TIME = 100` ms. |
1018 | 1019 | * @expose |
1019 | 1020 | */ |
1020 | 1021 | bcrypt.hash = function(s, salt, callback, progressCallback) { |
|
1059 | 1060 | * @param {string} s Data to compare |
1060 | 1061 | * @param {string} hash Data to be compared to |
1061 | 1062 | * @param {function(Error, boolean)} callback Callback receiving the error, if any, otherwise the result |
1062 | | - * @param {function(number)=} progressCallback Callback called with the current progress |
| 1063 | + * @param {function(number)=} progressCallback Callback successively called with the percentage of rounds completed |
| 1064 | + * (0.0 - 1.0), maximally once per `MAX_EXECUTION_TIME = 100` ms. |
1063 | 1065 | * @throws {Error} If the callback argument is invalid |
1064 | 1066 | * @expose |
1065 | 1067 | */ |
1066 | 1068 | bcrypt.compare = function(s, hash, callback, progressCallback) { |
1067 | 1069 | if (typeof callback !== 'function') |
1068 | | - throw(new Error("Illegal callback: "+callback)); |
| 1070 | + throw Error("Illegal callback: "+callback); |
1069 | 1071 | if (typeof s !== "string" || typeof hash !== "string") { |
1070 | | - _nextTick(callback.bind(this, new Error("Illegal argument types: "+(typeof s)+', '+(typeof hash)))); |
| 1072 | + _nextTick(callback.bind(this, Error("Illegal argument types: "+(typeof s)+', '+(typeof hash)))); |
1071 | 1073 | return; |
1072 | 1074 | } |
1073 | 1075 | bcrypt.hash(s, hash.substr(0, 29), function(err, comp) { |
|
0 commit comments