Strategies

Convert data strings to binary

optimalStrategy(str,options)

Finds the shortest possible encoding using smart mode-switching.

Opts

  • minVersion: (default: 1)
  • maxVersion: (default: 40)
  • minEcl: (default: 0)
  • maxEcl: (default: 3)

Returns: { version, ecl, codewords, cost, steps, strategy, budget }

allStrategies(str,version,ecl)

Enumerates all strategies that fit within an exact version and ecl.

Returns: [steps]

constructCodewords(str,steps,version,ecl)

Concatenates the binary data based on steps, appends Reed-Solomon error correction codes, and interleaves them into a QR-ready Uint8Array.

packStrategy(steps)

Packs an array of steps ["byte","byte","byte","numeric","numeric"] into a compressed strategy.

unpackStrategy(packed,length)

Unpacks a compressed strategy into an array of steps ["byte","byte","byte","numeric","numeric"].