Skip to content

Commit

Permalink
fix: typos, add cspell
Browse files Browse the repository at this point in the history
  • Loading branch information
plasticrake committed Feb 16, 2019
1 parent 1aecac8 commit 8d24aab
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 8 deletions.
62 changes: 62 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"version": "0.1",

"language": "en",
"words": [
"plasticrake",

"castarray",
"defaultsdeep",
"isequal",
"jsonparse",

"camelcase",
"customizer",
"polyfill",
"preallocate",
"rssi",
"ssid",
"subnet",
"truthy",
"wifi",

"SNDBUF",

"binded",
"daystat",
"devs",
"emeter",
"heapsize",
"igain",
"itarget",
"kasa",
"lightingservice",
"lightstate",
"Linkie",
"mday",
"monthstat",
"netif",
"realtime",
"scaninfo",
"smartbulb",
"smarthome",
"smartlife",
"smartplugswitch",
"smartpowerstrip",
"stainfo",
"sysinfo",
"tcsp",
"timesetting",
"tplink",
"tplinkcloud",
"uboot",
"vgain",
"vtarget",
"wday"
],
"languageSettings": [{
"languageId": "markdown",
"local": "*",
"dictionaries": ["node"]
}]
}
8 changes: 4 additions & 4 deletions src/device-networking.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class DeviceNetworking extends EventEmitter {
processUdpMessage (msg, rinfo) {
let decryptedMsg = decrypt(msg).toString('utf8');
logUdp('[%s] UDP receiving', this.model, rinfo.port, rinfo.address);
this.emit('data', { time: Date.now(), protocol: 'udp', message: decryptedMsg, remoteAddress: rinfo.address, remortPort: rinfo.port });
this.emit('data', { time: Date.now(), protocol: 'udp', message: decryptedMsg, remoteAddress: rinfo.address, remotePort: rinfo.port });
let msgObj;
try {
msgObj = JSON.parse(decryptedMsg);
Expand All @@ -47,7 +47,7 @@ class DeviceNetworking extends EventEmitter {
setTimeout(() => {
logUdp('[%s] UDP responding, delay:%s,', this.model, this.responseDelay, rinfo.port, rinfo.address);
logUdp(responseForLog);
this.emit('response', { time: Date.now(), protocol: 'tcp', message: responseForLog, remoteAddress: rinfo.address, remortPort: rinfo.port });
this.emit('response', { time: Date.now(), protocol: 'tcp', message: responseForLog, remoteAddress: rinfo.address, remotePort: rinfo.port });
this.udpSocket.send(response, 0, response.length, rinfo.port, rinfo.address);
}, this.responseDelay);
}
Expand All @@ -57,7 +57,7 @@ class DeviceNetworking extends EventEmitter {
logTcp('[%s] TCP DATA', this.model, socket.remoteAddress, socket.remotePort);
let decryptedMsg = decryptWithHeader(msg).toString('utf8');
logTcp(decryptedMsg);
this.emit('data', { time: Date.now(), protocol: 'tcp', message: decryptedMsg, localAddress: socket.localAddress, localPort: socket.localPort, remoteAddress: socket.remoteAddress, remortPort: socket.remotePort });
this.emit('data', { time: Date.now(), protocol: 'tcp', message: decryptedMsg, localAddress: socket.localAddress, localPort: socket.localPort, remoteAddress: socket.remoteAddress, remotePort: socket.remotePort });
let msgObj;
try {
msgObj = JSON.parse(decryptedMsg);
Expand All @@ -73,7 +73,7 @@ class DeviceNetworking extends EventEmitter {
setTimeout(() => {
logTcp('[%s] TCP responding, delay:%s,', this.model, this.responseDelay, socket.address());
logTcp(responseForLog);
this.emit('response', { time: Date.now(), protocol: 'tcp', message: responseForLog, localAddress: socket.localAddress, localPort: socket.localPort, remoteAddress: socket.remoteAddress, remortPort: socket.remotePort });
this.emit('response', { time: Date.now(), protocol: 'tcp', message: responseForLog, localAddress: socket.localAddress, localPort: socket.localPort, remoteAddress: socket.remoteAddress, remotePort: socket.remotePort });
socket.write(response);
if (this.device.endSocketAfterResponse) {
socket.end();
Expand Down
8 changes: 4 additions & 4 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ function readJson (path, cb) {
});
}

function randomMac (prefix, delim = ':') {
var mac = prefix || ['50', 'c7', 'bf'].join(delim);
function randomMac (prefix, delimiter = ':') {
var mac = prefix || ['50', 'c7', 'bf'].join(delimiter);

for (var i = 0; i < 6; i++) {
if (i % 2 === 0) mac += delim;
if (i % 2 === 0) mac += delimiter;
mac += Math.floor(Math.random() * 16).toString(16);
}

Expand Down Expand Up @@ -123,7 +123,7 @@ function editRule (rules, rule) {
}

function deleteRule (rules, id) {
if (!id) throw { 'err_code': -10002, 'err_msg': 'Missing neccesary argument' };
if (!id) throw { 'err_code': -10002, 'err_msg': 'Missing neccesary argument' }; // cspell:disable-line // Typo on purpose
let rule = rules.find((r, i, a) => {
if (r.id === id) {
a.splice(i, 1); // remove rule
Expand Down

0 comments on commit 8d24aab

Please sign in to comment.