Options
All
  • Public
  • Public/Protected
  • All
Menu

Module utils

Type aliases

Ecl

Ecl: Static<typeof Ecl>

Functional

Functional: Static<typeof Functional>

Mask

Mask: Static<typeof Mask>

Mode

Mode: Static<typeof Mode>

Position

Position: Static<typeof Position>

Version

Version: Static<typeof Version>

Constant Variables

Const ALIGNMENT_POSITION

ALIGNMENT_POSITION: number[][] = ...

Fixed positions for alignment modules

Const ALPHANUMERIC

ALPHANUMERIC: string = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:"

Alphanumeric table

Const CAPACITY

CAPACITY: number[][] = ...

Fixed capacities for each version and error correction level

Const EC_CODEWORD_PER_BLOCK

EC_CODEWORD_PER_BLOCK: number[][] = ...

The number of error correction codewords per block according to error correction level and version

Const FORMAT_INFO

FORMAT_INFO: number[][] = ...

Fixed format information bits

Const KANJI

KANJI: object = ...

Shift-JIS boundary codepoints

Type declaration

  • A: number
  • B: number
  • C: number
  • D: number
  • E: number
  • factor: number

Const MODE

MODE: object = ...

Data encoding mode data
indicator: Mode indicator
charCount: Character count indicator

Type declaration

  • ALPHANUMERIC: object
    • charCount: number[]
    • indicator: number
  • BYTE: object
    • charCount: number[]
    • indicator: number
  • KANJI: object
    • charCount: number[]
    • indicator: number
  • NUMERIC: object
    • charCount: number[]
    • indicator: number

Const NUMERIC

NUMERIC: string = "0123456789"

Numeric table

Const NUM_EC_BLOCK

NUM_EC_BLOCK: number[][] = ...

The number of error correction blocks required according to error correction level and version

Const PENALTIES

PENALTIES: object = ...

Penalty factors for each condition

Type declaration

  • S1: number
  • S2: number
  • S3: number
  • S4: number

Const VERSION_INFO

VERSION_INFO: number[] = ...

Fixed version bits, starts from version 7

Other Variables

Const Ecl

Ecl: Union<[Literal<"LOW">, Literal<"MEDIUM">, Literal<"QUARTILE">, Literal<"HIGH">]> = ...

A Union of error correction level in string literal for type aliasing. External library runtypes used here.

Const Functional

Functional: Union<[Literal<"FINDER">, Literal<"SEPARATOR">, Literal<"TIMING">, Literal<"ALIGNMENT">, Literal<"FORMAT_INFO">, Literal<"VERSION_INFO">, Literal<"Dark">]> = ...

A union of functionalities in string literal for type aliasing. External library runtypes used here.

Const Mask

Mask: Constraint<Number, number, unknown> = ...

A number between -1 and 7 (including) for type aliasing. External library runtypes used here.

Const Mode

Mode: Union<[Literal<"BYTE">, Literal<"NUMERIC">, Literal<"ALPHANUMERIC">, Literal<"KANJI">]> = ...

A Union of data encoding mode in string literal for type aliasing. External library runtypes used here.

Const Position

Position: Tuple<[Number, Number]> = ...

A 2D position represented by a tuple of integer for type aliasing. External library runtypes used here.

Const Version

Version: Constraint<Number, number, unknown> = ...

A number between 1 and 40 (including) for type aliasing. External library runtypes used here.

Functions

computeOptimalMask

  • computeOptimalMask(qr: QR): [number, QR]
  • Step 7 for generating a QR code. Compute the optimal mask pattern for the given raw <qr> object

    internal

    Parameters

    • qr: QR

      The QR object

    Returns [number, QR]

    A QR code mask and corresponding number

generateCodePoint

  • generateCodePoint(str: string): CodePoint[]
  • Step 1 for generating a QR code. Generate an array of CodePoint objects by the given <str>. Each UTF-16 character in the string corresponds to a CodePoint instance. External library emoji-regex is used here for detecting emoji input.

    internal

    Parameters

    • str: string

      The string that is used for generating

    Returns CodePoint[]

generateCodeword

  • Step 5 for generating a QR code. Generate an array of codeword including both data codeword and error correction codeword by the given <data>, <version> and <ecl>

    internal

    Parameters

    • data: DataCodeword[]

      The array of data codeword

    • version: Version

      The version of QR code

    • ecl: Ecl

      The error correction level

    Returns Codeword[]

generateDataCodeword

  • Step 4 for generating a QR code. Generate an array of data codeword by the given <segments>, <version> and <ecl>

    internal

    Parameters

    • segments: Segment[]

      The array of encoded data segments

    • version: Version

      The version of QR code

    • ecl: Ecl

      The error correction level

    Returns DataCodeword[]

generateOptimalSegments

  • Alternative step 2 and 3 for generating a QR code. Generate an array of data segments and corresponding optimal version by the given <codePoints>, <version> and <ecl>

    internal

    Parameters

    • codePoints: CodePoint[]

      The array of CodePoint objects for encoding

    • version: Version

      The version of QR code

    • ecl: Ecl

      The error correction level

    • forced: boolean

      The option for forcing to use <version>

    Returns [Version, Segment[]]

    • An array of encoded data segments and corresponding optimal version

generateQR

  • generateQR(qr: QR, mask: [number, QR]): void
  • Step 8 for generating a QR code. Apply the <mask> to the raw <qr> object

    internal

    Parameters

    • qr: QR

      The QR object

    • mask: [number, QR]

      The optimal QR code mask and corresponding number

    Returns void

generateRawQR

  • Step 6 for generating a QR code. Initializing a new QR object by the given <version> and <ecl>, then place <data> into it.

    internal

    Parameters

    • data: Codeword[]

      The array of codeword

    • version: Version

      The version of QR code

    • ecl: Ecl

      The error correction level

    Returns QR

isColor

  • isColor(str?: string): boolean
  • Determine whether the given <str> is a valid hex color string. It should start with "#" and contain 3 or 6 hex number.

    Parameters

    • Optional str: string

      The string that should be tested, can be undefined

    Returns boolean

    TRUE if <str> is valid or undefined, FALSE otherwise

Generated using TypeDoc