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

collectd-protocol

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

collectd-protocol - npm Package Compare versions

Comparing version 0.3.1 to 0.3.2

2

package.json

@@ -8,3 +8,3 @@ {

"description": "A NodeJS module for parsing the CollectD binary protocol",
"version": "0.3.1",
"version": "0.3.2",
"repository": {

@@ -11,0 +11,0 @@ "type": "git",

@@ -87,4 +87,7 @@ collectd-protocol

- Fix decoding of unknown values (not in types.db specification)
* 0.3.2
- Fix decoding of a sequence of metrics from the same plugin
[npm-url]: https://npmjs.org/package/collectd-protocol
[npm-image]: https://badge.fury.io/js/collectd-protocol.svg

@@ -9,2 +9,4 @@ 'use strict';

var isUndefined = require('lodash/isUndefined');
var last = require('lodash/last');
var clone = require('lodash/clone');

@@ -32,7 +34,17 @@ var definition = require('./definition');

*
* @param host A decoded host
* @param metricsArray The global metrics array
* @returns {*} A new initialized metric
*/
function initializeMetric(metricsArray) {
metricsArray.push({});
function initializeMetric(host, metricsArray) {
var lastMetric = last(metricsArray);
var newMetric;
if (isUndefined(lastMetric)) {
newMetric = {};
} else {
newMetric = clone(lastMetric);
}
newMetric.host = host;
metricsArray.push(newMetric);
return metricsArray[metricsArray.length - 1];

@@ -49,2 +61,6 @@ }

function isTimeType(header) {
return header.type === definition.TYPE_TIME_HIRES || header.type === definition.TYPE_TIME;
}
/**

@@ -116,3 +132,3 @@ * Returns true if the specified header type is a configured string part.

}
deferred.resolve({metric: metric, metrics: metrics});
deferred.resolve({metric: metric, metrics: metrics, decoded: decoded});
});

@@ -186,10 +202,15 @@ }

if (isHostType(header)) {
self._metric = initializeMetric(self._metrics);
if (isTimeType(header)) {
self._metric = initializeMetric(self._host, self._metrics);
}
decodePart(self._metrics, self._metric, header, self._buffer, self._offset)
.then(function() {
.then(function(decodedPart) {
self._offset += header.length;
self.push(self._metric);
if (isHostType(header)) {
self._host = decodedPart.decoded;
}
}, function (err) {

@@ -196,0 +217,0 @@ self.emit('error', err);

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