MCPcopy
hub / github.com/stemkoski/stemkoski.github.com / _readInt32

Function _readInt32

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

Source from the content-addressed store, hash-verified

1542}
1543
1544function _readInt32 (buf, offset, littleEndian, noAssert) {
1545 if (!noAssert) {
1546 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
1547 assert(offset !== undefined && offset !== null, 'missing offset')
1548 assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
1549 }
1550
1551 var len = buf.length
1552 if (offset >= len)
1553 return
1554
1555 var val = _readUInt32(buf, offset, littleEndian, true)
1556 var neg = val & 0x80000000
1557 if (neg)
1558 return (0xffffffff - val + 1) * -1
1559 else
1560 return val
1561}
1562
1563Buffer.prototype.readInt32LE = function (offset, noAssert) {
1564 return _readInt32(this, offset, true, noAssert)

Callers 1

mathbox-core.jsFile · 0.70

Calls 2

assertFunction · 0.70
_readUInt32Function · 0.70

Tested by

no test coverage detected