Socket
Socket
Sign inDemoInstall

vue-barcode-scanner

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-barcode-scanner - npm Package Compare versions

Comparing version 0.1.5 to 0.2.0

18

index.js

@@ -6,2 +6,4 @@ const VueBarcodeScanner = {

let attributes = {
previousCode: '',
tempCode: '',
barcode: '',

@@ -39,2 +41,6 @@ setting: {

Vue.prototype.$barcodeScanner.getPreviousCode = () => {
return attributes.previousCode
}
function addListener (type) {

@@ -60,4 +66,8 @@ if (attributes.hasListener) {

} else if (event.keyCode === 13 && attributes.barcode !== '') {
// scanner is done and trigger "Enter" then clear barcode and play the sound if it's set as true
// scanner is done and trigger "Enter" then clear barcode
// before clear current code, back it up to previous code and temp code for editable
// play the sound if it's set to true
attributes.callback(attributes.barcode)
attributes.previousCode = attributes.barcode
attributes.tempCode = attributes.barcode
attributes.barcode = ''

@@ -67,2 +77,7 @@ if (attributes.setting.sound) {

}
} else if (event.keyCode === 8 && attributes.tempCode !== '') {
// when enter backspace to edit barcode, Get the last code from temp and trim the last char
// then set it to current code
attributes.tempCode = attributes.tempCode.substring(0, attributes.tempCode.length - 1)
attributes.barcode = attributes.tempCode
} else {

@@ -78,2 +93,3 @@ // scan and validate each charactor

switch (input) {
case 8: inputChar = ''; break
case 189: inputChar = '-'; break

@@ -80,0 +96,0 @@ default: inputChar = String.fromCharCode(input); break

2

package.json
{
"name": "vue-barcode-scanner",
"version": "0.1.5",
"version": "0.2.0",
"description": "Barcode Scanner Plugin for Vue.js",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -15,2 +15,3 @@ # Vue Barcode Scanner

* Handle special charactors and return the complete barcode to you.
* Handle when user edit the code themselve by type backspace key then enter the plugin will return the correct code to you callback.

@@ -61,3 +62,3 @@ ----------------------------------------

### init
Init method use for add event listener (keydown) for the scanner
Init method use for add event listener (keydown) for the scanner.

@@ -69,3 +70,3 @@ ```javascript

### destroy
Destroy method is for remove the listener when it's unnecessary
Destroy method is for remove the listener when it's unnecessary.

@@ -77,3 +78,3 @@ ```javascript

### hasListener
Return the value that curently has a listener or not
Return the value that curently has a listener or not.

@@ -83,5 +84,13 @@ ```javascript

```
### getBarcode
Return last barcode scanned whatever your input is (In textbox currently).
The last barcode will be replace when hit enter key.
```javascript
this.$barcodeScanner.getBarcode() // return String
```
----------------------------------------
## Usage
In your component file (.vue) just for the component you need to listener for barcode
In your component file (.vue) just for the component you need to listener for barcode.

@@ -88,0 +97,0 @@ ```javascript

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc