Skip to content

Commit

Permalink
extra safety for data
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffreyDavidsz committed Aug 16, 2022
1 parent afc1281 commit 0b0e81a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
22 changes: 10 additions & 12 deletions hotkey.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,17 @@ class instance extends instance_skel {
})
this.tcp.on('data', (data) => {
let dataArray = data.toString().trim().split('\r\n')
for (const iterator of dataArray) {
const json = ((raw) => {
try {
return JSON.parse(raw)
} catch (objError) {
if (objError instanceof SyntaxError) {
console.error(objError.name)
} else {
console.error(objError.message)
}
for (const rawData of dataArray) {
try {
let processed = JSON.parse(rawData)
if (processed !== null || processed !== undefined) this.processData(processed)
} catch (objError) {
if (objError instanceof SyntaxError) {
console.error(objError.name)
} else {
console.error(objError.message)
}
})(iterator)
this.processData(json)
}
}
})

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vicreo-hotkey",
"version": "3.0.3",
"version": "3.0.4",
"api_version": "1.0.0",
"keywords": [
"Software",
Expand Down

0 comments on commit 0b0e81a

Please sign in to comment.