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

rfcontroljs

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rfcontroljs - npm Package Compare versions

Comparing version 0.0.0 to 0.0.4

lib/protocols/pir1.js

2

gulpfile.js

@@ -1,2 +0,2 @@

require('coffee-script-redux/register');
require('coffee-script/register');
require('./gulpfile.coffee')

@@ -1,1 +0,1 @@

module.exports = require('lib/controller')
module.exports = require('./lib/controller');

@@ -5,7 +5,7 @@ var doesProtocolMatch, helper, protocols, sortIndices;

protocols = ['weather1', 'weather2', 'switch1', 'switch2', 'switch3', 'switch4'];
protocols = ['weather1', 'weather2', 'weather3', 'switch1', 'switch2', 'switch3', 'switch4', 'pir1'];
protocols = protocols.map((function(_this) {
return function(p) {
return require("../protocols/" + p + ".coffee")(helper);
return require("./protocols/" + p)(helper);
};

@@ -56,2 +56,3 @@ })(this));

module.exports = {
debug: false,
compressTimings: function(timings) {

@@ -92,3 +93,3 @@ var bucket, buckets, counts, hasMatch, i, j, pulses, sums, timing, _i, _j, _k, _len, _len1, _len2;

prepareCompressedPulses: function(input) {
var parts, pulseLengths, pulses;
var parts, pulseLengths, pulses, sortedIndices;
parts = input.split(' ');

@@ -102,7 +103,7 @@ pulseLengths = parts.slice(0, 8);

});
sortIndices = sortIndices(pulseLengths);
sortedIndices = sortIndices(pulseLengths);
pulseLengths.sort(function(l, r) {
return l - r;
});
pulses = helper.mapByArray(pulses, sortIndices);
pulses = helper.mapByArray(pulses, sortedIndices);
return {

@@ -113,4 +114,4 @@ pulseLengths: pulseLengths,

},
parsePulseSquence: function(pulseLengths, pulses) {
var p, results, values, _i, _len;
decodePulses: function(pulseLengths, pulses) {
var err, p, results, values, _i, _len;
results = [];

@@ -120,11 +121,42 @@ for (_i = 0, _len = protocols.length; _i < _len; _i++) {

if (doesProtocolMatch(pulseLengths, pulses, p)) {
values = p.parse(pulses);
results.push({
protocol: p.name,
values: values
});
try {
values = p.decodePulses(pulses);
results.push({
protocol: p.name,
values: values
});
} catch (_error) {
err = _error;
if (this.debug) {
console.log("Error trying to parse message with protocol " + p.name + ": " + err.stack);
}
if (!(err instanceof helper.ParsingError)) {
throw err;
}
}
}
}
return results;
},
encodeMessage: function(protocolName, message) {
var p, protocol, _i, _len;
protocol = null;
for (_i = 0, _len = protocols.length; _i < _len; _i++) {
p = protocols[_i];
if (p.name === protocolName) {
protocol = p;
break;
}
}
if (protocol == null) {
throw new Error("Could not find a protocol named " + protocolName);
}
if (protocol.encodeMessage == null) {
throw new Error("The protocol has no send report.");
}
return {
pulseLengths: protocol.pulseLengths,
pulses: protocol.encodeMessage(message)
};
}
};

@@ -0,2 +1,20 @@

var ParsingError,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
ParsingError = (function(_super) {
__extends(ParsingError, _super);
function ParsingError(message, cause) {
this.message = message;
this.cause = cause;
Error.captureStackTrace(this, ParsingError);
}
return ParsingError;
})(Error);
module.exports = {
ParsingError: ParsingError,
map: function(data, mapping) {

@@ -20,3 +38,3 @@ var hadMatch, i, replace, result, search;

if (!hadMatch) {
throw new Error("Data did not match mapping");
throw new ParsingError("Data did not match mapping");
}

@@ -57,2 +75,13 @@ }

},
numberToBinary: function(number, length) {
var binary, i;
binary = '';
i = 0;
while (i < length) {
binary = (number & 1) + binary;
number >>= 1;
i++;
}
return binary;
},
binaryToBoolean: function(data, i) {

@@ -59,0 +88,0 @@ return data[i] === '1';

{
"name": "rfcontroljs",
"version": "0.0.0",
"version": "0.0.4",
"description": "Protocol support for different 433mhz switches and weather stations for the RFControl Arduino library",
"main": "index.js",
"directories": {
"test": "test"
},
"files": [
"test",
"lib",
"README.md",
"LICENSE",
"gulpfile.js",
"gulpfile.coffee",
"index.js"
],
"scripts": {

@@ -22,5 +28,8 @@ "test": "gulp test"

"devDependencies": {
"coffee-script": "^1.7.1",
"gulp": "~3.8.6",
"gulp-coffee": "~2.1.1",
"coffee-script-redux": "~2.0.0-beta8",
"gulp-coffeelint": "^0.3.4",
"gulp-coverage": "^0.1.24",
"gulp-mocha": "^1.0.0",
"gulp-plumber": "~0.6.4",

@@ -27,0 +36,0 @@ "gulp-watch": "~0.6.9"

Sorry, the diff of this file is not supported yet

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