Comparing version 1.0.3 to 1.0.4
@@ -32,2 +32,9 @@ (function (global, factory) { | ||
Object.defineProperty(this, 'stop', { | ||
enumerable: true, | ||
writable: true, | ||
value: function value() { | ||
document.removeEventListener('keydown', _this.startListner, false); | ||
} | ||
}); | ||
Object.defineProperty(this, 'logInfo', { | ||
@@ -67,2 +74,5 @@ enumerable: true, | ||
this.HUMAN_MACHINE_SPEED_THRESHOLD_PERCENTAGE = config.overall_percentage || DEFAULT_CONFIG.config.overall_percentage; | ||
return { | ||
stop: this.stop | ||
}; | ||
} | ||
@@ -73,11 +83,6 @@ | ||
value: function initListenHandler() { | ||
this.handler = document.addEventListener('keydown', this.startListner, false); | ||
document.addEventListener('keydown', this.startListner, false); | ||
this.initBuffer(); | ||
} | ||
}, { | ||
key: 'stop', | ||
value: function stop() { | ||
this.handler = document.removeEventListener('keydown', this.startListner, false); | ||
} | ||
}, { | ||
key: 'initBuffer', | ||
@@ -91,4 +96,3 @@ value: function initBuffer() { | ||
value: function timeDifference(timestamp1, timestamp2) { | ||
var difference = timestamp2 - timestamp1; | ||
return difference / 1000; | ||
return (timestamp2 - timestamp1) / 1000; | ||
} | ||
@@ -107,4 +111,4 @@ }, { | ||
var bufferLength = this.timeStampBuffer.length - 1; | ||
var counter = 0; | ||
var lastHitKeyEnter = false; | ||
var counter = 0, | ||
lastHitKeyEnter = false; | ||
this.timeStampBuffer.forEach(function (timestamp, index) { | ||
@@ -123,3 +127,2 @@ if (index < bufferLength) { | ||
var achievedPercentage = counter * 100 / bufferLength; | ||
return achievedPercentage > this.HUMAN_MACHINE_SPEED_THRESHOLD_PERCENTAGE && lastHitKeyEnter; | ||
@@ -126,0 +129,0 @@ } |
{ | ||
"name": "keyscanner", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"main": "./build/index.min.js", | ||
"description": "library that allows reading input events from a barcode machine or other similar devices, and distinguish them from normal user keystrokes", | ||
"description": "A library to detect automated keyboard events from external devices (such as a barcode scanner) and differentiates between human keystroke inputs with a high level of accuracy. This reader software, hence allows obtaining barcode information, without the user having to focus the cursor on a textfield.", | ||
"license": "MIT", | ||
"scripts": { | ||
"format:fix": "pretty-quick --staged", | ||
"precommit": "npm run format:fix", | ||
"build": "rollup -c" | ||
@@ -38,2 +40,5 @@ }, | ||
"browser-env": "^2.0.29", | ||
"husky": "^0.14.3", | ||
"prettier": "^1.13.7", | ||
"pretty-quick": "^1.6.0", | ||
"rollup": "^0.41.6", | ||
@@ -40,0 +45,0 @@ "rollup-plugin-babel": "^2.7.1" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8824
116
13