Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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.1.7 to 2.1.8

18

bundle.js

@@ -78,3 +78,3 @@ 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){

else if (type === 'object')
length = coerce(subject.length) // Assume object is an array
length = coerce(subject.length) // assume that object is array-like
else

@@ -86,3 +86,3 @@ throw new Error('First argument needs to be a number, array or string.')

// Preferred: Return an augmented `Uint8Array` instance for best performance
buf = augment(new Uint8Array(length))
buf = Buffer._augment(new Uint8Array(length))
} else {

@@ -96,5 +96,7 @@ // Fallback: Return THIS instance of Buffer (created by `new`)

var i
if (Buffer._useTypedArrays && typeof Uint8Array === 'function' &&
subject instanceof Uint8Array) {
// Speed optimization -- use set if we're copying from a Uint8Array
if (Buffer._useTypedArrays && (subject instanceof Uint8Array
|| subject instanceof Uint16Array || subject instanceof Int16Array
|| subject instanceof Uint32Array || subject instanceof Int32Array
|| subject instanceof Float32Array || subject instanceof Float64Array)) {
// Speed optimization -- use set if we're copying from a typed array
buf._set(subject)

@@ -472,3 +474,3 @@ } else if (isArrayish(subject)) {

if (Buffer._useTypedArrays) {
return augment(this.subarray(start, end))
return Buffer._augment(this.subarray(start, end))
} else {

@@ -941,5 +943,5 @@ var sliceLen = end - start

/**
* Augment the Uint8Array *instance* (not the class!) with Buffer methods
* Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods
*/
function augment (arr) {
Buffer._augment = function (arr) {
arr._isBuffer = true

@@ -946,0 +948,0 @@

@@ -77,3 +77,3 @@ /**

else if (type === 'object')
length = coerce(subject.length) // Assume object is an array
length = coerce(subject.length) // assume that object is array-like
else

@@ -85,3 +85,3 @@ throw new Error('First argument needs to be a number, array or string.')

// Preferred: Return an augmented `Uint8Array` instance for best performance
buf = augment(new Uint8Array(length))
buf = Buffer._augment(new Uint8Array(length))
} else {

@@ -95,5 +95,7 @@ // Fallback: Return THIS instance of Buffer (created by `new`)

var i
if (Buffer._useTypedArrays && typeof Uint8Array === 'function' &&
subject instanceof Uint8Array) {
// Speed optimization -- use set if we're copying from a Uint8Array
if (Buffer._useTypedArrays && (subject instanceof Uint8Array
|| subject instanceof Uint16Array || subject instanceof Int16Array
|| subject instanceof Uint32Array || subject instanceof Int32Array
|| subject instanceof Float32Array || subject instanceof Float64Array)) {
// Speed optimization -- use set if we're copying from a typed array
buf._set(subject)

@@ -471,3 +473,3 @@ } else if (isArrayish(subject)) {

if (Buffer._useTypedArrays) {
return augment(this.subarray(start, end))
return Buffer._augment(this.subarray(start, end))
} else {

@@ -940,5 +942,5 @@ var sliceLen = end - start

/**
* Augment the Uint8Array *instance* (not the class!) with Buffer methods
* Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods
*/
function augment (arr) {
Buffer._augment = function (arr) {
arr._isBuffer = true

@@ -945,0 +947,0 @@

{
"name": "buffer",
"description": "Node.js Buffer API, for the browser",
"version": "2.1.7",
"version": "2.1.8",
"author": "Feross Aboukhadijeh <feross@feross.org> (http://feross.org/)",

@@ -6,0 +6,0 @@ "bugs": {

@@ -1,2 +0,2 @@

var B = require('../index.js').Buffer
var B = require('../').Buffer
var test = require('tape')

@@ -21,2 +21,107 @@

test('new buffer from buffer', function (t) {
var b1 = new B('asdf')
var b2 = new B(b1)
t.equal(b1.toString('hex'), b2.toString('hex'))
t.end()
})
test('new buffer from uint8array', function (t) {
if (typeof Uint8Array === 'function') {
var b1 = new Uint8Array([0, 1, 2, 3])
var b2 = new B(b1)
t.equal(b1.length, b2.length)
t.equal(b1[0], 0)
t.equal(b1[1], 1)
t.equal(b1[2], 2)
t.equal(b1[3], 3)
t.equal(b1[4], undefined)
}
t.end()
})
test('new buffer from uint16array', function (t) {
if (typeof Uint16Array === 'function') {
var b1 = new Uint16Array([0, 1, 2, 3])
var b2 = new B(b1)
t.equal(b1.length, b2.length)
t.equal(b1[0], 0)
t.equal(b1[1], 1)
t.equal(b1[2], 2)
t.equal(b1[3], 3)
t.equal(b1[4], undefined)
}
t.end()
})
test('new buffer from uint32array', function (t) {
if (typeof Uint32Array === 'function') {
var b1 = new Uint32Array([0, 1, 2, 3])
var b2 = new B(b1)
t.equal(b1.length, b2.length)
t.equal(b1[0], 0)
t.equal(b1[1], 1)
t.equal(b1[2], 2)
t.equal(b1[3], 3)
t.equal(b1[4], undefined)
}
t.end()
})
test('new buffer from int16array', function (t) {
if (typeof Int16Array === 'function') {
var b1 = new Int16Array([0, 1, 2, 3])
var b2 = new B(b1)
t.equal(b1.length, b2.length)
t.equal(b1[0], 0)
t.equal(b1[1], 1)
t.equal(b1[2], 2)
t.equal(b1[3], 3)
t.equal(b1[4], undefined)
}
t.end()
})
test('new buffer from int32array', function (t) {
if (typeof Int32Array === 'function') {
var b1 = new Int32Array([0, 1, 2, 3])
var b2 = new B(b1)
t.equal(b1.length, b2.length)
t.equal(b1[0], 0)
t.equal(b1[1], 1)
t.equal(b1[2], 2)
t.equal(b1[3], 3)
t.equal(b1[4], undefined)
}
t.end()
})
test('new buffer from float32array', function (t) {
if (typeof Float32Array === 'function') {
var b1 = new Float32Array([0, 1, 2, 3])
var b2 = new B(b1)
t.equal(b1.length, b2.length)
t.equal(b1[0], 0)
t.equal(b1[1], 1)
t.equal(b1[2], 2)
t.equal(b1[3], 3)
t.equal(b1[4], undefined)
}
t.end()
})
test('new buffer from float64array', function (t) {
if (typeof Float64Array === 'function') {
var b1 = new Float64Array([0, 1, 2, 3])
var b2 = new B(b1)
t.equal(b1.length, b2.length)
t.equal(b1[0], 0)
t.equal(b1[1], 1)
t.equal(b1[2], 2)
t.equal(b1[3], 3)
t.equal(b1[4], undefined)
}
t.end()
})
test('buffer toArrayBuffer()', function (t) {

@@ -23,0 +128,0 @@ var data = [1, 2, 3, 4, 5, 6, 7, 8]

@@ -1,2 +0,2 @@

var B = require('../index.js').Buffer
var B = require('../').Buffer
var test = require('tape')

@@ -6,3 +6,3 @@

t.equal(
new B("Ձאab", "utf8").toString("base64"),
new B('Ձאab', 'utf8').toString('base64'),
'1YHXkGFi'

@@ -15,3 +15,3 @@ )

t.equal(
new B("Ձאab", "utf8").toString("hex"),
new B('Ձאab', 'utf8').toString('hex'),
'd581d7906162'

@@ -24,3 +24,3 @@ )

t.equal(
new B("öäüõÖÄÜÕ", "utf8").toString("utf8"),
new B('öäüõÖÄÜÕ', 'utf8').toString('utf8'),
'öäüõÖÄÜÕ'

@@ -34,3 +34,3 @@ )

t.equal(
new B(new B("abcd", "utf8").toString("utf16le"), "utf16le").toString("utf8"),
new B(new B('abcd', 'utf8').toString('utf16le'), 'utf16le').toString('utf8'),
'abcd'

@@ -44,3 +44,3 @@ );

t.equal(
new B("abcd", "utf16le").toString('hex'),
new B('abcd', 'utf16le').toString('hex'),
'6100620063006400'

@@ -53,3 +53,3 @@ );

t.equal(
new B("123456!@#$%^", "ascii").toString("base64"),
new B('123456!@#$%^', 'ascii').toString('base64'),
'MTIzNDU2IUAjJCVe'

@@ -62,3 +62,3 @@ )

t.equal(
new B("123456!@#$%^", "ascii").toString("hex"),
new B('123456!@#$%^', 'ascii').toString('hex'),
'31323334353621402324255e'

@@ -71,3 +71,3 @@ )

t.equal(
new B("1YHXkGFi", "base64").toString("utf8"),
new B('1YHXkGFi', 'base64').toString('utf8'),
'Ձאab'

@@ -80,3 +80,3 @@ )

t.equal(
new B("d581d7906162", "hex").toString("utf8"),
new B('d581d7906162', 'hex').toString('utf8'),
'Ձאab'

@@ -89,3 +89,3 @@ )

t.equal(
new B("MTIzNDU2IUAjJCVe", "base64").toString("ascii"),
new B('MTIzNDU2IUAjJCVe', 'base64').toString('ascii'),
'123456!@#$%^'

@@ -98,3 +98,3 @@ )

t.equal(
new B("31323334353621402324255e", "hex").toString("ascii"),
new B('31323334353621402324255e', 'hex').toString('ascii'),
'123456!@#$%^'

@@ -107,3 +107,3 @@ )

t.equal(
new B("MTIzNDU2IUAjJCVe", "base64").toString("binary"),
new B('MTIzNDU2IUAjJCVe', 'base64').toString('binary'),
'123456!@#$%^'

@@ -116,3 +116,3 @@ )

t.equal(
new B("31323334353621402324255e", "hex").toString("binary"),
new B('31323334353621402324255e', 'hex').toString('binary'),
'123456!@#$%^'

@@ -125,4 +125,4 @@ )

t.equal(
new B("öäüõÖÄÜÕ", "utf8").toString("binary"),
"öäüõÖÄÜÕ"
new B('öäüõÖÄÜÕ', 'utf8').toString('binary'),
'öäüõÖÄÜÕ'
)

@@ -132,10 +132,10 @@ t.end()

test("hex of write{Uint,Int}{8,16,32}{LE,BE}", function (t) {
test('hex of write{Uint,Int}{8,16,32}{LE,BE}', function (t) {
t.plan(2*(2*2*2+2))
var hex = [
"03", "0300", "0003", "03000000", "00000003",
"fd", "fdff", "fffd", "fdffffff", "fffffffd"
'03', '0300', '0003', '03000000', '00000003',
'fd', 'fdff', 'fffd', 'fdffffff', 'fffffffd'
]
var reads = [ 3, 3, 3, 3, 3, -3, -3, -3, -3, -3 ]
var xs = ["UInt","Int"]
var xs = ['UInt','Int']
var ys = [8,16,32]

@@ -146,3 +146,3 @@ for (var i = 0; i < xs.length; i++) {

var y = ys[j]
var endianesses = (y === 8) ? [""] : ["LE","BE"]
var endianesses = (y === 8) ? [''] : ['LE','BE']
for (var k = 0; k < endianesses.length; k++) {

@@ -152,10 +152,10 @@ var z = endianesses[k]

var v1 = new B(y / 8)
var writefn = "write" + x + y + z
var val = (x === "Int") ? -3 : 3
var writefn = 'write' + x + y + z
var val = (x === 'Int') ? -3 : 3
v1[writefn](val, 0)
t.equal(
v1.toString("hex"),
v1.toString('hex'),
hex.shift()
)
var readfn = "read" + x + y + z
var readfn = 'read' + x + y + z
t.equal(

@@ -171,7 +171,7 @@ v1[readfn](0),

test("hex of write{Uint,Int}{8,16,32}{LE,BE} with overflow", function (t) {
test('hex of write{Uint,Int}{8,16,32}{LE,BE} with overflow', function (t) {
t.plan(3*(2*2*2+2))
var hex = [
"", "03", "00", "030000", "000000",
"", "fd", "ff", "fdffff", "ffffff"
'', '03', '00', '030000', '000000',
'', 'fd', 'ff', 'fdffff', 'ffffff'
]

@@ -182,3 +182,3 @@ var reads = [

]
var xs = ["UInt","Int"]
var xs = ['UInt','Int']
var ys = [8,16,32]

@@ -189,3 +189,3 @@ for (var i = 0; i < xs.length; i++) {

var y = ys[j]
var endianesses = (y === 8) ? [""] : ["LE","BE"]
var endianesses = (y === 8) ? [''] : ['LE','BE']
for (var k = 0; k < endianesses.length; k++) {

@@ -197,7 +197,7 @@ var z = endianesses[k]

next.writeUInt32BE(0, 0)
var writefn = "write" + x + y + z
var val = (x === "Int") ? -3 : 3
var writefn = 'write' + x + y + z
var val = (x === 'Int') ? -3 : 3
v1[writefn](val, 0, true)
t.equal(
v1.toString("hex"),
v1.toString('hex'),
hex.shift()

@@ -209,3 +209,3 @@ )

next.writeInt32BE(~0, 0)
var readfn = "read" + x + y + z
var readfn = 'read' + x + y + z
t.equal(

@@ -221,3 +221,3 @@ v1[readfn](0, true),

test("concat() a varying number of buffers", function (t) {
test('concat() a varying number of buffers', function (t) {
t.plan(5)

@@ -242,23 +242,3 @@ var zero = []

test("new buffer from buffer", function (t) {
var b1 = new B('asdf')
var b2 = new B(b1)
t.equal(b1.toString('hex'), b2.toString('hex'))
t.end()
})
test("new buffer from uint8array", function (t) {
if (typeof Uint8Array === 'function') {
var b1 = new Uint8Array([0, 1, 2, 3])
var b2 = new B(b1)
t.equal(b1[0], 0)
t.equal(b1[1], 1)
t.equal(b1[2], 2)
t.equal(b1[3], 3)
t.equal(b1[4], undefined)
}
t.end()
})
test("fill", function(t) {
test('fill', function(t) {
t.plan(1)

@@ -282,3 +262,3 @@ var b = new B(10)

t.plan(1)
var text = "\n YW9ldQ== "
var text = '\n YW9ldQ== '
var buf = new B(text, 'base64')

@@ -285,0 +265,0 @@ t.equal(buf.toString(), 'aoeu')

@@ -1,2 +0,2 @@

var B = require('../index.js').Buffer
var B = require('../').Buffer
var test = require('tape')

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

var B = require('../index.js').Buffer
var B = require('../').Buffer
var test = require('tape')

@@ -3,0 +3,0 @@

@@ -1,3 +0,2 @@

var B = require('../index.js').Buffer
var B = require('../').Buffer
var test = require('tape')

@@ -4,0 +3,0 @@

@@ -1,2 +0,2 @@

var B = require('../index.js').Buffer
var B = require('../').Buffer
var test = require('tape')

@@ -3,0 +3,0 @@

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