From 26027bfb854708b5e568aa92105a6de9fc2a6333 Mon Sep 17 00:00:00 2001 From: Koen Kanters Date: Mon, 9 Apr 2018 20:27:32 +0200 Subject: [PATCH] Perfy is nice but we dont need it :(. #2 --- npm-shrinkwrap.json | 5 ----- package.json | 1 - parsers.js | 18 +++++++----------- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index a7062c589..f1f44ea14 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -601,11 +601,6 @@ "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" }, - "perfy": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/perfy/-/perfy-1.1.2.tgz", - "integrity": "sha1-5KASR7xab8mfPfHaD9Oi0lU7QyM=" - }, "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", diff --git a/package.json b/package.json index 47c9a3ed5..91d52ccb3 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,6 @@ "homepage": "https://github.com/AndrewLinden/xiaomi-zb2mqtt#readme", "dependencies": { "mqtt": "*", - "perfy": "*", "zigbee-shepherd": "*", "yaml-config": "*" } diff --git a/parsers.js b/parsers.js index 2434ceb98..2ecfcf42b 100644 --- a/parsers.js +++ b/parsers.js @@ -1,5 +1,3 @@ -const perfy = require('perfy'); - const clickLookup = { 2: 'double', 3: 'triple', @@ -28,16 +26,14 @@ const parsers = [ // 0 = click down, 1 = click up, else = multiple clicks if (state === 0) { - perfy.start(deviceID); - setTimeout(() => { - if (perfy.exists(deviceID)) { - publish('long'); - perfy.end(deviceID); - } - }, 300); // After 300 seconds of not releasing we assume long click. + store[deviceID] = setTimeout(() => { + publish('long'); + store[deviceID] = null; + }, 300); // After 300 milliseconds of not releasing we assume long click. } else if (state === 1) { - if (perfy.exists(deviceID)) { - perfy.end(deviceID); + if (store[deviceID]) { + clearTimeout(store[deviceID]); + store[deviceID] = null; publish('single'); } } else {