(buf, offset, littleEndian, noAssert)
| 1515 | } |
| 1516 | |
| 1517 | function _readInt16 (buf, offset, littleEndian, noAssert) { |
| 1518 | if (!noAssert) { |
| 1519 | assert(typeof littleEndian === 'boolean', 'missing or invalid endian') |
| 1520 | assert(offset !== undefined && offset !== null, 'missing offset') |
| 1521 | assert(offset + 1 < buf.length, 'Trying to read beyond buffer length') |
| 1522 | } |
| 1523 | |
| 1524 | var len = buf.length |
| 1525 | if (offset >= len) |
| 1526 | return |
| 1527 | |
| 1528 | var val = _readUInt16(buf, offset, littleEndian, true) |
| 1529 | var neg = val & 0x8000 |
| 1530 | if (neg) |
| 1531 | return (0xffff - val + 1) * -1 |
| 1532 | else |
| 1533 | return val |
| 1534 | } |
| 1535 | |
| 1536 | Buffer.prototype.readInt16LE = function (offset, noAssert) { |
| 1537 | return _readInt16(this, offset, true, noAssert) |
no test coverage detected