native-buffer-browserify
Advanced tools
Comparing version 1.0.1 to 1.0.2
129
index.js
@@ -6,3 +6,2 @@ exports.Buffer = Buffer | ||
var assert | ||
var browserSupport | ||
@@ -26,4 +25,2 @@ | ||
function Buffer (subject, encoding) { | ||
if (!assert) assert = require('assert') | ||
var type = typeof subject | ||
@@ -399,4 +396,4 @@ var length | ||
if (!noAssert) { | ||
assert.ok(offset !== undefined && offset !== null, 'missing offset') | ||
assert.ok(offset < buf.length, 'Trying to read beyond buffer length') | ||
assert(offset !== undefined && offset !== null, 'missing offset') | ||
assert(offset < buf.length, 'Trying to read beyond buffer length') | ||
} | ||
@@ -412,6 +409,6 @@ | ||
if (!noAssert) { | ||
assert.ok(typeof (littleEndian) === 'boolean', | ||
assert(typeof (littleEndian) === 'boolean', | ||
'missing or invalid endian') | ||
assert.ok(offset !== undefined && offset !== null, 'missing offset') | ||
assert.ok(offset + 1 < buf.length, 'Trying to read beyond buffer length') | ||
assert(offset !== undefined && offset !== null, 'missing offset') | ||
assert(offset + 1 < buf.length, 'Trying to read beyond buffer length') | ||
} | ||
@@ -441,6 +438,6 @@ | ||
if (!noAssert) { | ||
assert.ok(typeof (littleEndian) === 'boolean', | ||
assert(typeof (littleEndian) === 'boolean', | ||
'missing or invalid endian') | ||
assert.ok(offset !== undefined && offset !== null, 'missing offset') | ||
assert.ok(offset + 3 < buf.length, 'Trying to read beyond buffer length') | ||
assert(offset !== undefined && offset !== null, 'missing offset') | ||
assert(offset + 3 < buf.length, 'Trying to read beyond buffer length') | ||
} | ||
@@ -473,5 +470,5 @@ | ||
if (!noAssert) { | ||
assert.ok(offset !== undefined && offset !== null, | ||
assert(offset !== undefined && offset !== null, | ||
'missing offset') | ||
assert.ok(offset < buf.length, 'Trying to read beyond buffer length') | ||
assert(offset < buf.length, 'Trying to read beyond buffer length') | ||
} | ||
@@ -487,7 +484,7 @@ | ||
if (!noAssert) { | ||
assert.ok(typeof (littleEndian) === 'boolean', | ||
assert(typeof (littleEndian) === 'boolean', | ||
'missing or invalid endian') | ||
assert.ok(offset !== undefined && offset !== null, | ||
assert(offset !== undefined && offset !== null, | ||
'missing offset') | ||
assert.ok(offset + 1 < buf.length, 'Trying to read beyond buffer length') | ||
assert(offset + 1 < buf.length, 'Trying to read beyond buffer length') | ||
} | ||
@@ -517,6 +514,6 @@ | ||
if (!noAssert) { | ||
assert.ok(typeof (littleEndian) === 'boolean', | ||
assert(typeof (littleEndian) === 'boolean', | ||
'missing or invalid endian') | ||
assert.ok(offset !== undefined && offset !== null, 'missing offset') | ||
assert.ok(offset + 3 < buf.length, 'Trying to read beyond buffer length') | ||
assert(offset !== undefined && offset !== null, 'missing offset') | ||
assert(offset + 3 < buf.length, 'Trying to read beyond buffer length') | ||
} | ||
@@ -548,5 +545,5 @@ | ||
if (!noAssert) { | ||
assert.ok(typeof (littleEndian) === 'boolean', | ||
assert(typeof (littleEndian) === 'boolean', | ||
'missing or invalid endian') | ||
assert.ok(offset + 3 < buf.length, 'Trying to read beyond buffer length') | ||
assert(offset + 3 < buf.length, 'Trying to read beyond buffer length') | ||
} | ||
@@ -567,5 +564,5 @@ | ||
if (!noAssert) { | ||
assert.ok(typeof (littleEndian) === 'boolean', | ||
assert(typeof (littleEndian) === 'boolean', | ||
'missing or invalid endian') | ||
assert.ok(offset + 7 < buf.length, 'Trying to read beyond buffer length') | ||
assert(offset + 7 < buf.length, 'Trying to read beyond buffer length') | ||
} | ||
@@ -587,5 +584,5 @@ | ||
if (!noAssert) { | ||
assert.ok(value !== undefined && value !== null, 'missing value') | ||
assert.ok(offset !== undefined && offset !== null, 'missing offset') | ||
assert.ok(offset < buf.length, 'trying to write beyond buffer length') | ||
assert(value !== undefined && value !== null, 'missing value') | ||
assert(offset !== undefined && offset !== null, 'missing offset') | ||
assert(offset < buf.length, 'trying to write beyond buffer length') | ||
verifuint(value, 0xff) | ||
@@ -601,7 +598,7 @@ } | ||
if (!noAssert) { | ||
assert.ok(value !== undefined && value !== null, 'missing value') | ||
assert.ok(typeof (littleEndian) === 'boolean', | ||
assert(value !== undefined && value !== null, 'missing value') | ||
assert(typeof (littleEndian) === 'boolean', | ||
'missing or invalid endian') | ||
assert.ok(offset !== undefined && offset !== null, 'missing offset') | ||
assert.ok(offset + 1 < buf.length, 'trying to write beyond buffer length') | ||
assert(offset !== undefined && offset !== null, 'missing offset') | ||
assert(offset + 1 < buf.length, 'trying to write beyond buffer length') | ||
verifuint(value, 0xffff) | ||
@@ -632,7 +629,7 @@ } | ||
if (!noAssert) { | ||
assert.ok(value !== undefined && value !== null, 'missing value') | ||
assert.ok(typeof (littleEndian) === 'boolean', | ||
assert(value !== undefined && value !== null, 'missing value') | ||
assert(typeof (littleEndian) === 'boolean', | ||
'missing or invalid endian') | ||
assert.ok(offset !== undefined && offset !== null, 'missing offset') | ||
assert.ok(offset + 3 < buf.length, 'trying to write beyond buffer length') | ||
assert(offset !== undefined && offset !== null, 'missing offset') | ||
assert(offset + 3 < buf.length, 'trying to write beyond buffer length') | ||
verifuint(value, 0xffffffff) | ||
@@ -666,5 +663,5 @@ } | ||
if (!noAssert) { | ||
assert.ok(value !== undefined && value !== null, 'missing value') | ||
assert.ok(offset !== undefined && offset !== null, 'missing offset') | ||
assert.ok(offset < buf.length, 'Trying to write beyond buffer length') | ||
assert(value !== undefined && value !== null, 'missing value') | ||
assert(offset !== undefined && offset !== null, 'missing offset') | ||
assert(offset < buf.length, 'Trying to write beyond buffer length') | ||
verifsint(value, 0x7f, -0x80) | ||
@@ -680,7 +677,7 @@ } | ||
if (!noAssert) { | ||
assert.ok(value !== undefined && value !== null, 'missing value') | ||
assert.ok(typeof (littleEndian) === 'boolean', | ||
assert(value !== undefined && value !== null, 'missing value') | ||
assert(typeof (littleEndian) === 'boolean', | ||
'missing or invalid endian') | ||
assert.ok(offset !== undefined && offset !== null, 'missing offset') | ||
assert.ok(offset + 1 < buf.length, 'Trying to write beyond buffer length') | ||
assert(offset !== undefined && offset !== null, 'missing offset') | ||
assert(offset + 1 < buf.length, 'Trying to write beyond buffer length') | ||
verifsint(value, 0x7fff, -0x8000) | ||
@@ -711,7 +708,7 @@ } | ||
if (!noAssert) { | ||
assert.ok(value !== undefined && value !== null, 'missing value') | ||
assert.ok(typeof (littleEndian) === 'boolean', | ||
assert(value !== undefined && value !== null, 'missing value') | ||
assert(typeof (littleEndian) === 'boolean', | ||
'missing or invalid endian') | ||
assert.ok(offset !== undefined && offset !== null, 'missing offset') | ||
assert.ok(offset + 3 < buf.length, 'Trying to write beyond buffer length') | ||
assert(offset !== undefined && offset !== null, 'missing offset') | ||
assert(offset + 3 < buf.length, 'Trying to write beyond buffer length') | ||
verifsint(value, 0x7fffffff, -0x80000000) | ||
@@ -744,7 +741,7 @@ } | ||
if (!noAssert) { | ||
assert.ok(value !== undefined && value !== null, 'missing value') | ||
assert.ok(typeof (littleEndian) === 'boolean', | ||
assert(value !== undefined && value !== null, 'missing value') | ||
assert(typeof (littleEndian) === 'boolean', | ||
'missing or invalid endian') | ||
assert.ok(offset !== undefined && offset !== null, 'missing offset') | ||
assert.ok(offset + 3 < buf.length, 'Trying to write beyond buffer length') | ||
assert(offset !== undefined && offset !== null, 'missing offset') | ||
assert(offset + 3 < buf.length, 'Trying to write beyond buffer length') | ||
verifIEEE754(value, 3.4028234663852886e+38, -3.4028234663852886e+38) | ||
@@ -777,7 +774,7 @@ } | ||
if (!noAssert) { | ||
assert.ok(value !== undefined && value !== null, 'missing value') | ||
assert.ok(typeof (littleEndian) === 'boolean', | ||
assert(value !== undefined && value !== null, 'missing value') | ||
assert(typeof (littleEndian) === 'boolean', | ||
'missing or invalid endian') | ||
assert.ok(offset !== undefined && offset !== null, 'missing offset') | ||
assert.ok(offset + 7 < buf.length, | ||
assert(offset !== undefined && offset !== null, 'missing offset') | ||
assert(offset + 7 < buf.length, | ||
'Trying to write beyond buffer length') | ||
@@ -1127,7 +1124,7 @@ verifIEEE754(value, 1.7976931348623157E+308, -1.7976931348623157E+308) | ||
function verifuint (value, max) { | ||
assert.ok(typeof (value) == 'number', 'cannot write a non-number as a number') | ||
assert.ok(value >= 0, | ||
assert(typeof (value) == 'number', 'cannot write a non-number as a number') | ||
assert(value >= 0, | ||
'specified a negative value for writing an unsigned value') | ||
assert.ok(value <= max, 'value is larger than maximum value for type') | ||
assert.ok(Math.floor(value) === value, 'value has a fractional component') | ||
assert(value <= max, 'value is larger than maximum value for type') | ||
assert(Math.floor(value) === value, 'value has a fractional component') | ||
} | ||
@@ -1139,12 +1136,16 @@ | ||
function verifsint(value, max, min) { | ||
assert.ok(typeof (value) == 'number', 'cannot write a non-number as a number') | ||
assert.ok(value <= max, 'value larger than maximum allowed value') | ||
assert.ok(value >= min, 'value smaller than minimum allowed value') | ||
assert.ok(Math.floor(value) === value, 'value has a fractional component') | ||
assert(typeof (value) == 'number', 'cannot write a non-number as a number') | ||
assert(value <= max, 'value larger than maximum allowed value') | ||
assert(value >= min, 'value smaller than minimum allowed value') | ||
assert(Math.floor(value) === value, 'value has a fractional component') | ||
} | ||
function verifIEEE754(value, max, min) { | ||
assert.ok(typeof (value) == 'number', 'cannot write a non-number as a number') | ||
assert.ok(value <= max, 'value larger than maximum allowed value') | ||
assert.ok(value >= min, 'value smaller than minimum allowed value') | ||
assert(typeof (value) == 'number', 'cannot write a non-number as a number') | ||
assert(value <= max, 'value larger than maximum allowed value') | ||
assert(value >= min, 'value smaller than minimum allowed value') | ||
} | ||
function assert (test, message) { | ||
if (!test) throw new Error(message || 'Failed assertion') | ||
} |
{ | ||
"name": "native-buffer-browserify", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "buffer module compatibility for browserify (backed by ArrayBuffer so its fast!)", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
57500