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

native-buffer-browserify

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

native-buffer-browserify - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

35

index.js

@@ -27,9 +27,13 @@ exports.Buffer = Buffer

var type = typeof subject
var length
var buf
// Work-around: node's base64 implementation
// allows for non-padded strings while base64-js
// does not..
if (encoding == "base64" && typeof subject == "string") {
if (encoding === 'base64' && type === 'string') {
subject = stringtrim(subject)
while (subject.length % 4 !== 0) {
subject = subject + "="
subject = subject + '='
}

@@ -39,4 +43,2 @@ }

// Find the length
var type = typeof subject
var length
if (type === 'number')

@@ -47,9 +49,18 @@ length = coerce(subject)

else if (type === 'object')
length = coerce(subject.length); // Assume object is an array
length = coerce(subject.length) // Assume object is an array
else
throw new Error('First argument needs to be a number, array or string.')
var buf = augment(new Uint8Array(length))
if (subject instanceof ArrayBuffer) {
// API Addition: do something reasonable with an ArrayBuffer. Use it as
// backing buffer for the Uint8Array.
buf = augment(new Uint8Array(subject))
} else {
buf = augment(new Uint8Array(length))
}
if (isArrayIsh(subject)) {
if (subject instanceof Uint8Array) {
// Speed optimization -- use set if we're copying from a Uint8Array
buf.set(subject, 0)
} else if (isArrayIsh(subject)) {
// Treat array-ish objects as a byte array.

@@ -62,3 +73,3 @@ for (var i = 0; i < length; i++) {

}
} else if (type == 'string') {
} else if (type === 'string') {
buf.write(subject, 0, encoding)

@@ -98,3 +109,3 @@ }

Buffer.byteLength = function (str, encoding) {
switch (encoding || "utf8") {
switch (encoding || 'utf8') {
case 'hex':

@@ -823,3 +834,3 @@ return str.length / 2

out[i] = toHex(this[i])
if (i == exports.INSPECT_MAX_BYTES) {
if (i === exports.INSPECT_MAX_BYTES) {
out[i + 1] = '...'

@@ -832,3 +843,3 @@ break

// Creates a new `ArrayBuffer` with the copied memory of the buffer instance.
// Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance.
// Added in Node 0.12.

@@ -1091,3 +1102,3 @@ function BufferToArrayBuffer () {

} catch (err) {
return String.fromCharCode(0xFFFD); // UTF 8 invalid char
return String.fromCharCode(0xFFFD) // UTF 8 invalid char
}

@@ -1094,0 +1105,0 @@ }

{
"name": "native-buffer-browserify",
"version": "1.0.0",
"version": "1.0.1",
"description": "buffer module compatibility for browserify (backed by ArrayBuffer so its fast!)",

@@ -5,0 +5,0 @@ "main": "index.js",

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