New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bare-buffer

Package Overview
Dependencies
Maintainers
0
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bare-buffer - npm Package Compare versions

Comparing version 2.6.0 to 2.7.0

global.js

347

index.js

@@ -11,3 +11,3 @@ const constants = require('./lib/constants')

const Buffer = module.exports = exports = class Buffer extends Uint8Array {
module.exports = exports = class Buffer extends Uint8Array {
static {

@@ -17,15 +17,15 @@ binding.tag(this)

static get poolSize () {
static get poolSize() {
return poolSize
}
static set poolSize (value) {
static set poolSize(value) {
poolSize = Math.max(0, value)
}
[Symbol.species] () {
[Symbol.species]() {
return Buffer
}
copy (target, targetStart = 0, sourceStart = 0, sourceEnd = this.byteLength) {
copy(target, targetStart = 0, sourceStart = 0, sourceEnd = this.byteLength) {
let source = this

@@ -44,3 +44,5 @@

if (sourceEnd - sourceStart > targetLength) sourceEnd = sourceStart + targetLength
if (sourceEnd - sourceStart > targetLength) {
sourceEnd = sourceStart + targetLength
}

@@ -52,3 +54,5 @@ const sourceLength = sourceEnd - sourceStart

} else {
if (sourceStart !== 0 || sourceEnd !== source.byteLength) source = source.subarray(sourceStart, sourceEnd)
if (sourceStart !== 0 || sourceEnd !== source.byteLength) {
source = source.subarray(sourceStart, sourceEnd)
}

@@ -61,3 +65,3 @@ target.set(source, targetStart)

equals (target) {
equals(target) {
const source = this

@@ -72,3 +76,9 @@

compare (target, targetStart = 0, targetEnd = target.byteLength, sourceStart = 0, sourceEnd = this.byteLength) {
compare(
target,
targetStart = 0,
targetEnd = target.byteLength,
sourceStart = 0,
sourceEnd = this.byteLength
) {
let source = this

@@ -92,5 +102,9 @@

if (sourceStart !== 0 || sourceEnd !== source.byteLength) source = source.subarray(sourceStart, sourceEnd)
if (sourceStart !== 0 || sourceEnd !== source.byteLength) {
source = source.subarray(sourceStart, sourceEnd)
}
if (targetStart !== 0 || targetEnd !== target.byteLength) target = target.subarray(targetStart, targetEnd)
if (targetStart !== 0 || targetEnd !== target.byteLength) {
target = target.subarray(targetStart, targetEnd)
}

@@ -100,3 +114,3 @@ return binding.compare(source, target)

fill (value, offset = 0, end = this.byteLength, encoding = 'utf8') {
fill(value, offset = 0, end = this.byteLength, encoding = 'utf8') {
if (typeof value === 'string') {

@@ -109,3 +123,3 @@ // fill(string, encoding)

// fill(string, offset, encoding)
// fill(string, offset, encoding)
} else if (typeof end === 'string') {

@@ -140,7 +154,7 @@ encoding = end

includes (value, offset, encoding) {
includes(value, offset, encoding) {
return this.indexOf(value, offset, encoding) !== -1
}
indexOf (value, offset = 0, encoding) {
indexOf(value, offset = 0, encoding) {
if (typeof value === 'number') return super.indexOf(value & 0xff, offset)

@@ -151,4 +165,6 @@

lastIndexOf (value, offset = this.byteLength - 1, encoding) {
if (typeof value === 'number') return super.lastIndexOf(value & 0xff, offset)
lastIndexOf(value, offset = this.byteLength - 1, encoding) {
if (typeof value === 'number') {
return super.lastIndexOf(value & 0xff, offset)
}

@@ -158,6 +174,8 @@ return bidirectionalIndexOf(this, value, offset, encoding, false /* last */)

swap16 () {
swap16() {
const length = this.byteLength
if (length % 2 !== 0) throw new RangeError('Buffer size must be a multiple of 16-bits')
if (length % 2 !== 0) {
throw new RangeError('Buffer size must be a multiple of 16-bits')
}

@@ -169,6 +187,8 @@ for (let i = 0; i < length; i += 2) swap(this, i, i + 1)

swap32 () {
swap32() {
const length = this.byteLength
if (length % 4 !== 0) throw new RangeError('Buffer size must be a multiple of 32-bits')
if (length % 4 !== 0) {
throw new RangeError('Buffer size must be a multiple of 32-bits')
}

@@ -183,6 +203,8 @@ for (let i = 0; i < length; i += 4) {

swap64 () {
swap64() {
const length = this.byteLength
if (length % 8 !== 0) throw new RangeError('Buffer size must be a multiple of 64-bits')
if (length % 8 !== 0) {
throw new RangeError('Buffer size must be a multiple of 64-bits')
}

@@ -199,3 +221,3 @@ for (let i = 0; i < length; i += 8) {

toString (encoding, start = 0, end = this.byteLength) {
toString(encoding, start = 0, end = this.byteLength) {
// toString()

@@ -215,3 +237,5 @@ if (arguments.length === 0) return utf8.toString(this)

if (start !== 0 || end !== this.byteLength) buffer = buffer.subarray(start, end)
if (start !== 0 || end !== this.byteLength) {
buffer = buffer.subarray(start, end)
}

@@ -221,3 +245,8 @@ return codecFor(encoding).toString(buffer)

write (string, offset = 0, length = this.byteLength - offset, encoding = 'utf8') {
write(
string,
offset = 0,
length = this.byteLength - offset,
encoding = 'utf8'
) {
// write(string)

@@ -232,3 +261,3 @@ if (arguments.length === 1) return utf8.write(this, string)

// write(string, offset, encoding)
// write(string, offset, encoding)
} else if (typeof length === 'string') {

@@ -251,3 +280,5 @@ encoding = length

if (start !== 0 || end !== this.byteLength) buffer = buffer.subarray(start, end)
if (start !== 0 || end !== this.byteLength) {
buffer = buffer.subarray(start, end)
}

@@ -257,83 +288,203 @@ return codecFor(encoding).write(buffer, string)

readBigInt64BE (offset = 0) { return viewOf(this).getBigInt64(offset, false) }
readBigInt64LE (offset = 0) { return viewOf(this).getBigInt64(offset, true) }
readBigInt64BE(offset = 0) {
return viewOf(this).getBigInt64(offset, false)
}
readBigInt64LE(offset = 0) {
return viewOf(this).getBigInt64(offset, true)
}
readBigUint64BE (offset = 0) { return viewOf(this).getBigUint64(offset, false) }
readBigUint64LE (offset = 0) { return viewOf(this).getBigUint64(offset, true) }
readBigUint64BE(offset = 0) {
return viewOf(this).getBigUint64(offset, false)
}
readBigUint64LE(offset = 0) {
return viewOf(this).getBigUint64(offset, true)
}
readDoubleBE (offset = 0) { return viewOf(this).getFloat64(offset, false) }
readDoubleLE (offset = 0) { return viewOf(this).getFloat64(offset, true) }
readDoubleBE(offset = 0) {
return viewOf(this).getFloat64(offset, false)
}
readDoubleLE(offset = 0) {
return viewOf(this).getFloat64(offset, true)
}
readFloatBE (offset = 0) { return viewOf(this).getFloat32(offset, false) }
readFloatLE (offset = 0) { return viewOf(this).getFloat32(offset, true) }
readFloatBE(offset = 0) {
return viewOf(this).getFloat32(offset, false)
}
readFloatLE(offset = 0) {
return viewOf(this).getFloat32(offset, true)
}
readInt8 (offset = 0) { return viewOf(this).getInt8(offset) }
readInt8(offset = 0) {
return viewOf(this).getInt8(offset)
}
readInt16BE (offset = 0) { return viewOf(this).getInt16(offset, false) }
readInt16LE (offset = 0) { return viewOf(this).getInt16(offset, true) }
readInt16BE(offset = 0) {
return viewOf(this).getInt16(offset, false)
}
readInt16LE(offset = 0) {
return viewOf(this).getInt16(offset, true)
}
readInt32BE (offset = 0) { return viewOf(this).getInt32(offset, false) }
readInt32LE (offset = 0) { return viewOf(this).getInt32(offset, true) }
readInt32BE(offset = 0) {
return viewOf(this).getInt32(offset, false)
}
readInt32LE(offset = 0) {
return viewOf(this).getInt32(offset, true)
}
readUint8 (offset = 0) { return viewOf(this).getUint8(offset) }
readUint8(offset = 0) {
return viewOf(this).getUint8(offset)
}
readUint16BE (offset = 0) { return viewOf(this).getUint16(offset, false) }
readUint16LE (offset = 0) { return viewOf(this).getUint16(offset, true) }
readUint16BE(offset = 0) {
return viewOf(this).getUint16(offset, false)
}
readUint16LE(offset = 0) {
return viewOf(this).getUint16(offset, true)
}
readUint32BE (offset = 0) { return viewOf(this).getUint32(offset, false) }
readUint32LE (offset = 0) { return viewOf(this).getUint32(offset, true) }
readUint32BE(offset = 0) {
return viewOf(this).getUint32(offset, false)
}
readUint32LE(offset = 0) {
return viewOf(this).getUint32(offset, true)
}
readBigUInt64BE (...args) { return this.readBigUint64BE(...args) }
readBigUInt64LE (...args) { return this.readBigUint64LE(...args) }
readBigUInt64BE(...args) {
return this.readBigUint64BE(...args)
}
readBigUInt64LE(...args) {
return this.readBigUint64LE(...args)
}
readUInt8 (...args) { return this.readUint8(...args) }
readUInt8(...args) {
return this.readUint8(...args)
}
readUInt16BE (...args) { return this.readUint16BE(...args) }
readUInt16LE (...args) { return this.readUint16LE(...args) }
readUInt16BE(...args) {
return this.readUint16BE(...args)
}
readUInt16LE(...args) {
return this.readUint16LE(...args)
}
readUInt32BE (...args) { return this.readUint32BE(...args) }
readUInt32LE (...args) { return this.readUint32LE(...args) }
readUInt32BE(...args) {
return this.readUint32BE(...args)
}
readUInt32LE(...args) {
return this.readUint32LE(...args)
}
writeBigInt64BE (value, offset = 0) { viewOf(this).setBigInt64(offset, value, false); return offset + 8 }
writeBigInt64LE (value, offset = 0) { viewOf(this).setBigInt64(offset, value, true); return offset + 8 }
writeBigInt64BE(value, offset = 0) {
viewOf(this).setBigInt64(offset, value, false)
return offset + 8
}
writeBigInt64LE(value, offset = 0) {
viewOf(this).setBigInt64(offset, value, true)
return offset + 8
}
writeBigUint64BE (value, offset = 0) { viewOf(this).setBigUint64(offset, value, false); return offset + 8 }
writeBigUint64LE (value, offset = 0) { viewOf(this).setBigUint64(offset, value, true); return offset + 8 }
writeBigUint64BE(value, offset = 0) {
viewOf(this).setBigUint64(offset, value, false)
return offset + 8
}
writeBigUint64LE(value, offset = 0) {
viewOf(this).setBigUint64(offset, value, true)
return offset + 8
}
writeDoubleBE (value, offset = 0) { viewOf(this).setFloat64(offset, value, false); return offset + 8 }
writeDoubleLE (value, offset = 0) { viewOf(this).setFloat64(offset, value, true); return offset + 8 }
writeDoubleBE(value, offset = 0) {
viewOf(this).setFloat64(offset, value, false)
return offset + 8
}
writeDoubleLE(value, offset = 0) {
viewOf(this).setFloat64(offset, value, true)
return offset + 8
}
writeFloatBE (value, offset = 0) { viewOf(this).setFloat32(offset, value, false); return offset + 4 }
writeFloatLE (value, offset = 0) { viewOf(this).setFloat32(offset, value, true); return offset + 4 }
writeFloatBE(value, offset = 0) {
viewOf(this).setFloat32(offset, value, false)
return offset + 4
}
writeFloatLE(value, offset = 0) {
viewOf(this).setFloat32(offset, value, true)
return offset + 4
}
writeInt8 (value, offset = 0) { viewOf(this).setInt8(offset, value); return offset + 1 }
writeInt8(value, offset = 0) {
viewOf(this).setInt8(offset, value)
return offset + 1
}
writeInt16BE (value, offset = 0) { viewOf(this).setInt16(offset, value, false); return offset + 2 }
writeInt16LE (value, offset = 0) { viewOf(this).setInt16(offset, value, true); return offset + 2 }
writeInt16BE(value, offset = 0) {
viewOf(this).setInt16(offset, value, false)
return offset + 2
}
writeInt16LE(value, offset = 0) {
viewOf(this).setInt16(offset, value, true)
return offset + 2
}
writeInt32BE (value, offset = 0) { viewOf(this).setInt32(offset, value, false); return offset + 4 }
writeInt32LE (value, offset = 0) { viewOf(this).setInt32(offset, value, true); return offset + 4 }
writeInt32BE(value, offset = 0) {
viewOf(this).setInt32(offset, value, false)
return offset + 4
}
writeInt32LE(value, offset = 0) {
viewOf(this).setInt32(offset, value, true)
return offset + 4
}
writeUint8 (value, offset = 0) { viewOf(this).setUint8(offset, value, true); return offset + 1 }
writeUint8(value, offset = 0) {
viewOf(this).setUint8(offset, value, true)
return offset + 1
}
writeUint16BE (value, offset = 0) { viewOf(this).setUint16(offset, value, false); return offset + 2 }
writeUint16LE (value, offset = 0) { viewOf(this).setUint16(offset, value, true); return offset + 2 }
writeUint16BE(value, offset = 0) {
viewOf(this).setUint16(offset, value, false)
return offset + 2
}
writeUint16LE(value, offset = 0) {
viewOf(this).setUint16(offset, value, true)
return offset + 2
}
writeUint32LE (value, offset = 0) { viewOf(this).setUint32(offset, value, true); return offset + 4 }
writeUint32BE (value, offset = 0) { viewOf(this).setUint32(offset, value, false); return offset + 4 }
writeUint32LE(value, offset = 0) {
viewOf(this).setUint32(offset, value, true)
return offset + 4
}
writeUint32BE(value, offset = 0) {
viewOf(this).setUint32(offset, value, false)
return offset + 4
}
writeBigUInt64BE (...args) { return this.writeBigUint64BE(...args) }
writeBigUInt64LE (...args) { return this.writeBigUint64LE(...args) }
writeBigUInt64BE(...args) {
return this.writeBigUint64BE(...args)
}
writeBigUInt64LE(...args) {
return this.writeBigUint64LE(...args)
}
writeUInt8 (...args) { return this.writeUint8(...args) }
writeUInt8(...args) {
return this.writeUint8(...args)
}
writeUInt16BE (...args) { return this.writeUint16BE(...args) }
writeUInt16LE (...args) { return this.writeUint16LE(...args) }
writeUInt16BE(...args) {
return this.writeUint16BE(...args)
}
writeUInt16LE(...args) {
return this.writeUint16LE(...args)
}
writeUInt32BE (...args) { return this.writeUint32BE(...args) }
writeUInt32LE (...args) { return this.writeUint32LE(...args) }
writeUInt32BE(...args) {
return this.writeUint32BE(...args)
}
writeUInt32LE(...args) {
return this.writeUint32LE(...args)
}
}
exports.Buffer = exports
const Buffer = exports
exports.Buffer = Buffer // For Node.js compatibility
exports.constants = constants

@@ -349,3 +500,3 @@

function codecFor (encoding = 'utf8') {
function codecFor(encoding = 'utf8') {
if (encoding in codecs) return codecs[encoding]

@@ -362,3 +513,3 @@

function viewOf (buffer) {
function viewOf(buffer) {
let view = views.get(buffer)

@@ -372,3 +523,3 @@ if (view === undefined) {

exports.isBuffer = function isBuffer (value) {
exports.isBuffer = function isBuffer(value) {
if (typeof value !== 'object' || value === null) return false

@@ -387,3 +538,3 @@

exports.isEncoding = function isEncoding (encoding) {
exports.isEncoding = function isEncoding(encoding) {
try {

@@ -397,3 +548,3 @@ codecFor(encoding)

exports.alloc = function alloc (size, fill, encoding) {
exports.alloc = function alloc(size, fill, encoding) {
const buffer = new Buffer(size)

@@ -404,3 +555,3 @@ if (fill !== undefined) buffer.fill(fill, 0, buffer.byteLength, encoding)

exports.allocUnsafe = function allocUnsafe (size) {
exports.allocUnsafe = function allocUnsafe(size) {
binding.setZeroFillEnabled(0)

@@ -414,7 +565,7 @@ try {

exports.allocUnsafeSlow = function allocUnsafeSlow (size) {
exports.allocUnsafeSlow = function allocUnsafeSlow(size) {
return exports.allocUnsafe(size)
}
exports.byteLength = function byteLength (string, encoding) {
exports.byteLength = function byteLength(string, encoding) {
if (typeof string === 'string') {

@@ -427,7 +578,7 @@ return codecFor(encoding).byteLength(string)

exports.compare = function compare (a, b) {
exports.compare = function compare(a, b) {
return binding.compare(a, b)
}
exports.concat = function concat (buffers, length) {
exports.concat = function concat(buffers, length) {
if (length === undefined) {

@@ -455,3 +606,3 @@ length = buffers.reduce((length, buffer) => length + buffer.byteLength, 0)

exports.coerce = function coerce (buffer) {
exports.coerce = function coerce(buffer) {
if (exports.isBuffer(buffer)) return buffer

@@ -461,3 +612,3 @@ return new Buffer(buffer.buffer, buffer.byteOffset, buffer.byteLength)

exports.from = function from (value, encodingOrOffset, length) {
exports.from = function from(value, encodingOrOffset, length) {
// from(string, encoding)

@@ -476,3 +627,3 @@ if (typeof value === 'string') return fromString(value, encodingOrOffset)

function fromString (string, encoding) {
function fromString(string, encoding) {
const codec = codecFor(encoding)

@@ -484,3 +635,3 @@ const buffer = new Buffer(codec.byteLength(string))

function fromArray (array) {
function fromArray(array) {
const buffer = new Buffer(array.length)

@@ -491,3 +642,3 @@ buffer.set(array)

function fromBuffer (buffer) {
function fromBuffer(buffer) {
const copy = new Buffer(buffer.byteLength)

@@ -498,7 +649,7 @@ copy.set(buffer)

function fromArrayBuffer (arrayBuffer, offset, length) {
function fromArrayBuffer(arrayBuffer, offset, length) {
return new Buffer(arrayBuffer, offset, length)
}
function bidirectionalIndexOf (buffer, value, offset, encoding, first) {
function bidirectionalIndexOf(buffer, value, offset, encoding, first) {
if (buffer.byteLength === 0) return -1

@@ -510,3 +661,3 @@

} else if (offset === undefined) {
offset = first ? 0 : (buffer.byteLength - 1)
offset = first ? 0 : buffer.byteLength - 1
} else if (offset < 0) {

@@ -562,3 +713,3 @@ offset += buffer.byteLength

function swap (buffer, n, m) {
function swap(buffer, n, m) {
const i = buffer[n]

@@ -565,0 +716,0 @@ buffer[n] = buffer[m]

@@ -1,6 +0,6 @@

exports.byteLength = function byteLength (string) {
exports.byteLength = function byteLength(string) {
return string.length
}
exports.toString = function toString (buffer) {
exports.toString = function toString(buffer) {
const len = buffer.byteLength

@@ -17,3 +17,3 @@

exports.write = function write (buffer, string) {
exports.write = function write(buffer, string) {
const len = buffer.byteLength

@@ -20,0 +20,0 @@

const binding = require('../binding')
exports.byteLength = function byteLength (string) {
exports.byteLength = function byteLength(string) {
let len = string.length

@@ -5,0 +5,0 @@

const binding = require('../binding')
exports.byteLength = function byteLength (string) {
exports.byteLength = function byteLength(string) {
return string.length >>> 1

@@ -5,0 +5,0 @@ }

const binding = require('../binding')
exports.byteLength = function byteLength (string) {
exports.byteLength = function byteLength(string) {
return string.length * 2

@@ -5,0 +5,0 @@ }

{
"name": "bare-buffer",
"version": "2.6.0",
"version": "2.7.0",
"description": "Native buffers for JavaScript",

@@ -8,2 +8,3 @@ "exports": {

"./package": "./package.json",
"./global": "./global.js",
"./constants": "./lib/constants.js"

@@ -13,2 +14,3 @@ },

"index.js",
"global.js",
"binding.c",

@@ -22,3 +24,3 @@ "binding.js",

"scripts": {
"test": "standard && bare test/all.js"
"test": "prettier . --check && bare test/all.js"
},

@@ -39,4 +41,5 @@ "repository": {

"cmake-fetch": "^1.0.0",
"standard": "^17.0.0"
"prettier": "^3.3.3",
"prettier-config-standard": "^7.0.0"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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