(buf, offset, littleEndian, noAssert)
| 48111 | } |
| 48112 | |
| 48113 | function _readUInt16 (buf, offset, littleEndian, noAssert) { |
| 48114 | if (!noAssert) { |
| 48115 | assert(typeof littleEndian === 'boolean', 'missing or invalid endian') |
| 48116 | assert(offset !== undefined && offset !== null, 'missing offset') |
| 48117 | assert(offset + 1 < buf.length, 'Trying to read beyond buffer length') |
| 48118 | } |
| 48119 | |
| 48120 | var len = buf.length |
| 48121 | if (offset >= len) |
| 48122 | return |
| 48123 | |
| 48124 | var val |
| 48125 | if (littleEndian) { |
| 48126 | val = buf[offset] |
| 48127 | if (offset + 1 < len) |
| 48128 | val |= buf[offset + 1] << 8 |
| 48129 | } else { |
| 48130 | val = buf[offset] << 8 |
| 48131 | if (offset + 1 < len) |
| 48132 | val |= buf[offset + 1] |
| 48133 | } |
| 48134 | return val |
| 48135 | } |
| 48136 | |
| 48137 | Buffer.prototype.readUInt16LE = function (offset, noAssert) { |
| 48138 | return _readUInt16(this, offset, true, noAssert) |
no test coverage detected