<commit_before>ZXing TypeScript
================

[![Build Status](https://travis-ci.org/aleris/zxing-typescript.svg?branch=master)](https://travis-ci.org/aleris/zxing-typescript)

ZXing ("zebra crossing") TypeScript is an open-source, multi-format 1D/2D barcode image processing library ported to TypeScript from Java.

See https://github.com/zxing/zxing for original Java project.

Demo
====

See [some demo examples](https://aleris.github.io/zxing-typescript/) in browser.

Usage
=====

The library can be used from browser with TypeScript (include anything from src/browser however you must do the packaging yourself) or with plain javascript (see below). It can also be used from node (see below). The library is using separate builds for node and browser to allow different ES targeting.

Browser Usage
-------------

Examples below are for QR barcode, all other supported barcodes work similary.

`npm install zxing-typescript --save`

To use from javascript you need to build the browser distribution package:

`npm run build.browser.dist`

And then include what you need from `build-browser` folder (for example `zxing.qrcodereader.min.js` for qr barcode reader).

Or just grap the minified files that are available in [examples](https://github.com/aleris/zxing-typescript/tree/master/docs/examples).

See [some demo examples](https://github.com/aleris/zxing-typescript/tree/master/docs/examples) for browser code examples with javascript.

All the examples are using es6, be sure is supported in your browser or modify as needed (eg. var instead of const etc.). 

The builded library itself is targeting es5 (see `.babelrc`). If you want to target es6 change to `"presets": ["es2016"]` and add babel-preset-es2016 to dependencies (but be aware that webpack uglify does not yet support es6 as of this writing).

### Scanning from Video Camera

To display the input from the video camera you will need to add a video element in the html page:

```html
<video id="video" width="300" height="200" style="border: 1px solid gray"></video>
```

To start decoding, first obtain a list of video input devices with:
<commit_msg>updated info about polyfills for devicemedia api<commit_after>ZXing TypeScript
================

[![Build Status](https://travis-ci.org/aleris/zxing-typescript.svg?branch=master)](https://travis-ci.org/aleris/zxing-typescript)

ZXing ("zebra crossing") TypeScript is an open-source, multi-format 1D/2D barcode image processing library ported to TypeScript from Java.

See https://github.com/zxing/zxing for original Java project.

Demo
====

See [some demo examples](https://aleris.github.io/zxing-typescript/) in browser.

Usage
=====

The library can be used from browser with TypeScript (include anything from src/browser however you must do the packaging yourself) or with plain javascript (see below). It can also be used from node (see below). The library is using separate builds for node and browser to allow different ES targeting.

Browser Usage
-------------

Examples below are for QR barcode, all other supported barcodes work similary.

`npm install zxing-typescript --save`

To use from javascript you need to build the browser distribution package:

`npm run build.browser.dist`

And then include what you need from `build-browser` folder (for example `zxing.qrcodereader.min.js` for qr barcode reader).

Or just grap the minified files that are available in [examples](https://github.com/aleris/zxing-typescript/tree/master/docs/examples).

See [some demo examples](https://github.com/aleris/zxing-typescript/tree/master/docs/examples) for browser code examples with javascript.

All the examples are using es6, be sure is supported in your browser or modify as needed (eg. var instead of const etc.). 

The builded library itself is targeting es5 (see `.babelrc`). If you want to target es6 change to `"presets": ["es2016"]` and add babel-preset-es2016 to dependencies (but be aware that webpack uglify does not yet support es6 as of this writing).

The browser library is using the [MediaDevices](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices) web api which is marked as experimental as of this writing. You can use external polyfills like [enumerateDevices-shim](https://github.com/pbojinov/enumerateDevices-shim) and [mediaDevices-getUserMedia-polyfill](https://github.com/mozdevs/mediaDevices-getUserMedia-polyfill) to increase browser compatiblity.

### Scanning from Video Camera

To display the input from the video camera you will need to add a video element in the html page:

```html
<video id="video" width="300" height="200" style="border: 1px solid gray"></video>
```

To start decoding, first obtain a list of video input devices with:

{'fraction_non_alphanumeric': 0.1020797962648557, 'fraction_numerical': 0.008913412563667233, 'mean_word_length': 4.657863145258103, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 15, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3124877', 'n_tokens_mistral': 1394, 'n_tokens_neox': 1312, 'n_words': 563}