MCPcopy
hub / github.com/stemkoski/stemkoski.github.com / _writeInt16

Function _writeInt16

MathBox/mathbox-core.js:1690–1707  ·  view source on GitHub ↗
(buf, value, offset, littleEndian, noAssert)

Source from the content-addressed store, hash-verified

1688}
1689
1690function _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
1709Buffer.prototype.writeInt16LE = function (value, offset, noAssert) {
1710 _writeInt16(this, value, offset, true, noAssert)

Callers 1

mathbox-core.jsFile · 0.70

Calls 3

assertFunction · 0.70
verifsintFunction · 0.70
_writeUInt16Function · 0.70

Tested by

no test coverage detected