Socket
Socket
Sign inDemoInstall

buffer

Package Overview
Dependencies
2
Maintainers
1
Versions
96
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.0.3 to 5.0.4

40

index.js

@@ -107,3 +107,3 @@ /*!

if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
if (value instanceof ArrayBuffer) {
return fromArrayBuffer(value, encodingOrOffset, length)

@@ -220,4 +220,2 @@ }

function fromArrayBuffer (array, byteOffset, length) {
array.byteLength // this throws if `array` is not a valid ArrayBuffer
if (byteOffset < 0 || array.byteLength < byteOffset) {

@@ -246,3 +244,3 @@ throw new RangeError('\'offset\' is out of bounds')

function fromObject (obj) {
if (Buffer.isBuffer(obj)) {
if (obj instanceof Buffer) {
var len = checked(obj.length) | 0

@@ -260,4 +258,3 @@ var buf = createBuffer(len)

if (obj) {
if ((typeof ArrayBuffer !== 'undefined' &&
obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
if (ArrayBuffer.isView(obj) || 'length' in obj) {
if (typeof obj.length !== 'number' || isnan(obj.length)) {

@@ -295,7 +292,7 @@ return createBuffer(0)

Buffer.isBuffer = function isBuffer (b) {
return !!(b != null && b._isBuffer)
return b instanceof Buffer
}
Buffer.compare = function compare (a, b) {
if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
if (!(a instanceof Buffer) || !(b instanceof Buffer)) {
throw new TypeError('Arguments must be Buffers')

@@ -362,3 +359,3 @@ }

var buf = list[i]
if (!Buffer.isBuffer(buf)) {
if (!(buf instanceof Buffer)) {
throw new TypeError('"list" argument must be an Array of Buffers')

@@ -373,7 +370,6 @@ }

function byteLength (string, encoding) {
if (Buffer.isBuffer(string)) {
if (string instanceof Buffer) {
return string.length
}
if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
(ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
if (ArrayBuffer.isView(string) || string instanceof ArrayBuffer) {
return string.byteLength

@@ -488,4 +484,4 @@ }

// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
// Buffer instances.
// The property is used by the `is-buffer` npm package to detect Buffer instances
// in Safari 5-7. Remove this eventually.
Buffer.prototype._isBuffer = true

@@ -544,3 +540,3 @@

Buffer.prototype.equals = function equals (b) {
if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
if (!(b instanceof Buffer)) throw new TypeError('Argument must be a Buffer')
if (this === b) return true

@@ -561,3 +557,3 @@ return Buffer.compare(this, b) === 0

Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
if (!Buffer.isBuffer(target)) {
if (!(target instanceof Buffer)) {
throw new TypeError('Argument must be a Buffer')

@@ -664,3 +660,3 @@ }

// Finally, search either indexOf (if dir is true) or lastIndexOf
if (Buffer.isBuffer(val)) {
if (val instanceof Buffer) {
// Special case: looking for empty string/buffer always fails

@@ -1020,3 +1016,3 @@ if (val.length === 0) {

for (var i = 0; i < bytes.length; i += 2) {
res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))
}

@@ -1232,3 +1228,3 @@ return res

function checkInt (buf, value, offset, ext, max, min) {
if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
if (!(buf instanceof Buffer)) throw new TypeError('"buffer" argument must be a Buffer instance')
if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')

@@ -1328,3 +1324,3 @@ if (offset + ext > buf.length) throw new RangeError('Index out of range')

if (!noAssert) {
var limit = Math.pow(2, 8 * byteLength - 1)
var limit = Math.pow(2, (8 * byteLength) - 1)

@@ -1352,3 +1348,3 @@ checkInt(this, value, offset, byteLength, limit - 1, -limit)

if (!noAssert) {
var limit = Math.pow(2, 8 * byteLength - 1)
var limit = Math.pow(2, (8 * byteLength) - 1)

@@ -1563,3 +1559,3 @@ checkInt(this, value, offset, byteLength, limit - 1, -limit)

} else {
var bytes = Buffer.isBuffer(val)
var bytes = val instanceof Buffer
? val

@@ -1566,0 +1562,0 @@ : new Buffer(val, encoding)

{
"name": "buffer",
"description": "Node.js Buffer API, for the browser",
"version": "5.0.3",
"version": "5.0.4",
"author": {

@@ -6,0 +6,0 @@ "name": "Feross Aboukhadijeh",

@@ -32,3 +32,3 @@ var B = require('../').Buffer

test('hex of write{Uint,Int}{8,16,32}{LE,BE}', function (t) {
t.plan(2 * (2 * 2 * 2 + 2))
t.plan(2 * ((2 * 2 * 2) + 2))
var hex = [

@@ -69,3 +69,3 @@ '03', '0300', '0003', '03000000', '00000003',

test('hex of write{Uint,Int}{8,16,32}{LE,BE} with overflow', function (t) {
t.plan(3 * (2 * 2 * 2 + 2))
t.plan(3 * ((2 * 2 * 2) + 2))
var hex = [

@@ -89,3 +89,3 @@ '', '03', '00', '030000', '000000',

var v1 = new B(y / 8 - 1)
var v1 = new B((y / 8) - 1)
var next = new B(4)

@@ -92,0 +92,0 @@ next.writeUInt32BE(0, 0)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc