MCPcopy
hub / github.com/stemkoski/stemkoski.github.com / _readInt16

Function _readInt16

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

Source from the content-addressed store, hash-verified

1515}
1516
1517function _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
1536Buffer.prototype.readInt16LE = function (offset, noAssert) {
1537 return _readInt16(this, offset, true, noAssert)

Callers 1

mathbox-core.jsFile · 0.70

Calls 2

assertFunction · 0.70
_readUInt16Function · 0.70

Tested by

no test coverage detected