(buf, value, offset, littleEndian, noAssert)
| 1688 | } |
| 1689 | |
| 1690 | function _writeInt16 (buf, value, offset, littleEndian, noAssert) { |
| 1691 | if (!noAssert) { |
| 1692 | assert(value !== undefined && value !== null, 'missing value') |
| 1693 | assert(typeof littleEndian === 'boolean', 'missing or invalid endian') |
| 1694 | assert(offset !== undefined && offset !== null, 'missing offset') |
| 1695 | assert(offset + 1 < buf.length, 'Trying to write beyond buffer length') |
| 1696 | verifsint(value, 0x7fff, -0x8000) |
| 1697 | } |
| 1698 | |
| 1699 | var len = buf.length |
| 1700 | if (offset >= len) |
| 1701 | return |
| 1702 | |
| 1703 | if (value >= 0) |
| 1704 | _writeUInt16(buf, value, offset, littleEndian, noAssert) |
| 1705 | else |
| 1706 | _writeUInt16(buf, 0xffff + value + 1, offset, littleEndian, noAssert) |
| 1707 | } |
| 1708 | |
| 1709 | Buffer.prototype.writeInt16LE = function (value, offset, noAssert) { |
| 1710 | _writeInt16(this, value, offset, true, noAssert) |
no test coverage detected