randombytes
Advanced tools
+3
-2
@@ -23,4 +23,5 @@ 'use strict' | ||
| // See https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues | ||
| crypto.getRandomValues(rawBytes) | ||
| if (size > 0) { // getRandomValues fails on IE if size == 0 | ||
| crypto.getRandomValues(rawBytes) | ||
| } | ||
| // phantomjs doesn't like a buffer being passed here | ||
@@ -27,0 +28,0 @@ var bytes = new Buffer(rawBytes.buffer) |
+1
-1
| { | ||
| "name": "randombytes", | ||
| "version": "2.0.2", | ||
| "version": "2.0.3", | ||
| "description": "random bytes from browserify stand alone", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
+9
-2
@@ -5,3 +5,4 @@ var test = require('tape') | ||
| test('sync', function (t) { | ||
| t.plan(3) | ||
| t.plan(4) | ||
| t.equals(randomBytes(0).length, 0, 'len: ' + 0) | ||
| t.equals(randomBytes(3).length, 3, 'len: ' + 3) | ||
@@ -13,4 +14,10 @@ t.equals(randomBytes(30).length, 30, 'len: ' + 30) | ||
| test('async', function (t) { | ||
| t.plan(3) | ||
| t.plan(4) | ||
| randomBytes(0, function (err, resp) { | ||
| if (err) throw err | ||
| t.equals(resp.length, 0, 'len: ' + 0) | ||
| }) | ||
| randomBytes(3, function (err, resp) { | ||
@@ -17,0 +24,0 @@ if (err) throw err |
3973
6.14%74
10.45%