node-opcua-basic-types
Advanced tools
Comparing version 2.113.0 to 2.114.0
@@ -66,2 +66,5 @@ import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream"; | ||
export declare function coerceInt32(value: null | Int64 | UInt64 | number | string): Int32; | ||
export declare function Int64ToBigInt(value: Int64): bigint; | ||
export declare function UInt64ToBigInt(value: UInt64): bigint; | ||
export declare function coerceInt64toInt32(value: Int64 | Int32): Int32; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.coerceUInt32 = exports.coerceInt16 = exports.coerceUInt16 = exports.coerceSByte = exports.coerceByte = exports.coerceUInt8 = exports.coerceInt8 = exports.decodeInt64 = exports.encodeInt64 = exports.isValidInt64 = exports.coerceInt64 = exports.randomInt64 = exports.coerceUInt64 = exports.constructInt64 = exports.decodeUInt64 = exports.encodeUInt64 = exports.randomUInt64 = exports.isValidUInt64 = exports.decodeByte = exports.encodeByte = exports.randomByte = exports.isValidByte = exports.decodeUInt8 = exports.encodeUInt8 = exports.randomUInt8 = exports.isValidUInt8 = exports.decodeSByte = exports.encodeSByte = exports.randomSByte = exports.isValidSByte = exports.decodeInt8 = exports.encodeInt8 = exports.randomInt8 = exports.isValidInt8 = exports.decodeUInt32 = exports.encodeUInt32 = exports.randomUInt32 = exports.isValidUInt32 = exports.decodeInt32 = exports.encodeInt32 = exports.randomInt32 = exports.isValidInt32 = exports.decodeInt16 = exports.encodeInt16 = exports.randomInt16 = exports.isValidInt16 = exports.decodeUInt16 = exports.encodeUInt16 = exports.randomUInt16 = exports.isValidUInt16 = void 0; | ||
exports.coerceInt32 = void 0; | ||
exports.coerceInt64toInt32 = exports.UInt64ToBigInt = exports.Int64ToBigInt = exports.coerceInt32 = void 0; | ||
/*** | ||
@@ -301,3 +301,3 @@ * @module node-opcua-basic-types | ||
// Int64 as a [high,low] | ||
return value[1] + value[0] * 0xffffffff; | ||
return value[1] + value[0] * 0x1000000; | ||
} | ||
@@ -310,2 +310,32 @@ if (typeof value === "number") { | ||
exports.coerceInt32 = coerceInt32; | ||
const signMask = 1n << 31n; | ||
const shiftHigh = 1n << 32n; | ||
function Int64ToBigInt(value) { | ||
const h = BigInt(value[0]); | ||
const l = BigInt(value[1]); | ||
if ((h & signMask) === signMask) { | ||
const v = (h & ~signMask) * shiftHigh + l - 0x8000000000000000n; | ||
return v; | ||
} | ||
else { | ||
const v = h * shiftHigh + l; | ||
return v; | ||
} | ||
} | ||
exports.Int64ToBigInt = Int64ToBigInt; | ||
function UInt64ToBigInt(value) { | ||
const h = BigInt(value[0]); | ||
const l = BigInt(value[1]); | ||
const v = h * shiftHigh + l; | ||
return v; | ||
} | ||
exports.UInt64ToBigInt = UInt64ToBigInt; | ||
function coerceInt64toInt32(value) { | ||
if (value instanceof Array) { | ||
const b = Int64ToBigInt(value); | ||
return Number(b); | ||
} | ||
return value; | ||
} | ||
exports.coerceInt64toInt32 = coerceInt64toInt32; | ||
//# sourceMappingURL=integers.js.map |
{ | ||
"name": "node-opcua-basic-types", | ||
"version": "2.113.0", | ||
"version": "2.114.0", | ||
"description": "pure nodejs OPCUA SDK - module basic-types", | ||
@@ -15,13 +15,13 @@ "main": "./dist/index.js", | ||
"node-opcua-assert": "2.105.0", | ||
"node-opcua-binary-stream": "2.110.0", | ||
"node-opcua-buffer-utils": "2.110.0", | ||
"node-opcua-date-time": "2.113.0", | ||
"node-opcua-binary-stream": "2.114.0", | ||
"node-opcua-buffer-utils": "2.114.0", | ||
"node-opcua-date-time": "2.114.0", | ||
"node-opcua-guid": "2.98.1", | ||
"node-opcua-nodeid": "2.113.0", | ||
"node-opcua-status-code": "2.110.0" | ||
"node-opcua-nodeid": "2.114.0", | ||
"node-opcua-status-code": "2.114.0" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "20.5.9", | ||
"node-opcua-benchmarker": "2.110.0", | ||
"node-opcua-debug": "2.113.0", | ||
"@types/node": "20.8.0", | ||
"node-opcua-benchmarker": "2.114.0", | ||
"node-opcua-debug": "2.114.0", | ||
"should": "^13.2.3" | ||
@@ -44,3 +44,3 @@ }, | ||
"homepage": "http://node-opcua.github.io/", | ||
"gitHead": "36db335391fedd39726990a1b37f7768da16466a", | ||
"gitHead": "358d284a696c88e383eedac1ab75d950fb28ec35", | ||
"files": [ | ||
@@ -47,0 +47,0 @@ "dist", |
@@ -185,3 +185,4 @@ /*** | ||
export function coerceUInt64(value: number | UInt64 | Int32 | string | null): UInt64 { | ||
export function | ||
coerceUInt64(value: number | UInt64 | Int32 | string | null): UInt64 { | ||
let high; | ||
@@ -318,3 +319,3 @@ let low; | ||
// Int64 as a [high,low] | ||
return value[1] + value[0] * 0xffffffff; | ||
return value[1] + value[0] * 0x1000000; | ||
} | ||
@@ -326,1 +327,29 @@ if (typeof value === "number") { | ||
} | ||
const signMask = 1n << 31n; | ||
const shiftHigh = 1n << 32n; | ||
export function Int64ToBigInt(value: Int64): bigint { | ||
const h = BigInt(value[0]); | ||
const l = BigInt(value[1]); | ||
if ((h & signMask) === signMask) { | ||
const v = (h & ~signMask) * shiftHigh + l - 0x8000000000000000n; | ||
return v; | ||
} else { | ||
const v = h * shiftHigh + l; | ||
return v; | ||
} | ||
} | ||
export function UInt64ToBigInt(value: UInt64): bigint { | ||
const h = BigInt(value[0]); | ||
const l = BigInt(value[1]); | ||
const v = h * shiftHigh + l; | ||
return v; | ||
} | ||
export function coerceInt64toInt32(value: Int64 | Int32): Int32 { | ||
if (value instanceof Array) { | ||
const b = Int64ToBigInt(value); | ||
return Number(b); | ||
} | ||
return value; | ||
} |
Sorry, the diff of this file is not supported yet
121015
2365
+ Addednode-opcua-binary-stream@2.114.0(transitive)
+ Addednode-opcua-buffer-utils@2.114.0(transitive)
+ Addednode-opcua-constants@2.114.0(transitive)
+ Addednode-opcua-date-time@2.114.0(transitive)
+ Addednode-opcua-nodeid@2.114.0(transitive)
+ Addednode-opcua-status-code@2.114.0(transitive)
+ Addednode-opcua-utils@2.114.0(transitive)
- Removednode-opcua-binary-stream@2.110.0(transitive)
- Removednode-opcua-buffer-utils@2.110.0(transitive)
- Removednode-opcua-constants@2.98.1(transitive)
- Removednode-opcua-date-time@2.113.0(transitive)
- Removednode-opcua-nodeid@2.113.0(transitive)
- Removednode-opcua-status-code@2.110.0(transitive)
- Removednode-opcua-utils@2.110.0(transitive)
Updatednode-opcua-date-time@2.114.0
Updatednode-opcua-nodeid@2.114.0