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.3 to 0.3.0

dist/binaryStream.d.ts

13

package.json
{
"name": "node-opcua-binary-stream",
"version": "0.2.3",
"version": "0.3.0",
"description": "pure nodejs OPCUA SDK - module -binary-stream",
"main": "src/binaryStream.js",
"main": "dist/binaryStream.js",
"types": "dist/binaryStream.d.ts",
"scripts": {
"build": "tsc",
"test": "mocha test"

@@ -11,7 +13,8 @@ },

"colors": "^1.2.1",
"node-opcua-assert": "^0.2.0",
"node-opcua-buffer-utils": "^0.2.0"
"node-opcua-assert": "^0.3.0",
"node-opcua-buffer-utils": "^0.3.0"
},
"devDependencies": {
"node-opcua-benchmarker": "^0.2.0",
"@types/underscore": "^1.8.8",
"node-opcua-benchmarker": "^0.3.0",
"should": "13.2.1"

@@ -18,0 +21,0 @@ },

"use strict";
var BinaryStream = require("..").BinaryStream; // node-opcua-binary-stream
var BinaryStreamSizeCalculator = require("..").BinaryStreamSizeCalculator;
var should = require("should");
var assert = require("node-opcua-assert");
const BinaryStream = require("..").BinaryStream; // node-opcua-binary-stream
const BinaryStreamSizeCalculator = require("..").BinaryStreamSizeCalculator;
const should = require("should");
const assert = require("node-opcua-assert").assert;
var Benchmarker = require("node-opcua-benchmarker").Benchmarker;
const Benchmarker = require("node-opcua-benchmarker").Benchmarker;

@@ -16,3 +16,3 @@ describe("Testing BinaryStream", function () {

var stream = new BinaryStream();
const stream = new BinaryStream();
stream.length.should.equal(0);

@@ -29,7 +29,7 @@

var f = stream.readDouble();
const f = stream.readDouble();
f.should.equal(10.00234);
stream.length.should.equal(8);
var i = stream.readInteger();
const i = stream.readInteger();
i.should.equal(100000);

@@ -43,6 +43,6 @@ stream.length.should.equal(12);

var stream = new BinaryStream(50);
const stream = new BinaryStream(50);
var arr = new Int16Array(25);
for (var i=0;i<25;i++) { arr[i] = 512+i; }
const arr = new Int16Array(25);
for (let i=0;i<25;i++) { arr[i] = 512+i; }

@@ -63,3 +63,3 @@ console.log((new Uint8Array(arr.buffer)).join(" "));

stream.rewind();
var arr2 = new Int16Array(stream.readArrayBuffer(50).buffer);
const arr2 = new Int16Array(stream.readArrayBuffer(50).buffer);
console.log((new Uint8Array(arr2.buffer)).join(" "));

@@ -88,3 +88,3 @@

var stream = new BinaryStreamSizeCalculator();
const stream = new BinaryStreamSizeCalculator();
stream.writeFloat(10.00234);

@@ -105,5 +105,5 @@ stream.writeInteger(100000);

//xx assert(arrayBuf instanceof ArrayBuffer);
var byteArr = new Uint8Array(arrayBuf);
var n = (length || byteArr.length) + offset;
for (var i = offset; i < n; i++) {
const byteArr = new Uint8Array(arrayBuf);
const n = (length || byteArr.length) + offset;
for (let i = offset; i < n; i++) {
this._buffer[this.length++] = byteArr[i];

@@ -116,5 +116,5 @@ }

assert(this.length + length <= this._buffer.length, "not enough bytes in buffer");
var slice = this._buffer.slice(this.length, this.length + length);
const slice = this._buffer.slice(this.length, this.length + length);
assert(slice.length === length);
var byteArr = new Uint8Array(slice);
const byteArr = new Uint8Array(slice);
assert(byteArr.length === length);

@@ -128,3 +128,3 @@ this.length += length;

// returns a new Buffer that shares the same allocated memory as the given ArrayBuffer.
var result = Buffer.from(this._buffer.buffer, this.length, length);
const result = Buffer.from(this._buffer.buffer, this.length, length);
this.length += length;

@@ -135,3 +135,3 @@ return Buffer.from(result);

BinaryStream.prototype.readArrayBuffer2 = function (length) {
var slice = this._buffer.slice(this.length, this.length + length);
const slice = this._buffer.slice(this.length, this.length + length);
this.length += length;

@@ -143,5 +143,5 @@ return Buffer.from(slice);

//xx assert(this.length + length <= this._buffer.length, "not enough bytes in buffer");
var slice = this._buffer.slice(this.length, this.length + length);
const slice = this._buffer.slice(this.length, this.length + length);
//xx assert(slice.length === length);
var byteArr = new Uint8Array(slice);
const byteArr = new Uint8Array(slice);
assert(byteArr.length === length);

@@ -158,7 +158,7 @@ this.length += length;

var n = 1024 * 1024 + 3;
var largeArray;
const n = 1024 * 1024 + 3;
let largeArray;
beforeEach(function () {
largeArray = new Float64Array(n);
for (var i = 0; i < n; i++) {
for (let i = 0; i < n; i++) {
largeArray[i] = (i * 0.14);

@@ -177,3 +177,3 @@ }

}
for (var i = 0; i < buf.length; i++) {
for (let i = 0; i < buf.length; i++) {
if (buf[i] !== i * 0.14) {

@@ -190,3 +190,3 @@ return false;

largeArray[100].should.eql(100 * 0.14);
var binStream = new BinaryStream(new Buffer(n * 8 + 20));
const binStream = new BinaryStream(new Buffer(n * 8 + 20));

@@ -200,5 +200,5 @@ largeArray.length.should.eql(n);

binStream.rewind();
var arr = binStream_readArrayBuffer.call(binStream, largeArray.byteLength);
const arr = binStream_readArrayBuffer.call(binStream, largeArray.byteLength);
arr.length.should.eql(largeArray.byteLength);
var reloaded = new Float64Array(arr.buffer);
const reloaded = new Float64Array(arr.buffer);

@@ -223,7 +223,7 @@ reloaded.length.should.eql(largeArray.length);

var binStream1 = new BinaryStream(new Buffer(n * 8 + 20));
var binStream2 = new BinaryStream(new Buffer(n * 8 + 20));
const binStream1 = new BinaryStream(new Buffer(n * 8 + 20));
const binStream2 = new BinaryStream(new Buffer(n * 8 + 20));
largeArray.byteLength.should.eql(n * 8);
var bench = new Benchmarker();
const bench = new Benchmarker();
bench

@@ -253,3 +253,3 @@ .add("writeArrayBuffer (old version with byte copy)", function () {

var binStream1 = new BinaryStream(new Buffer(n * 8 + 20));
const binStream1 = new BinaryStream(new Buffer(n * 8 + 20));
binStream1.writeArrayBuffer(largeArray.buffer, 0, largeArray.byteLength);

@@ -262,7 +262,7 @@

var bench = new Benchmarker();
const bench = new Benchmarker();
bench
.add("readArrayBuffer_old (old version with byte copy)", function () {
binStream1.rewind();
var arr = binStream1.readArrayBuffer_old(largeArray.byteLength);
const arr = binStream1.readArrayBuffer_old(largeArray.byteLength);
isValidBuffer(new Float64Array(arr.buffer), largeArray).should.eql(true);

@@ -272,3 +272,3 @@ })

binStream1.rewind();
var arr = binStream1.readArrayBuffer1(largeArray.byteLength);
const arr = binStream1.readArrayBuffer1(largeArray.byteLength);
isValidBuffer(new Float64Array(arr.buffer), largeArray).should.eql(true);

@@ -278,3 +278,3 @@ })

binStream1.rewind();
var arr = binStream1.readArrayBuffer2(largeArray.byteLength);
const arr = binStream1.readArrayBuffer2(largeArray.byteLength);
isValidBuffer(new Float64Array(arr.buffer), largeArray).should.eql(true);

@@ -284,3 +284,3 @@ })

binStream1.rewind();
var arr = binStream1.readArrayBuffer3(largeArray.byteLength);
const arr = binStream1.readArrayBuffer3(largeArray.byteLength);
isValidBuffer(new Float64Array(arr.buffer), largeArray).should.eql(true);

@@ -290,3 +290,3 @@ })

binStream1.rewind();
var arr = binStream1.readArrayBuffer(largeArray.byteLength);
const arr = binStream1.readArrayBuffer(largeArray.byteLength);
isValidBuffer(new Float64Array(arr.buffer), largeArray).should.eql(true);

@@ -311,6 +311,6 @@ })

var binStream1 = new BinaryStream(new Buffer(n * 8 + 20));
const binStream1 = new BinaryStream(new Buffer(n * 8 + 20));
binStream1.writeArrayBuffer(largeArray.buffer, 0, largeArray.byteLength);
var bench = new Benchmarker();
const bench = new Benchmarker();
bench

@@ -321,3 +321,3 @@ .add("writeArrayBuffer_old/readArrayBuffer_old (old version with byte copy)", function () {

binStream1.rewind();
var arr = binStream1.readArrayBuffer_old(largeArray.byteLength);
const arr = binStream1.readArrayBuffer_old(largeArray.byteLength);
isValidBuffer(new Float64Array(arr.buffer), largeArray).should.eql(true);

@@ -329,3 +329,3 @@ })

binStream1.rewind();
var arr = binStream1.readArrayBuffer(largeArray.byteLength);
const arr = binStream1.readArrayBuffer(largeArray.byteLength);

@@ -332,0 +332,0 @@ binStream1.length.should.eql(largeArray.byteLength);

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