Socket
Socket
Sign inDemoInstall

buffer

Package Overview
Dependencies
Maintainers
1
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

buffer - npm Package Compare versions

Comparing version 2.3.4 to 2.4.0

60

bundle.js

@@ -57,15 +57,15 @@ require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({"Focm2+":[function(require,module,exports){

if (encoding === 'base64' && type === 'string') {
subject = base64clean(subject)
}
// Find the length
var length
if (type === 'number')
length = coerce(subject)
else if (type === 'string')
length = subject > 0 ? subject >>> 0 : 0
else if (type === 'string') {
if (encoding === 'base64')
subject = base64clean(subject)
length = Buffer.byteLength(subject, encoding)
else if (type === 'object')
length = coerce(subject.length) // assume that object is array-like
else
} else if (type === 'object' && subject !== null) { // assume object is array-like
if (subject.type === 'Buffer' && Array.isArray(subject.data))
subject = subject.data
length = +subject.length > 0 ? Math.floor(+subject.length) : 0
} else
throw new Error('First argument needs to be a number, array or string.')

@@ -478,5 +478,24 @@

var len = this.length
start = clamp(start, len, 0)
end = clamp(end, len, len)
start = ~~start
end = end === undefined ? len : ~~end
if (start < 0) {
start += len;
if (start < 0)
start = 0
} else if (start > len) {
start = len
}
if (end < 0) {
end += len
if (end < 0)
end = 0
} else if (end > len) {
end = len
}
if (end < start)
end = start
if (Buffer._useTypedArrays) {

@@ -1034,21 +1053,2 @@ return Buffer._augment(this.subarray(start, end))

// slice(start, end)
function clamp (index, len, defaultValue) {
if (typeof index !== 'number') return defaultValue
index = ~~index; // Coerce to integer.
if (index >= len) return len
if (index >= 0) return index
index += len
if (index >= 0) return index
return 0
}
function coerce (length) {
// Coerce length to a number (possibly NaN), round up
// in case it's fractional (e.g. 123.456) then do a
// double negate to coerce a NaN to 0. Easy, right?
length = ~~Math.ceil(+length)
return length < 0 ? 0 : length
}
function isArray (subject) {

@@ -1055,0 +1055,0 @@ return (Array.isArray || function (subject) {

@@ -56,15 +56,15 @@ /*!

if (encoding === 'base64' && type === 'string') {
subject = base64clean(subject)
}
// Find the length
var length
if (type === 'number')
length = coerce(subject)
else if (type === 'string')
length = subject > 0 ? subject >>> 0 : 0
else if (type === 'string') {
if (encoding === 'base64')
subject = base64clean(subject)
length = Buffer.byteLength(subject, encoding)
else if (type === 'object')
length = coerce(subject.length) // assume that object is array-like
else
} else if (type === 'object' && subject !== null) { // assume object is array-like
if (subject.type === 'Buffer' && Array.isArray(subject.data))
subject = subject.data
length = +subject.length > 0 ? Math.floor(+subject.length) : 0
} else
throw new Error('First argument needs to be a number, array or string.')

@@ -477,5 +477,24 @@

var len = this.length
start = clamp(start, len, 0)
end = clamp(end, len, len)
start = ~~start
end = end === undefined ? len : ~~end
if (start < 0) {
start += len;
if (start < 0)
start = 0
} else if (start > len) {
start = len
}
if (end < 0) {
end += len
if (end < 0)
end = 0
} else if (end > len) {
end = len
}
if (end < start)
end = start
if (Buffer._useTypedArrays) {

@@ -1033,21 +1052,2 @@ return Buffer._augment(this.subarray(start, end))

// slice(start, end)
function clamp (index, len, defaultValue) {
if (typeof index !== 'number') return defaultValue
index = ~~index; // Coerce to integer.
if (index >= len) return len
if (index >= 0) return index
index += len
if (index >= 0) return index
return 0
}
function coerce (length) {
// Coerce length to a number (possibly NaN), round up
// in case it's fractional (e.g. 123.456) then do a
// double negate to coerce a NaN to 0. Easy, right?
length = ~~Math.ceil(+length)
return length < 0 ? 0 : length
}
function isArray (subject) {

@@ -1054,0 +1054,0 @@ return (Array.isArray || function (subject) {

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

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

@@ -164,2 +164,11 @@ var B = require('../').Buffer

test('new buffer from buffer.toJSON() output', function (t) {
var buf = new B('test')
var json = JSON.stringify(buf)
var obj = JSON.parse(json)
var copy = new B(obj)
t.ok(buf.equals(copy))
t.end()
})
test('buffer copy example', function (t) {

@@ -166,0 +175,0 @@ var buf1 = new B(26)

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc