Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

syntax error in BarcodeScannerProxy.js (arrow functions not supported) #588

Open
fartwhif opened this issue Dec 22, 2017 · 2 comments
Open
Labels

Comments

@fartwhif
Copy link

fartwhif commented Dec 22, 2017

Expected Behaviour

application starts without error

Actual Behaviour

application crashes with a syntax error within BarcodeScannerProxy.js

Reproduce Scenario (including but not limited to)

Steps to Reproduce

install the plugin, set to windows x86 platform, start debugging

Platform and Version (eg. Android 5.0 or iOS 9.2.1)

Windows 10, Visual studio 2015, Cordova 6.1.1, Msbuild 14, TACO

Plugin version

master origin/master origin/HEAD, SHA-1: 36284b1

Logs taken while reproducing problem

JavaScript critical error at line 166, column 26 in ms-appx://io.cordova.myapp5c88717e/www/plugins/phonegap-plugin-barcodescanner/src/windows/BarcodeScannerProxy.js\n\nSCRIPT1002: Syntax error

Workaround:

replace the arrow function with a regular function, unified diff:

 src/windows/BarcodeScannerProxy.js | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git src/windows/BarcodeScannerProxy.js src/windows/BarcodeScannerProxy.js
index cea16d9..a1b6054 100644
--- src/windows/BarcodeScannerProxy.js
+++ src/windows/BarcodeScannerProxy.js
@@ -160,15 +160,18 @@ BarcodeReader.prototype.init = function (capture, width, height) {
 
     var formatsList = BarcodeReader.scanCallArgs.args.length > 0 && BarcodeReader.scanCallArgs.args[0].formats;	
 	if (formatsList) {		
+        
+		var indexer = function (format) {
+            for (var index in BARCODE_FORMAT) {
+                if (BARCODE_FORMAT[index] === format) {
+                    return index;
+                }
+            }
+        }
+
         var possibleFormats = formatsList
             .split(",")
-            .map(format => {
-                for (var index in BARCODE_FORMAT) {
-                    if (BARCODE_FORMAT[index] === format) {                        
-                        return index;
-                    }
-                }
-            });
+            .map(indexer);
 
         this._zxingReader.possibleFormats = possibleFormats;
     }

Merry Christmas!

@ndcunningham
Copy link

I have this same issue:

JavaScript critical error at line 166, column 26 

Hope this gets looked at soon. Trying to run the app on same windows 10 platform

@ndcunningham
Copy link

ndcunningham commented Jan 30, 2018

Fixed when i added
<preference name="windows-target-version" value="10.0" />
And installed the camera plugin.

I am using ionic however so that is also a factor

@macdonst macdonst added the bug label Jan 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

3 participants