types: Expected Buffer, length to follow

This commit is contained in:
Daniel Cousens 2015-08-19 15:27:06 +10:00
parent bfb7289cf2
commit ca4debd92e

View file

@ -3,7 +3,7 @@ var ecurve = require('ecurve')
var typeforce = require('typeforce')
function nBuffer (value, n) {
if (!Buffer.isBuffer(value)) return false
typeforce(types.Buffer, value)
if (value.length !== n) throw new Error('Expected ' + (n * 8) + '-bit Buffer, got ' + (value.length * 8) + '-bit Buffer')
return true
}