Handle status better for Bigints

to close #1101
This commit is contained in:
Dave Conway-Jones
2025-08-04 17:04:36 +01:00
parent 06a9c48395
commit 5e829109ab
2 changed files with 15 additions and 4 deletions

View File

@@ -16,7 +16,12 @@ module.exports = function(RED) {
value = cbor.decode(value);
RED.util.setMessageProperty(msg,node.property,value);
node.send(msg);
node.status({text:l +" b->o "+ JSON.stringify(value).length});
if (typeof value === 'bigint') {
node.status({text:l +" b->o "+ value.toString().length});
}
else {
node.status({text:l +" b->o "+ JSON.stringify(value).length});
}
}
catch (e) {
node.error("Bad decode",msg);
@@ -24,7 +29,13 @@ module.exports = function(RED) {
}
}
else {
var le = JSON.stringify(value).length;
var le;
if (typeof value === 'bigint') {
le = value.toString().length;
}
else {
le = JSON.stringify(value).length;
}
value = cbor.encode(value);
RED.util.setMessageProperty(msg,node.property,value);
node.send(msg);

View File

@@ -1,9 +1,9 @@
{
"name" : "node-red-node-cbor",
"version" : "1.0.1",
"version" : "1.0.2",
"description" : "A Node-RED node to pack and unpack objects to cbor format",
"dependencies" : {
"cbor-x" : "^1.3.2"
"cbor-x" : "^1.6.0"
},
"bundledDependencies": [
"cbor-x"