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 2.0.17 to 2.1.0

87

bundle.js

@@ -246,2 +246,7 @@ 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})({"SwUZZb":[function(require,module,exports){

function _utf16leWrite (buf, string, offset, length) {
var bytes, pos
return Buffer._charsWritten = blitBuffer(utf16leToBytes(string), buf, offset, length)
}
Buffer.prototype.write = function (string, offset, length, encoding) {

@@ -274,21 +279,30 @@ // Support both (string, offset, length, encoding)

var ret
switch (encoding) {
case 'hex':
return _hexWrite(this, string, offset, length)
ret = _hexWrite(this, string, offset, length)
break
case 'utf8':
case 'utf-8':
case 'ucs2': // TODO: No support for ucs2 or utf16le encodings yet
ret = _utf8Write(this, string, offset, length)
break
case 'ascii':
ret = _asciiWrite(this, string, offset, length)
break
case 'binary':
ret = _binaryWrite(this, string, offset, length)
break
case 'base64':
ret = _base64Write(this, string, offset, length)
break
case 'ucs2':
case 'ucs-2':
case 'utf16le':
case 'utf-16le':
return _utf8Write(this, string, offset, length)
case 'ascii':
return _asciiWrite(this, string, offset, length)
case 'binary':
return _binaryWrite(this, string, offset, length)
case 'base64':
return _base64Write(this, string, offset, length)
ret = _utf16leWrite(this, string, offset, length)
break
default:
throw new Error('Unknown encoding')
}
return ret
}

@@ -309,21 +323,30 @@

var ret
switch (encoding) {
case 'hex':
return _hexSlice(self, start, end)
ret = _hexSlice(self, start, end)
break
case 'utf8':
case 'utf-8':
case 'ucs2': // TODO: No support for ucs2 or utf16le encodings yet
ret = _utf8Slice(self, start, end)
break
case 'ascii':
ret = _asciiSlice(self, start, end)
break
case 'binary':
ret = _binarySlice(self, start, end)
break
case 'base64':
ret = _base64Slice(self, start, end)
break
case 'ucs2':
case 'ucs-2':
case 'utf16le':
case 'utf-16le':
return _utf8Slice(self, start, end)
case 'ascii':
return _asciiSlice(self, start, end)
case 'binary':
return _binarySlice(self, start, end)
case 'base64':
return _base64Slice(self, start, end)
ret = _utf16leSlice(self, start, end)
break
default:
throw new Error('Unknown encoding')
}
return ret
}

@@ -419,3 +442,11 @@

// http://nodejs.org/api/buffer.html#buffer_buf_slice_start_end
function _utf16leSlice (buf, start, end) {
var bytes = buf.slice(start, end)
var res = ''
for (var i = 0; i < bytes.length; i += 2) {
res += String.fromCharCode(bytes[i] + bytes[i+1] * 256)
}
return res
}
Buffer.prototype.slice = function (start, end) {

@@ -1011,2 +1042,16 @@ var len = this.length

function utf16leToBytes (str) {
var c, hi, lo
var byteArray = []
for (var i = 0; i < str.length; i++) {
c = str.charCodeAt(i)
hi = c >> 8
lo = c % 256
byteArray.push(lo)
byteArray.push(hi)
}
return byteArray
}
function base64ToBytes (str) {

@@ -1047,3 +1092,3 @@ return base64.toByteArray(str)

function verifsint(value, max, min) {
function verifsint (value, max, min) {
assert(typeof value == 'number', 'cannot write a non-number as a number')

@@ -1055,3 +1100,3 @@ assert(value <= max, 'value larger than maximum allowed value')

function verifIEEE754(value, max, min) {
function verifIEEE754 (value, max, min) {
assert(typeof value == 'number', 'cannot write a non-number as a number')

@@ -1058,0 +1103,0 @@ assert(value <= max, 'value larger than maximum allowed value')

@@ -245,2 +245,7 @@ var base64 = require('base64-js')

function _utf16leWrite (buf, string, offset, length) {
var bytes, pos
return Buffer._charsWritten = blitBuffer(utf16leToBytes(string), buf, offset, length)
}
Buffer.prototype.write = function (string, offset, length, encoding) {

@@ -273,21 +278,30 @@ // Support both (string, offset, length, encoding)

var ret
switch (encoding) {
case 'hex':
return _hexWrite(this, string, offset, length)
ret = _hexWrite(this, string, offset, length)
break
case 'utf8':
case 'utf-8':
case 'ucs2': // TODO: No support for ucs2 or utf16le encodings yet
ret = _utf8Write(this, string, offset, length)
break
case 'ascii':
ret = _asciiWrite(this, string, offset, length)
break
case 'binary':
ret = _binaryWrite(this, string, offset, length)
break
case 'base64':
ret = _base64Write(this, string, offset, length)
break
case 'ucs2':
case 'ucs-2':
case 'utf16le':
case 'utf-16le':
return _utf8Write(this, string, offset, length)
case 'ascii':
return _asciiWrite(this, string, offset, length)
case 'binary':
return _binaryWrite(this, string, offset, length)
case 'base64':
return _base64Write(this, string, offset, length)
ret = _utf16leWrite(this, string, offset, length)
break
default:
throw new Error('Unknown encoding')
}
return ret
}

@@ -308,21 +322,30 @@

var ret
switch (encoding) {
case 'hex':
return _hexSlice(self, start, end)
ret = _hexSlice(self, start, end)
break
case 'utf8':
case 'utf-8':
case 'ucs2': // TODO: No support for ucs2 or utf16le encodings yet
ret = _utf8Slice(self, start, end)
break
case 'ascii':
ret = _asciiSlice(self, start, end)
break
case 'binary':
ret = _binarySlice(self, start, end)
break
case 'base64':
ret = _base64Slice(self, start, end)
break
case 'ucs2':
case 'ucs-2':
case 'utf16le':
case 'utf-16le':
return _utf8Slice(self, start, end)
case 'ascii':
return _asciiSlice(self, start, end)
case 'binary':
return _binarySlice(self, start, end)
case 'base64':
return _base64Slice(self, start, end)
ret = _utf16leSlice(self, start, end)
break
default:
throw new Error('Unknown encoding')
}
return ret
}

@@ -418,3 +441,11 @@

// http://nodejs.org/api/buffer.html#buffer_buf_slice_start_end
function _utf16leSlice (buf, start, end) {
var bytes = buf.slice(start, end)
var res = ''
for (var i = 0; i < bytes.length; i += 2) {
res += String.fromCharCode(bytes[i] + bytes[i+1] * 256)
}
return res
}
Buffer.prototype.slice = function (start, end) {

@@ -1010,2 +1041,16 @@ var len = this.length

function utf16leToBytes (str) {
var c, hi, lo
var byteArray = []
for (var i = 0; i < str.length; i++) {
c = str.charCodeAt(i)
hi = c >> 8
lo = c % 256
byteArray.push(lo)
byteArray.push(hi)
}
return byteArray
}
function base64ToBytes (str) {

@@ -1046,3 +1091,3 @@ return base64.toByteArray(str)

function verifsint(value, max, min) {
function verifsint (value, max, min) {
assert(typeof value == 'number', 'cannot write a non-number as a number')

@@ -1054,3 +1099,3 @@ assert(value <= max, 'value larger than maximum allowed value')

function verifIEEE754(value, max, min) {
function verifIEEE754 (value, max, min) {
assert(typeof value == 'number', 'cannot write a non-number as a number')

@@ -1057,0 +1102,0 @@ assert(value <= max, 'value larger than maximum allowed value')

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

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

# native-buffer-browserify
[![Build Status](http://img.shields.io/travis/feross/native-buffer-browserify.svg)](https://travis-ci.org/feross/native-buffer-browserify)
[![NPM Version](http://img.shields.io/npm/v/native-buffer-browserify.svg)](https://npmjs.org/package/native-buffer-browserify)
[![NPM](http://img.shields.io/npm/dm/native-buffer-browserify.svg)](https://npmjs.org/package/native-buffer-browserify)
[![Gittip](http://img.shields.io/gittip/feross.svg)](https://www.gittip.com/feross/)
[![Build Status](http://img.shields.io/travis/feross/native-buffer-browserify.png)](https://travis-ci.org/feross/native-buffer-browserify)
[![NPM Version](http://img.shields.io/npm/v/native-buffer-browserify.png)](https://npmjs.org/package/native-buffer-browserify)
[![NPM](http://img.shields.io/npm/dm/native-buffer-browserify.png)](https://npmjs.org/package/native-buffer-browserify)
[![Gittip](http://img.shields.io/gittip/feross.png)](https://www.gittip.com/feross/)

@@ -7,0 +7,0 @@ The buffer module from [node.js](http://nodejs.org/), but for browsers. This is a fork of [buffer-browserify](https://github.com/toots/buffer-browserify).

@@ -28,2 +28,20 @@ var B = require('../index.js').Buffer

test('utf16le to utf16', function (t) {
t.plan(1);
t.equal(
new B(new B("abcd", "utf8").toString("utf16le"), "utf16le").toString("utf8"),
'abcd'
);
t.end();
});
test('utf16le to hex', function (t) {
t.plan(1);
t.equal(
new B("abcd", "utf16le").toString('hex'),
'6100620063006400'
);
t.end();
});
test('ascii buffer to base64', function (t) {

@@ -30,0 +48,0 @@ t.equal(

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