to-unsigned-int32
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -6,9 +6,10 @@ var dz = require('dezalgo') | ||
if (n >= 0xff) { | ||
return callback(new Error('Number can not represent in 32 bit')) | ||
var buffr = new Buffer(4) | ||
try { | ||
buffr.writeUInt32BE(n, 0) | ||
} catch(e) { | ||
return callback(e) | ||
} | ||
var buffr = new Buffer(4) | ||
buffr.writeUInt32BE(n, 0) | ||
return callback(null, buffr) | ||
} |
{ | ||
"name": "to-unsigned-int32", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "convert to number of 32 bit buffer", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -5,5 +5,5 @@ var tap = require('tap') | ||
tap.test('should return error when number can not fit in 32 bit', function (t) { | ||
toUInt32(0xfff, function (err, buff) { | ||
toUInt32(0xaffffffff, function (err, buff) { | ||
t.type(err, Error) | ||
t.equal(err.message, 'Number can not represent in 32 bit', 'handling error for number can not fit in 32 bit') | ||
t.equal(err.message, 'value is out of bounds', 'handling error for number can not fit in 32 bit') | ||
t.notOk(buff, 'buff should be null') | ||
@@ -10,0 +10,0 @@ t.end() |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30
2297