nl_tokens: / * eslint - enable Scans and returns barcode from the provided image
pl_tokens: async function barcodeDecoder ( image , options ) { // eslint-disable-next-line options . barcode = options . barcode . toLowerCase ( ) const <mask> = Object . keys ( BARCODE_DECODERS ) if ( list . indexOf ( options . barcode ) === - 1 ) { throw new Error ( ` ${ list } ` ) } const { data , width , height } = await UTILITIES . getImageDataFromSource ( image ) const channels = data . length / ( width * height ) // check points for barcode location const spoints = [ 1 , 9 , 2 , 8 , 3 , 7 , 4 , 6 , 5 ] let numLines = spoints . length const slineStep = height / ( numLines + 1 ) // eslint-disable-next-line while ( ( numLines -= 1 ) ) { // create section of height 2 const start = channels * width * Math . floor ( slineStep * spoints [ numLines ] ) const end = channels * width * Math . floor ( slineStep * spoints [ numLines ] ) + 2 * channels * width // const pxLine = data.slice(start, end) // const { lines, padding } = UTILITIES.getLines({ const { lines , padding } = UTILITIES . getLines ( { data , start , end , width , height , channels , } ) if ( lines && lines . length !== 0 ) { // remove empty whitespaces on side of barcode if ( padding . left ) lines . shift ( ) if ( padding . right ) lines . pop ( ) // Run the decoder const result = BARCODE_DECODERS [ options . barcode ] ( lines , options . type ) if ( result ) { return result } } } throw new Error ( 'Failed to extract barcode!' ) }