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

pbf

Package Overview
Dependencies
Maintainers
20
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pbf - npm Package Compare versions

Comparing version 1.1.2 to 1.1.3

61

buffer.js

@@ -11,39 +11,39 @@ 'use strict';

function Buffer(length) {
this.arr = new Uint8Array(length);
this.length = length;
var buf = new Uint8Array(length);
for (var i in BufferMethods) {
buf[i] = BufferMethods[i];
}
return buf;
}
Buffer.prototype = {
var BufferMethods = {
readUInt32LE: function(pos) {
var arr = this.arr;
return ((arr[pos]) |
(arr[pos + 1] << 8) |
(arr[pos + 2] << 16)) +
(arr[pos + 3] * 0x1000000);
return ((this[pos]) |
(this[pos + 1] << 8) |
(this[pos + 2] << 16)) +
(this[pos + 3] * 0x1000000);
},
writeUInt32LE: function(val, pos) {
var arr = this.arr;
arr[pos] = val;
arr[pos + 1] = (val >>> 8);
arr[pos + 2] = (val >>> 16);
arr[pos + 3] = (val >>> 24);
this[pos] = val;
this[pos + 1] = (val >>> 8);
this[pos + 2] = (val >>> 16);
this[pos + 3] = (val >>> 24);
},
readInt32LE: function(pos) {
var arr = this.arr;
return ((arr[pos]) |
(arr[pos + 1] << 8) |
(arr[pos + 2] << 16)) +
(arr[pos + 3] << 24);
return ((this[pos]) |
(this[pos + 1] << 8) |
(this[pos + 2] << 16)) +
(this[pos + 3] << 24);
},
readFloatLE: function(pos) { return ieee754.read(this.arr, pos, true, 23, 4); },
readDoubleLE: function(pos) { return ieee754.read(this.arr, pos, true, 52, 8); },
readFloatLE: function(pos) { return ieee754.read(this, pos, true, 23, 4); },
readDoubleLE: function(pos) { return ieee754.read(this, pos, true, 52, 8); },
writeFloatLE: function(val, pos) { return ieee754.write(this.arr, val, pos, true, 23, 4); },
writeDoubleLE: function(val, pos) { return ieee754.write(this.arr, val, pos, true, 52, 8); },
writeFloatLE: function(val, pos) { return ieee754.write(this, val, pos, true, 23, 4); },
writeDoubleLE: function(val, pos) { return ieee754.write(this, val, pos, true, 52, 8); },
toString: function(encoding, start, end) {
if (typeof TextDecoder !== 'undefined') return new TextDecoder('utf8').decode(this.arr.subarray(start, end));
if (typeof TextDecoder !== 'undefined') return new TextDecoder('utf8').decode(this.subarray(start, end));

@@ -57,3 +57,3 @@ var str = '',

for (var i = start; i < end; i++) {
var ch = this.arr[i];
var ch = this[i];
if (ch <= 0x7F) {

@@ -73,3 +73,3 @@ str += decodeUtf8Str(tmp) + String.fromCharCode(ch)

for (var i = 0; i < bytes.length; i++) {
this.arr[pos + i] = bytes[i];
this[pos + i] = bytes[i];
}

@@ -79,3 +79,3 @@ },

slice: function(start, end) {
return this.arr.subarray(start, end);
return this.subarray(start, end);
},

@@ -86,3 +86,3 @@

for (var i = 0; i < this.length; i++) {
buf.arr[pos + i] = this.arr[i];
buf[pos + i] = this[i];
}

@@ -92,8 +92,7 @@ }

Buffer.prototype.writeInt32LE = Buffer.prototype.writeUInt32LE;
BufferMethods.writeInt32LE = BufferMethods.writeUInt32LE;
Buffer.wrap = function(arr) {
var buf = Object.create(Buffer.prototype);
buf.arr = arr;
buf.length = arr.length;
var buf = Buffer(arr.length);
buf.set(arr);
return buf;

@@ -100,0 +99,0 @@ };

@@ -5,8 +5,7 @@ 'use strict';

var isBrowser = typeof window !== 'undefined',
Buffer = isBrowser ? require('./buffer') : global.Buffer;
var Buffer = global.Buffer || require('./buffer');
function Protobuf(buf) {
this.buf = !buf ? new Buffer(0) :
isBrowser ? Buffer.wrap(buf) :
!global.Buffer ? Buffer.wrap(buf) :
buf instanceof Uint8Array ? new Buffer(buf) : buf;

@@ -13,0 +12,0 @@

{
"name": "pbf",
"version": "1.1.2",
"version": "1.1.3",
"description": "a low-level, lightweight protocol buffers implementation in JavaScript",

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

@@ -185,3 +185,3 @@ # pbf

#### 1.1.2 (Dec 26 2014)
#### 1.1.3 (Dec 26 2014)

@@ -188,0 +188,0 @@ Brings tons of improvements and fixes over the previous version (`0.0.2`).

@@ -17,3 +17,3 @@ var BufferShim = require('../buffer'),

t.same(toArray(shim.arr), [18,49,0,0,43,2,0,0]);
t.same(toArray(shim), [18,49,0,0,43,2,0,0]);
t.end();

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

t.same(toArray(shim.arr), [121,233,246,66]);
t.same(toArray(shim), [121,233,246,66]);
t.end();

@@ -61,3 +61,3 @@ });

t.same(toArray(shim.arr), [153,76,251,7,60,221,94,64]);
t.same(toArray(shim), [153,76,251,7,60,221,94,64]);
t.end();

@@ -81,3 +81,3 @@ });

t.same(toArray(shim.arr), testBytes);
t.same(toArray(shim), testBytes);
t.end();

@@ -125,3 +125,3 @@ });

t.same(toArray(shim.arr), toArray(shim2.arr));
t.same(toArray(shim), toArray(shim2));
t.end();

@@ -128,0 +128,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