Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds the QR version to the object returned by jsQR #202

Merged
merged 2 commits into from
Apr 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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