I'm struggling to convert a Counter64 value issued from an SNMP node into an appropriately sized integer. My understanding is that BigInt is now officially part of node.js. So I assumed it would also be available to Node-RED and I've tried the following in a function node:
msg.payload = BigInt(msg.payload, 16); #I've also tried using a base of 256 with the same result return msg;
This will generate an "SyntaxError: Cannot convert #⏆ to a BigInt"
If I do this:
msg.payload = BigInt.fromArray(msg.payload, 16); return msg;
I then get "TypeError: BigInt.fromArray is not a function"
So it appears that even though BigInt is defined it is not implemented as expected.
So I've tried "npm install big-integer" under the ~/.node-red directory, modifying settings.js and adding bigInt:require("big-integer") under functionGlobalContext and modifying my function node as so:
var bigInt=global.get('bigint'); msg.payload = bigInt.fromArray(msg.payload, 16); return msg;
Which now gives me this: "TypeError: digits[i].times is not a function"
Or if try this way:
var bigInt=global.get('bigint'); msg.payload = bigInt(msg.payload, 16); return msg;
I get: "Error: # is not a valid character"
So there's progress I guess but still no success...
Any help will be much appreciated!