New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

node-red-contrib-buffer-parser

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-red-contrib-buffer-parser - npm Package Compare versions

Comparing version 2.4.0 to 2.5.0

images/example3.png

62

buffer-parser.js

@@ -30,3 +30,3 @@

"bcd", "bcdle", "bcdbe",
"string", "ascii", "utf8", "utf16le", "ucs2", "latin1", "binary", "buffer"
"string", "hex", "ascii", "utf8", "utf16le", "ucs2", "latin1", "binary", "buffer"
];

@@ -425,2 +425,5 @@ function bufferParserNode(config) {

let value;
if (dataCount === -1) {
dataCount = Math.floor((buffer.length - startByte) / dataSize);
}
if (dataCount > 1) {

@@ -543,2 +546,3 @@ value = [];

case 'ascii':
case 'hex':
case 'utf8':

@@ -548,14 +552,22 @@ case "utf16le":

case "latin1":
case "binary":
item.value = buf.toString(type, offset, offset + length);
result.objectResults[item.name] = item;
result.keyvalues[item.name] = item.value;
result.arrayResults.push(item);
result.values.push(item.value);
case "binary":
{
let _end = length === -1 ? undefined : offset + length;
item.value = buf.toString(type, offset, _end);
result.objectResults[item.name] = item;
result.keyvalues[item.name] = item.value;
result.arrayResults.push(item);
result.values.push(item.value);
}
break;
case "bool":
case "boolean":
case "boolean":
{
let bcount = Math.floor(((item.offsetbit + length) / 8)) + (((item.offsetbit + length) % 8) > 0 ? 1 : 0)
let data = dataGetter(buf, item.offset, bcount, "readUInt8", 1, item.mask)
let _byteCount;
if(length === -1) {
_byteCount = -1
} else {
_byteCount = Math.floor(((item.offsetbit + length) / 8)) + (((item.offsetbit + length) % 8) > 0 ? 1 : 0)
}
let data = dataGetter(buf, item.offset, _byteCount, "readUInt8", 1, item.mask)
let bitData = []

@@ -571,6 +583,8 @@

}
if (length == 1) {
if (length === 1) {
item.value = bitData[item.offsetbit];
} else if(length === -1) {
item.value = bitData.slice(item.offsetbit); // -1 - return all to the end.
} else {
item.value = bitData.slice(item.offsetbit, item.offsetbit + length)
item.value = bitData.slice(item.offsetbit, item.offsetbit + length);
}

@@ -585,3 +599,3 @@ result.objectResults[item.name] = item;

{
let data = dataGetter(buf, item.offset, item.length, "readUInt8", 1, item.mask)
let data = dataGetter(buf, item.offset, length, "readUInt8", 1, item.mask)
let bitData = [];

@@ -608,3 +622,3 @@ if (Array.isArray(data) === false) {

let fn = type == "16bitle" ? "readUInt16LE" : "readUInt16BE";
let data = dataGetter(buf, item.offset, item.length, fn, 2, item.mask)
let data = dataGetter(buf, item.offset, length, fn, 2, item.mask)
let bitData = [];

@@ -631,3 +645,3 @@ if (Array.isArray(data) == false) {

let fn = type == "bcdle" ? "readUInt16LE" : "readUInt16BE";
let data = dataGetter(buf, item.offset, item.length, fn, 2, item.mask)
let data = dataGetter(buf, item.offset, length, fn, 2, item.mask)
if (item.length > 1) {

@@ -645,10 +659,13 @@ dataBCD = data.map(e => bcd2number(e));

break;
case "buffer":
item.value = buf.slice(offset, offset + length);
result.objectResults[item.name] = item;
result.keyvalues[item.name] = item.value;
result.arrayResults.push(item);
result.values.push(item.value);
case "buffer":
{
let _end = length === -1 ? undefined : offset + length;
item.value = buf.slice(offset, _end);
result.objectResults[item.name] = item;
result.keyvalues[item.name] = item.value;
result.arrayResults.push(item);
result.values.push(item.value);
}
break;
default:
default: {
let errmsg = `type '${item.type}' is not a recognised parse specification`;

@@ -658,2 +675,3 @@ console.warn(errmsg);

break;
}
}

@@ -660,0 +678,0 @@ if (validatedSpec.options.singleResult === false) {

{
"name": "node-red-contrib-buffer-parser",
"version": "2.4.0",
"description": "A dynamic node to convert values in a buffer or integer array into the many different data type(s). Supports Big/Little Endian, BCD, byte swapping and much more",
"version": "2.5.0",
"description": "Convert values in a buffer, integer array or hex string into many different data type(s). Supports Big/Little Endian, BCD, byte swapping and much more",
"keywords": [

@@ -6,0 +6,0 @@ "node-red",

@@ -11,6 +11,10 @@ node-red-contrib-buffer-parser

## A picture is worth a thousand words - here is 2000
## A picture is worth a thousand words
### Convert array of integers into individual topic/payload messages - ideal for sending to MQTT
![example1](/images/example1.png)
![example1](/images/ui.png)
### Convert a buffer into key/value items - ideal for sending to dashboard or database
![example3](/images/example3.png)
![example3b](/images/example3b.png)

@@ -21,3 +25,3 @@

* Setup a specification and convert multiple parts of an array or buffer to...
* Set-up a specification and convert multiple parts of an array or buffer to...
* int, int8, byte, uint, uint8,

@@ -24,0 +28,0 @@ * int16, int16le, int16be, uint16, uint16le, uint16be,

Sorry, the diff of this file is not supported yet

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