@nuintun/qrcode
Version:
A pure JavaScript QRCode encode and decode library.
36 lines (32 loc) • 728 B
JavaScript
/**
* @module QRCode
* @package @nuintun/qrcode
* @license MIT
* @version 5.0.2
* @author nuintun <nuintun@qq.com>
* @description A pure JavaScript QRCode encode and decode library.
* @see https://github.com/nuintun/qrcode#readme
*/
;
/**
* @module ByteStream
*/
class ByteStream {
#bytes = [];
get bytes() {
return this.#bytes;
}
writeByte(value) {
this.#bytes.push(value & 0xff);
}
writeInt16(value) {
this.#bytes.push(value & 0xff, (value >> 8) & 0xff);
}
writeBytes(bytes, offset = 0, length = bytes.length) {
const buffer = this.#bytes;
for (let i = 0; i < length; i++) {
buffer.push(bytes[offset + i] & 0xff);
}
}
}
exports.ByteStream = ByteStream;