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

node-opcua-binary-stream

Package Overview
Dependencies
Maintainers
1
Versions
110
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-opcua-binary-stream - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

2

package.json
{
"name": "node-opcua-binary-stream",
"version": "0.2.0",
"version": "0.2.1",
"description": "pure nodejs OPCUA SDK - module -binary-stream",

@@ -5,0 +5,0 @@ "main": "src/binaryStream.js",

@@ -154,12 +154,35 @@ "use strict";

var my_memcpy = function my_memcpy(target, targetStart, source, sourceStart, sourceEnd) {
assert(target instanceof Buffer || target instanceof Uint8Array);
assert(source instanceof Buffer || source instanceof Uint8Array);
var l = targetStart;
for (var i = sourceStart; i < sourceEnd; i++) {
target[l++] = source[i];
/**
* @method writeArrayBuffer
* @param arrayBuf {ArrayBuffer}
* @param offset {Number}
* @param length {Number}
*/
BinaryStream.prototype.writeArrayBuffer = function (arrayBuf, offset, length) {
offset = offset || 0;
assert(arrayBuf instanceof ArrayBuffer);
var byteArr = new Uint8Array(arrayBuf);
var n = (length || byteArr.length) + offset;
for (var i = offset; i < n; i++) {
this._buffer[this.length++] = byteArr[i];
}
return sourceEnd - sourceStart;
};
/**
* @method readArrayBuffer
* @param length
* @returns {Uint8Array}
*/
BinaryStream.prototype.readArrayBuffer = function (length) {
assert(this.length + length <= this._buffer.length, "not enough bytes in buffer");
var slice = this._buffer.slice(this.length, this.length + length);
assert(slice.length === length);
var byteArr = new Uint8Array(slice);
assert(byteArr.length === length);
this.length += length;
return byteArr;
}
var displayWarnings = false;

@@ -180,5 +203,37 @@ require("colors");

try {
var my_memcpy = function my_memcpy(target, targetStart, source, sourceStart, sourceEnd) {
//xx assert(target instanceof Buffer || target instanceof Uint8Array);
//xx assert(source instanceof Buffer || source instanceof Uint8Array);
var l = targetStart;
for (var i = sourceStart; i < sourceEnd; i++) {
target[l++] = source[i];
}
return sourceEnd - sourceStart;
};
var memcpy = require("memcpy"); // C++ binding if available, else native JS
my_memcpy = memcpy;
console.log("Warning : using memcpy : OK".yellow);
BinaryStream.prototype.writeArrayBuffer = function (arrayBuf, offset, length) {
offset = offset || 0;
assert(arrayBuf instanceof ArrayBuffer);
var byteArr = new Uint8Array(arrayBuf);
length = length || byteArr.length;
if (length === 0) {
return;
}
this.length += my_memcpy(this._buffer, this.length, byteArr, offset, offset + length);
};
BinaryStream.prototype.readArrayBuffer = function (length) {
assert(this.length + length <= this._buffer.length, "not enough bytes in buffer");
var byteArr = new Uint8Array(new ArrayBuffer(length));
my_memcpy(byteArr, 0, this._buffer, this.length, this.length + length);
this.length += length;
return byteArr;
};
}

@@ -189,22 +244,2 @@ catch (err) {

BinaryStream.prototype.writeArrayBuffer = function (arrayBuf, offset, length) {
offset = offset || 0;
assert(arrayBuf instanceof ArrayBuffer);
var byteArr = new Uint8Array(arrayBuf);
length = length || byteArr.length;
if (length === 0) {
return;
}
this.length += my_memcpy(this._buffer, this.length, byteArr, offset, offset + length);
};
BinaryStream.prototype.readArrayBuffer = function (length) {
assert(this.length + length <= this._buffer.length, "not enough bytes in buffer");
var byteArr = new Uint8Array(new ArrayBuffer(length));
my_memcpy(byteArr, 0, this._buffer, this.length, this.length + length);
this.length += length;
return byteArr;
};
/**

@@ -430,3 +465,3 @@ * read a single signed byte (8 bits) from the stream.

assert(arrayBuf instanceof ArrayBuffer);
this.length += (byteLength || new Uint8Array(arrayBuf).length);
this.length += (byteLength || arrayBuf.byteLength);
};

@@ -440,3 +475,2 @@

this.length += buf.length;
}

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