(buf, offset, littleEndian, noAssert)
| 1426 | } |
| 1427 | |
| 1428 | function _readUInt16 (buf, offset, littleEndian, noAssert) { |
| 1429 | if (!noAssert) { |
| 1430 | assert(typeof littleEndian === 'boolean', 'missing or invalid endian') |
| 1431 | assert(offset !== undefined && offset !== null, 'missing offset') |
| 1432 | assert(offset + 1 < buf.length, 'Trying to read beyond buffer length') |
| 1433 | } |
| 1434 | |
| 1435 | var len = buf.length |
| 1436 | if (offset >= len) |
| 1437 | return |
| 1438 | |
| 1439 | var val |
| 1440 | if (littleEndian) { |
| 1441 | val = buf[offset] |
| 1442 | if (offset + 1 < len) |
| 1443 | val |= buf[offset + 1] << 8 |
| 1444 | } else { |
| 1445 | val = buf[offset] << 8 |
| 1446 | if (offset + 1 < len) |
| 1447 | val |= buf[offset + 1] |
| 1448 | } |
| 1449 | return val |
| 1450 | } |
| 1451 | |
| 1452 | Buffer.prototype.readUInt16LE = function (offset, noAssert) { |
| 1453 | return _readUInt16(this, offset, true, noAssert) |
no test coverage detected