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

@bfchain/bnrtc2-buffer

Package Overview
Dependencies
Maintainers
6
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bfchain/bnrtc2-buffer - npm Package Compare versions

Comparing version 0.0.1-alpha.11 to 0.0.1-alpha.12

2

cjs/buffer.d.ts

@@ -13,3 +13,3 @@ import "@bfchain/bnrtc2-buffer-typings";

private constructor();
private reallocBuffer;
private extendBuffer;
private checkSpace;

@@ -16,0 +16,0 @@ get length(): number;

@@ -51,14 +51,27 @@ "use strict";

}
reallocBuffer(size) {
extendBuffer(size, direction) {
const oldData = this.data();
const len = nextpow2(size + Bnrtc2Buffer.HEAD_RESERVE_SIZE);
const oldDataLen = this.length;
const len = nextpow2(oldDataLen + size + Bnrtc2Buffer.HEAD_RESERVE_SIZE);
this._buf = new Uint8Array(len);
this._dataOffset = Bnrtc2Buffer.HEAD_RESERVE_SIZE;
this._buf.set(oldData, this._dataOffset);
this._endOffset = Bnrtc2Buffer.HEAD_RESERVE_SIZE + oldData.length;
if (direction == WriteDirection.PUSH) {
this._dataOffset = Bnrtc2Buffer.HEAD_RESERVE_SIZE;
this._buf.set(oldData, this._dataOffset);
this._endOffset = Bnrtc2Buffer.HEAD_RESERVE_SIZE + oldDataLen;
}
else {
this._dataOffset = Bnrtc2Buffer.HEAD_RESERVE_SIZE + size;
this._buf.set(oldData, this._dataOffset);
this._endOffset = Bnrtc2Buffer.HEAD_RESERVE_SIZE + size + oldDataLen;
}
}
checkSpace(len, direction) {
if (direction == WriteDirection.PUT) {
if (this._isClone) {
this.extendBuffer(len, direction);
;
}
else if (direction == WriteDirection.PUT) {
if (len > this._dataOffset || (this._hasCloned && this._isPulled)) {
this.reallocBuffer(this.length + len);
this.extendBuffer(len, direction);
;
}

@@ -68,9 +81,6 @@ }

if (this._endOffset + len > this._buf.length) {
this.reallocBuffer(this.length + len);
this.extendBuffer(len, direction);
;
}
}
else if (this._isClone) {
this.reallocBuffer(this.length + len);
;
}
return this;

@@ -77,0 +87,0 @@ }

@@ -13,3 +13,3 @@ import "@bfchain/bnrtc2-buffer-typings";

private constructor();
private reallocBuffer;
private extendBuffer;
private checkSpace;

@@ -16,0 +16,0 @@ get length(): number;

@@ -50,14 +50,27 @@ import "@bfchain/bnrtc2-buffer-typings";

};
Bnrtc2Buffer.prototype.reallocBuffer = function (size) {
Bnrtc2Buffer.prototype.extendBuffer = function (size, direction) {
var oldData = this.data();
var len = nextpow2(size + Bnrtc2Buffer.HEAD_RESERVE_SIZE);
var oldDataLen = this.length;
var len = nextpow2(oldDataLen + size + Bnrtc2Buffer.HEAD_RESERVE_SIZE);
this._buf = new Uint8Array(len);
this._dataOffset = Bnrtc2Buffer.HEAD_RESERVE_SIZE;
this._buf.set(oldData, this._dataOffset);
this._endOffset = Bnrtc2Buffer.HEAD_RESERVE_SIZE + oldData.length;
if (direction == WriteDirection.PUSH) {
this._dataOffset = Bnrtc2Buffer.HEAD_RESERVE_SIZE;
this._buf.set(oldData, this._dataOffset);
this._endOffset = Bnrtc2Buffer.HEAD_RESERVE_SIZE + oldDataLen;
}
else {
this._dataOffset = Bnrtc2Buffer.HEAD_RESERVE_SIZE + size;
this._buf.set(oldData, this._dataOffset);
this._endOffset = Bnrtc2Buffer.HEAD_RESERVE_SIZE + size + oldDataLen;
}
};
Bnrtc2Buffer.prototype.checkSpace = function (len, direction) {
if (direction == WriteDirection.PUT) {
if (this._isClone) {
this.extendBuffer(len, direction);
;
}
else if (direction == WriteDirection.PUT) {
if (len > this._dataOffset || (this._hasCloned && this._isPulled)) {
this.reallocBuffer(this.length + len);
this.extendBuffer(len, direction);
;
}

@@ -67,9 +80,6 @@ }

if (this._endOffset + len > this._buf.length) {
this.reallocBuffer(this.length + len);
this.extendBuffer(len, direction);
;
}
}
else if (this._isClone) {
this.reallocBuffer(this.length + len);
;
}
return this;

@@ -76,0 +86,0 @@ };

@@ -13,3 +13,3 @@ import "@bfchain/bnrtc2-buffer-typings";

private constructor();
private reallocBuffer;
private extendBuffer;
private checkSpace;

@@ -16,0 +16,0 @@ get length(): number;

@@ -48,14 +48,27 @@ import "@bfchain/bnrtc2-buffer-typings";

}
reallocBuffer(size) {
extendBuffer(size, direction) {
const oldData = this.data();
const len = nextpow2(size + Bnrtc2Buffer.HEAD_RESERVE_SIZE);
const oldDataLen = this.length;
const len = nextpow2(oldDataLen + size + Bnrtc2Buffer.HEAD_RESERVE_SIZE);
this._buf = new Uint8Array(len);
this._dataOffset = Bnrtc2Buffer.HEAD_RESERVE_SIZE;
this._buf.set(oldData, this._dataOffset);
this._endOffset = Bnrtc2Buffer.HEAD_RESERVE_SIZE + oldData.length;
if (direction == WriteDirection.PUSH) {
this._dataOffset = Bnrtc2Buffer.HEAD_RESERVE_SIZE;
this._buf.set(oldData, this._dataOffset);
this._endOffset = Bnrtc2Buffer.HEAD_RESERVE_SIZE + oldDataLen;
}
else {
this._dataOffset = Bnrtc2Buffer.HEAD_RESERVE_SIZE + size;
this._buf.set(oldData, this._dataOffset);
this._endOffset = Bnrtc2Buffer.HEAD_RESERVE_SIZE + size + oldDataLen;
}
}
checkSpace(len, direction) {
if (direction == WriteDirection.PUT) {
if (this._isClone) {
this.extendBuffer(len, direction);
;
}
else if (direction == WriteDirection.PUT) {
if (len > this._dataOffset || (this._hasCloned && this._isPulled)) {
this.reallocBuffer(this.length + len);
this.extendBuffer(len, direction);
;
}

@@ -65,9 +78,6 @@ }

if (this._endOffset + len > this._buf.length) {
this.reallocBuffer(this.length + len);
this.extendBuffer(len, direction);
;
}
}
else if (this._isClone) {
this.reallocBuffer(this.length + len);
;
}
return this;

@@ -74,0 +84,0 @@ }

{
"name": "@bfchain/bnrtc2-buffer",
"version": "0.0.1-alpha.11",
"version": "0.0.1-alpha.12",
"main": "cjs/index.js",

@@ -9,5 +9,5 @@ "type": "cjs/index.d.ts",

"dependencies": {
"@bfchain/bnrtc2-buffer-typings": "^0.0.1-alpha.11",
"@bfchain/bnrtc2-buffer-typings": "^0.0.1-alpha.12",
"@bfchain/util-encoding-utf8": "^0.0.1-alpha.4"
}
}

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