MCPcopy
hub / github.com/kciter/qart.js / byteArrayOutputStream

Function byteArrayOutputStream

src/qrcode.js:1595–1641  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1593 // ---------------------------------------------------------------------
1594
1595 var byteArrayOutputStream = function () {
1596 var _bytes = new Array()
1597
1598 var _this = {}
1599
1600 _this.writeByte = function (b) {
1601 _bytes.push(b & 0xff)
1602 }
1603
1604 _this.writeShort = function (i) {
1605 _this.writeByte(i)
1606 _this.writeByte(i >>> 8)
1607 }
1608
1609 _this.writeBytes = function (b, off, len) {
1610 off = off || 0
1611 len = len || b.length
1612 for (var i = 0; i < len; i += 1) {
1613 _this.writeByte(b[i + off])
1614 }
1615 }
1616
1617 _this.writeString = function (s) {
1618 for (var i = 0; i < s.length; i += 1) {
1619 _this.writeByte(s.charCodeAt(i))
1620 }
1621 }
1622
1623 _this.toByteArray = function () {
1624 return _bytes
1625 }
1626
1627 _this.toString = function () {
1628 var s = ''
1629 s += '['
1630 for (var i = 0; i < _bytes.length; i += 1) {
1631 if (i > 0) {
1632 s += ','
1633 }
1634 s += _bytes[i]
1635 }
1636 s += ']'
1637 return s
1638 }
1639
1640 return _this
1641 }
1642
1643 // ---------------------------------------------------------------------
1644 // base64EncodeOutputStream

Callers 3

createImgObjectFunction · 0.85
getLZWRasterFunction · 0.85
createImgTagFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected