(buf, offset, littleEndian, noAssert)
| 48200 | } |
| 48201 | |
| 48202 | function _readInt16 (buf, offset, littleEndian, noAssert) { |
| 48203 | if (!noAssert) { |
| 48204 | assert(typeof littleEndian === 'boolean', 'missing or invalid endian') |
| 48205 | assert(offset !== undefined && offset !== null, 'missing offset') |
| 48206 | assert(offset + 1 < buf.length, 'Trying to read beyond buffer length') |
| 48207 | } |
| 48208 | |
| 48209 | var len = buf.length |
| 48210 | if (offset >= len) |
| 48211 | return |
| 48212 | |
| 48213 | var val = _readUInt16(buf, offset, littleEndian, true) |
| 48214 | var neg = val & 0x8000 |
| 48215 | if (neg) |
| 48216 | return (0xffff - val + 1) * -1 |
| 48217 | else |
| 48218 | return val |
| 48219 | } |
| 48220 | |
| 48221 | Buffer.prototype.readInt16LE = function (offset, noAssert) { |
| 48222 | return _readInt16(this, offset, true, noAssert) |
no test coverage detected