Skip to content

Commit

Permalink
Merge pull request #202 from christianpaquin/return-qr-version
Browse files Browse the repository at this point in the history
Adds the QR version to the object returned by jsQR
  • Loading branch information
jefff authored Apr 24, 2021
2 parents 8851ab5 + bfba291 commit c36eaea
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ If a QR is able to be decoded the library will return an object with the followi
- `binaryData` - `Uint8ClampedArray` - The raw bytes of the QR code.
- `data` - The string version of the QR code data.
- `chunks` - The QR chunks.
- `version` - The QR version.
- `location` - An object with keys describing key points of the QR code. Each key is a point of the form `{x: number, y: number}`.
Has points for the following locations.
- Corners - `topRightCorner`/`topLeftCorner`/`bottomRightCorner`/`bottomLeftCorner`;
Expand Down
1 change: 1 addition & 0 deletions dist/decoder/decodeData/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface DecodedQR {
text: string;
bytes: number[];
chunks: Chunks;
version: number;
}
export declare enum Mode {
Numeric = "numeric",
Expand Down
1 change: 1 addition & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export interface QRCode {
binaryData: number[];
data: string;
chunks: Chunks;
version: number;
location: {
topRightCorner: Point;
topLeftCorner: Point;
Expand Down
2 changes: 2 additions & 0 deletions dist/jsQR.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ function scan(matrix) {
binaryData: decoded.bytes,
data: decoded.text,
chunks: decoded.chunks,
version: decoded.version,
location: {
topRightCorner: extracted.mappingFunction(location_1.dimension, 0),
topLeftCorner: extracted.mappingFunction(0, 0),
Expand Down Expand Up @@ -956,6 +957,7 @@ function decode(data, version) {
text: "",
bytes: [],
chunks: [],
version: version,
};
while (stream.available() >= 4) {
var mode = stream.readBits(4);
Expand Down
2 changes: 2 additions & 0 deletions docs/jsQR.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ function scan(matrix) {
binaryData: decoded.bytes,
data: decoded.text,
chunks: decoded.chunks,
version: decoded.version,
location: {
topRightCorner: extracted.mappingFunction(location_1.dimension, 0),
topLeftCorner: extracted.mappingFunction(0, 0),
Expand Down Expand Up @@ -956,6 +957,7 @@ function decode(data, version) {
text: "",
bytes: [],
chunks: [],
version: version,
};
while (stream.available() >= 4) {
var mode = stream.readBits(4);
Expand Down
2 changes: 2 additions & 0 deletions src/decoder/decodeData/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface DecodedQR {
text: string;
bytes: number[];
chunks: Chunks;
version: number;
}

export enum Mode {
Expand Down Expand Up @@ -178,6 +179,7 @@ export function decode(data: Uint8ClampedArray, version: number): DecodedQR {
text: "",
bytes: [],
chunks: [],
version: version,
};

while (stream.available() >= 4) {
Expand Down
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import {binarize} from "./binarizer";
import {BitMatrix} from "./BitMatrix";
import {Chunks} from "./decoder/decodeData";
import {decode} from "./decoder/decoder";
import { Version } from "./decoder/version";
import {extract} from "./extractor";
import {locate, Point} from "./locator";

export interface QRCode {
binaryData: number[];
data: string;
chunks: Chunks;
version: number;
location: {
topRightCorner: Point;
topLeftCorner: Point;
Expand Down Expand Up @@ -37,6 +39,7 @@ function scan(matrix: BitMatrix): QRCode | null {
binaryData: decoded.bytes,
data: decoded.text,
chunks: decoded.chunks,
version: decoded.version,
location: {
topRightCorner: extracted.mappingFunction(location.dimension, 0),
topLeftCorner: extracted.mappingFunction(0, 0),
Expand Down

0 comments on commit c36eaea

Please sign in to comment.