Skip to Content
Menu
This question has been flagged
1 Reply
1832 Views

 functioninitCanvas() {            if (true&&typeofdocument!=='undefined') {                var$debug=document.querySelector("#debug.detection");                _canvas.dom.frequency=document.querySelector("canvas.frequency");                if (!_canvas.dom.frequency) {                    _canvas.dom.frequency=document.createElement("canvas");                    _canvas.dom.frequency.className="frequency";                    if ($debug) {                        $debug.appendChild(_canvas.dom.frequency);                    }                }                _canvas.ctx.frequency=_canvas.dom.frequency.getContext("2d");
                _canvas.dom.pattern=document.querySelector("canvas.patternBuffer");                if (!_canvas.dom.pattern) {                    _canvas.dom.pattern=document.createElement("canvas");                    _canvas.dom.pattern.className="patternBuffer";                    if ($debug) {                        $debug.appendChild(_canvas.dom.pattern);                    }                }                _canvas.ctx.pattern=_canvas.dom.pattern.getContext("2d");
                _canvas.dom.overlay=document.querySelector("canvas.drawingBuffer");                if (_canvas.dom.overlay) {                    _canvas.ctx.overlay=_canvas.dom.overlay.getContext("2d");                }            }        }
        functioninitReaders() {                        config.readers.forEach(function (readerConfig) {                varreader,                    configuration= {},                    supplements= [];                                       console.log("READconfig value", readerConfig)                if ((typeofreaderConfig==='undefined'?'undefined':_typeof(readerConfig)) ==='object') {                    reader=readerConfig.format;                    configuration=readerConfig.config;                } elseif (typeofreaderConfig==='string') {                    reader=readerConfig;                }                if (true) {                                       console.log("Before registering reader: ", reader);                }                if (configuration.supplements) {                    supplements=configuration.supplements.map(function (supplement) {                        returnnewREADERS[supplement]();                    });                }                _barcodeReaders.push(newREADERS[reader](configuration, supplements));            });            if (true) {                console.log("Registered Readers: "+_barcodeReaders.map(function (reader) {                    returnJSON.stringify({ format:reader.FORMAT, config:reader.config });                }).join(', '));            }        }
        functioninitConfig() {            if (true&&typeofdocument!=='undefined') {                vari,                    vis= [{                    node:_canvas.dom.frequency,                    prop:config.debug.showFrequency                }, {                    node:_canvas.dom.pattern,


                    prop:config.debug.showPattern                }];
                for (i=0; i<vis.length; i++) {                    if (vis[i].prop===true) {                        vis[i].node.style.display="block";                    } else {                        vis[i].node.style.display="none";                    }                }            }        }
//here check consol.log('before registering reader' reader)

//camera opens up for barcode it wont scan ,when i checked  browser console it shows before registering reader : undefined
TypeError: READERS[reader] is not a constructor

Avatar
Discard
Author

anybody has any solutions?

Best Answer

hi, try to following pattern:

you should ensure that the reader variable holds a valid value that corresponds to a constructor function within the READERS object. 

  1. Check the readerConfig object or array from which the reader value is obtained. Ensure that the value assigned to the reader variable is correct and matches the keys in the READERS object.

  2. Verify that the READERS object contains the necessary constructor functions for the barcode readers you want to use. Make sure the keys in the READERS object match the values assigned to the reader variable.

  3. Double-check the spelling and case-sensitivity of the reader value. It should exactly match the corresponding key in the READERS object.

  4. Confirm that the required dependencies or modules for the barcode readers are correctly imported or available in the current context. Missing or incorrect dependencies could cause the constructor functions to be undefined.

By reviewing these steps and ensuring the correct assignment of the reader variable with a valid constructor function from the READERS object, you should be able to resolve the "TypeError: READERS[reader] is not a constructor" issue.

Avatar
Discard
Related Posts Replies Views Activity
0
Mar 22
1195
0
Jan 22
1184
0
Apr 20
3792
0
Sep 24
436
4
May 24
11130