browser-barcodescanner
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -9,3 +9,5 @@ 'use strict'; | ||
callback({ | ||
res: barcodes[0].rawValue | ||
res: barcodes[0].rawValue, | ||
corner: barcodes[0].cornerPoints, | ||
box: barcodes[0].boundingBox | ||
}); | ||
@@ -18,2 +20,6 @@ }); | ||
// Check if the parameter sare valid | ||
if (!Array.isArray(formats) || formats.length === 0) throw new Error('Invalid formats, please provide at least one type of format. See https://developer.mozilla.org/en-US/docs/Web/API/Barcode_Detection_API#supported_barcode_formats for a list of supported formats.'); | ||
if (object === null) throw new Error('Invalid object, please provide a File, HTMLVideoElement, HTMLImageElement or HTMLCanvasElement.'); | ||
// Check if the format is supported | ||
@@ -23,3 +29,2 @@ const supportedFormats = await window.BarcodeDetector.getSupportedFormats(); | ||
if (unsupportedFormats.length > 0) throw new Error(`The following formats are not supported: ${unsupportedFormats.join(', ')}`); | ||
if (!object) throw new Error('Element or File to scan not provided'); | ||
if (object instanceof File) { | ||
@@ -26,0 +31,0 @@ /* If the object is a file, we need to convert it to a data URL */ |
@@ -7,3 +7,5 @@ function BarcodeScanner(callback, formats, object) { | ||
callback({ | ||
res: barcodes[0].rawValue | ||
res: barcodes[0].rawValue, | ||
corner: barcodes[0].cornerPoints, | ||
box: barcodes[0].boundingBox | ||
}); | ||
@@ -16,2 +18,6 @@ }); | ||
// Check if the parameter sare valid | ||
if (!Array.isArray(formats) || formats.length === 0) throw new Error('Invalid formats, please provide at least one type of format. See https://developer.mozilla.org/en-US/docs/Web/API/Barcode_Detection_API#supported_barcode_formats for a list of supported formats.'); | ||
if (object === null) throw new Error('Invalid object, please provide a File, HTMLVideoElement, HTMLImageElement or HTMLCanvasElement.'); | ||
// Check if the format is supported | ||
@@ -21,3 +27,2 @@ const supportedFormats = await window.BarcodeDetector.getSupportedFormats(); | ||
if (unsupportedFormats.length > 0) throw new Error(`The following formats are not supported: ${unsupportedFormats.join(', ')}`); | ||
if (!object) throw new Error('Element or File to scan not provided'); | ||
if (object instanceof File) { | ||
@@ -24,0 +29,0 @@ /* If the object is a file, we need to convert it to a data URL */ |
{ | ||
"name": "browser-barcodescanner", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "A browser API based barcode scanner", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.cjs.js", |
9258
83
105