goodeggs / angular-barcode-listener

Angular directive to listen for barcode scanner events
MIT License
16 stars 10 forks source link

Add support for suffix #15

Open darkurse opened 6 years ago

darkurse commented 6 years ago

Very often I have seen physical barcode scanners using a carriage return to signal the end of a barcode. could you do something to manage this ?

serhalp commented 6 years ago

As noted in https://github.com/goodeggs/angular-barcode-listener/issues/14, we actually added the ability to specify a regular expression that a barcode value must match in the underlying barcode-scan-listener-module, so you could specify something like barcodeValueTest: /\r$/. But unfortunately as explained in the above issue, we haven't properly threaded support for that into this module yet. And the value that your handler would be called with would include the carriage return, so you'd have to handle truncating that yourself...

However we'd also accept a PR into barcode-scan-listener if you'd like to add support for an optional suffix that gets stripped like the prefix!

darkurse commented 6 years ago

I actually saw what you're describing later in the day while investigating. I've done the mapping you're mentioning but I'm struggling a little with the tests .. that's my first time with both coffee script syntax and karma..

I'll do a PR within the hour I hope

darkurse commented 6 years ago

Hi @serhalp , anything wrong with the PRs ?