node-nfcpy-id
Advanced tools
Comparing version 0.0.2 to 0.0.3
20
index.js
@@ -10,3 +10,3 @@ 'use strict'; | ||
this.options = options; | ||
this.running = false; | ||
this._running = false; | ||
@@ -22,7 +22,11 @@ ['SIGHUP', 'SIGINT', 'exit'].forEach((event) => { | ||
get isRunning() { | ||
return this._running; | ||
} | ||
start() { | ||
if (this.running) { | ||
if (this.isRunning) { | ||
return this; | ||
} | ||
this.running = true; | ||
this._running = true; | ||
@@ -36,3 +40,3 @@ const scriptFile = 'scriptFile' in (this.options || {}) ? | ||
this.pyshell.stdout.on('data', (json) => { | ||
if (this.running) { | ||
if (this.isRunning) { | ||
const data = JSON.parse(json.split('\n')[0]); | ||
@@ -44,2 +48,4 @@ this.emit(data.event, data); | ||
this.pyshell.end((err) => { | ||
this.pyshell = null; | ||
this._running = false; | ||
this.emit('error', err); | ||
@@ -52,10 +58,12 @@ }); | ||
stop() { | ||
if (!this.running) { | ||
if (!this.isRunning) { | ||
return this; | ||
} | ||
this.running = false; | ||
this._running = false; | ||
this.pyshell.childProcess.kill('SIGHUP'); | ||
this.pyshell = null; | ||
return this; | ||
} | ||
} |
{ | ||
"name": "node-nfcpy-id", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Read the ID of an NFC Tag with nfcpy", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
6936
8
170