node-opcua-binary-stream
Advanced tools
Comparing version 2.16.0 to 2.17.0
/// <reference types="node" /> | ||
/** | ||
* @module node-opcua-binary-stream | ||
*/ | ||
import "util"; | ||
@@ -3,0 +6,0 @@ /** |
@@ -7,3 +7,2 @@ "use strict"; | ||
*/ | ||
const underscore_1 = require("underscore"); | ||
require("util"); | ||
@@ -136,3 +135,3 @@ const node_opcua_assert_1 = require("node-opcua-assert"); | ||
if (performCheck) { | ||
node_opcua_assert_1.assert(underscore_1.isFinite(value)); | ||
node_opcua_assert_1.assert(isFinite(value)); | ||
} | ||
@@ -139,0 +138,0 @@ if (performCheck) { |
@@ -10,3 +10,3 @@ "use strict"; | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
@@ -13,0 +13,0 @@ Object.defineProperty(exports, "__esModule", { value: true }); |
{ | ||
"name": "node-opcua-binary-stream", | ||
"version": "2.16.0", | ||
"version": "2.17.0", | ||
"description": "pure nodejs OPCUA SDK - module -binary-stream", | ||
@@ -16,8 +16,6 @@ "main": "./dist/index.js", | ||
"node-opcua-assert": "2.16.0", | ||
"node-opcua-buffer-utils": "2.16.0", | ||
"underscore": "^1.10.2" | ||
"node-opcua-buffer-utils": "2.17.0" | ||
}, | ||
"devDependencies": { | ||
"@types/underscore": "^1.10.20", | ||
"node-opcua-benchmarker": "2.16.0", | ||
"node-opcua-benchmarker": "2.17.0", | ||
"should": "^13.2.3" | ||
@@ -40,3 +38,3 @@ }, | ||
"homepage": "http://node-opcua.github.io/", | ||
"gitHead": "9fa7d50952a7c39ff6790888a2bd6f32fe46836d" | ||
"gitHead": "545072c8184378254468c383b78e74e7e8e31ab7" | ||
} |
/** | ||
* @module node-opcua-binary-stream | ||
*/ | ||
import { isFinite } from "underscore"; | ||
import "util"; | ||
@@ -43,3 +42,2 @@ | ||
export class BinaryStream { | ||
/** | ||
@@ -81,4 +79,8 @@ * the current position inside the buffer | ||
public writeInt8(value: number): void { | ||
if (performCheck) { assert(this.buffer.length >= this.length + 1, "not enough space in buffer"); } | ||
if (performCheck) { assert(value >= -128 && value < 128); } | ||
if (performCheck) { | ||
assert(this.buffer.length >= this.length + 1, "not enough space in buffer"); | ||
} | ||
if (performCheck) { | ||
assert(value >= -128 && value < 128); | ||
} | ||
this.buffer.writeInt8(value, this.length); | ||
@@ -93,4 +95,8 @@ this.length += 1; | ||
public writeUInt8(value: number): void { | ||
if (performCheck) { assert(this.buffer.length >= this.length + 1, "not enough space in buffer"); } | ||
if (performCheck) { assert(value >= 0 && value < 256, " writeUInt8 : out of bound "); } | ||
if (performCheck) { | ||
assert(this.buffer.length >= this.length + 1, "not enough space in buffer"); | ||
} | ||
if (performCheck) { | ||
assert(value >= 0 && value < 256, " writeUInt8 : out of bound "); | ||
} | ||
this.buffer.writeUInt8(value, this.length); | ||
@@ -105,3 +111,5 @@ this.length += 1; | ||
public writeInt16(value: number): void { | ||
if (performCheck) { assert(this.buffer.length >= this.length + 2, "not enough space in buffer"); } | ||
if (performCheck) { | ||
assert(this.buffer.length >= this.length + 2, "not enough space in buffer"); | ||
} | ||
this.buffer.writeInt16LE(value, this.length); | ||
@@ -116,3 +124,5 @@ this.length += 2; | ||
public writeUInt16(value: number): void { | ||
if (performCheck) { assert(this.buffer.length >= this.length + 2, "not enough space in buffer"); } | ||
if (performCheck) { | ||
assert(this.buffer.length >= this.length + 2, "not enough space in buffer"); | ||
} | ||
this.buffer.writeUInt16LE(value, this.length); | ||
@@ -127,3 +137,5 @@ this.length += 2; | ||
public writeInteger(value: number): void { | ||
if (performCheck) { assert(this.buffer.length >= this.length + 4, "not enough space in buffer"); } | ||
if (performCheck) { | ||
assert(this.buffer.length >= this.length + 4, "not enough space in buffer"); | ||
} | ||
this.buffer.writeInt32LE(value, this.length); | ||
@@ -139,5 +151,11 @@ this.length += 4; | ||
public writeUInt32(value: number): void { | ||
if (performCheck) {assert(this.buffer.length >= this.length + 4, "not enough space in buffer"); } | ||
if (performCheck) {assert(isFinite(value)); } | ||
if (performCheck) {assert(value >= 0 && value <= MAXUINT32); } | ||
if (performCheck) { | ||
assert(this.buffer.length >= this.length + 4, "not enough space in buffer"); | ||
} | ||
if (performCheck) { | ||
assert(isFinite(value)); | ||
} | ||
if (performCheck) { | ||
assert(value >= 0 && value <= MAXUINT32); | ||
} | ||
this.buffer.writeUInt32LE(value, this.length); | ||
@@ -158,3 +176,5 @@ this.length += 4; | ||
public writeFloat(value: number): void { | ||
if (performCheck) { assert(this.buffer.length >= this.length + 4, "not enough space in buffer"); } | ||
if (performCheck) { | ||
assert(this.buffer.length >= this.length + 4, "not enough space in buffer"); | ||
} | ||
this.buffer.writeFloatLE(value, this.length); | ||
@@ -169,3 +189,5 @@ this.length += 4; | ||
public writeDouble(value: number): void { | ||
if (performCheck) { assert(this.buffer.length >= this.length + 8, "not enough space in buffer"); } | ||
if (performCheck) { | ||
assert(this.buffer.length >= this.length + 8, "not enough space in buffer"); | ||
} | ||
this.buffer.writeDoubleLE(value, this.length); | ||
@@ -181,3 +203,5 @@ this.length += 8; | ||
public writeArrayBuffer(arrayBuf: ArrayBuffer, offset = 0, length = 0): void { | ||
if (performCheck) { assert(arrayBuf instanceof ArrayBuffer); } | ||
if (performCheck) { | ||
assert(arrayBuf instanceof ArrayBuffer); | ||
} | ||
const byteArr = new Uint8Array(arrayBuf); | ||
@@ -220,3 +244,5 @@ const n = (length || byteArr.length) + offset; | ||
public readUInt8(): number { | ||
if (performCheck) { assert(this.buffer.length >= this.length + 1); } | ||
if (performCheck) { | ||
assert(this.buffer.length >= this.length + 1); | ||
} | ||
const retVal = this.buffer.readUInt8(this.length); | ||
@@ -301,6 +327,6 @@ this.length += 1; | ||
"BinaryStream.writeByteStream error : not enough bytes left in buffer : bufferLength is " + | ||
buf.length + | ||
" but only " + | ||
remainingBytes + | ||
" left", | ||
buf.length + | ||
" but only " + | ||
remainingBytes + | ||
" left" | ||
); | ||
@@ -312,3 +338,3 @@ } | ||
public writeString(value: null|string): void { | ||
public writeString(value: null | string): void { | ||
if (value === undefined || value === null) { | ||
@@ -326,6 +352,6 @@ this.writeInteger(-1); | ||
"BinaryStream.writeByteStream error : not enough bytes left in buffer : bufferLength is " + | ||
byteLength + | ||
" but only " + | ||
remainingBytes + | ||
" left", | ||
byteLength + | ||
" but only " + | ||
remainingBytes + | ||
" left" | ||
); | ||
@@ -351,7 +377,13 @@ } | ||
public readArrayBuffer(length: number): Uint8Array { | ||
if (performCheck) { assert(this.length + length <= this.buffer.length, "not enough bytes in buffer"); } | ||
if (performCheck) { | ||
assert(this.length + length <= this.buffer.length, "not enough bytes in buffer"); | ||
} | ||
const slice = this.buffer.slice(this.length, this.length + length); | ||
if (performCheck) { assert(slice.length === length); } | ||
if (performCheck) { | ||
assert(slice.length === length); | ||
} | ||
const byteArr = new Uint8Array(slice); | ||
if (performCheck) { assert(byteArr.length === length); } | ||
if (performCheck) { | ||
assert(byteArr.length === length); | ||
} | ||
this.length += length; | ||
@@ -380,6 +412,6 @@ return byteArr; | ||
"BinaryStream.readByteStream error : not enough bytes left in buffer : bufferLength is " + | ||
bufLen + | ||
" but only " + | ||
remainingBytes + | ||
" left", | ||
bufLen + | ||
" but only " + | ||
remainingBytes + | ||
" left" | ||
); | ||
@@ -406,6 +438,6 @@ } | ||
"BinaryStream.readByteStream error : not enough bytes left in buffer : bufferLength is " + | ||
bufLen + | ||
" but only " + | ||
remainingBytes + | ||
" left", | ||
bufLen + | ||
" but only " + | ||
remainingBytes + | ||
" left" | ||
); | ||
@@ -412,0 +444,0 @@ } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
52781
3
2
1208
+ Addednode-opcua-buffer-utils@2.17.0(transitive)
- Removedunderscore@^1.10.2
- Removednode-opcua-buffer-utils@2.16.0(transitive)
- Removedunderscore@1.13.7(transitive)