added guard clause

This commit is contained in:
Alex Booker 2015-08-14 18:12:27 +01:00
parent 78634330de
commit 91fb2972b4

View File

@ -1,5 +1,8 @@
var passwordGenerator = (function() {
var generateRandomNum = function (max) {
if (!window.crypto || !window.crypto.getRandomValues) {
throw new Error('Unsupported browser.');
}
var array = new Uint8Array(1);
window.crypto.getRandomValues(array);
var range = max + 1;