PHP 8.2.30
Preview: numeric-data.js Size: 1.18 KB
/home/byroehnu/.trash/node_modules11/qrcode/lib/core/numeric-data.js

const Mode = require('./mode')

function NumericData (data) {
  this.mode = Mode.NUMERIC
  this.data = data.toString()
}

NumericData.getBitsLength = function getBitsLength (length) {
  return 10 * Math.floor(length / 3) + ((length % 3) ? ((length % 3) * 3 + 1) : 0)
}

NumericData.prototype.getLength = function getLength () {
  return this.data.length
}

NumericData.prototype.getBitsLength = function getBitsLength () {
  return NumericData.getBitsLength(this.data.length)
}

NumericData.prototype.write = function write (bitBuffer) {
  let i, group, value

  // The input data string is divided into groups of three digits,
  // and each group is converted to its 10-bit binary equivalent.
  for (i = 0; i + 3 <= this.data.length; i += 3) {
    group = this.data.substr(i, 3)
    value = parseInt(group, 10)

    bitBuffer.put(value, 10)
  }

  // If the number of input digits is not an exact multiple of three,
  // the final one or two digits are converted to 4 or 7 bits respectively.
  const remainingNum = this.data.length - i
  if (remainingNum > 0) {
    group = this.data.substr(i)
    value = parseInt(group, 10)

    bitBuffer.put(value, remainingNum * 3 + 1)
  }
}

module.exports = NumericData

Directory Contents

Dirs: 0 × Files: 22

Name Size Perms Modified Actions
2.93 KB lrw-r--r-- 2026-02-27 09:44:58
Edit Download
1.78 KB lrw-r--r-- 2026-02-27 09:44:58
Edit Download
719 B lrw-r--r-- 2026-02-27 09:44:58
Edit Download
1.47 KB lrw-r--r-- 2026-02-27 09:44:58
Edit Download
675 B lrw-r--r-- 2026-02-27 09:45:00
Edit Download
3.33 KB lrw-r--r-- 2026-02-27 09:45:00
Edit Download
893 B lrw-r--r-- 2026-02-27 09:45:00
Edit Download
599 B lrw-r--r-- 2026-02-27 09:45:00
Edit Download
1.10 KB lrw-r--r-- 2026-02-27 09:45:00
Edit Download
1.85 KB lrw-r--r-- 2026-02-27 09:45:00
Edit Download
1.55 KB lrw-r--r-- 2026-02-27 09:45:00
Edit Download
5.96 KB lrw-r--r-- 2026-02-27 09:45:00
Edit Download
3.89 KB lrw-r--r-- 2026-02-27 09:45:00
Edit Download
1.18 KB lrw-r--r-- 2026-02-27 09:45:00
Edit Download
1.55 KB lrw-r--r-- 2026-02-27 09:45:00
Edit Download
14.77 KB lrw-r--r-- 2026-02-27 09:45:00
Edit Download
1.59 KB lrw-r--r-- 2026-02-27 09:45:00
Edit Download
1.06 KB lrw-r--r-- 2026-02-27 09:45:02
Edit Download
9.11 KB lrw-r--r-- 2026-02-27 09:45:02
Edit Download
1.58 KB lrw-r--r-- 2026-02-27 09:45:04
Edit Download
268 B lrw-r--r-- 2026-02-27 09:45:04
Edit Download
4.81 KB lrw-r--r-- 2026-02-27 09:45:04
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).