MCPcopy
hub / github.com/stemkoski/stemkoski.github.com / _writeInt32

Function _writeInt32

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

Source from the content-addressed store, hash-verified

1715}
1716
1717function _writeInt32 (buf, value, offset, littleEndian, noAssert) {
1718 if (!noAssert) {
1719 assert(value !== undefined && value !== null, 'missing value')
1720 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
1721 assert(offset !== undefined && offset !== null, 'missing offset')
1722 assert(offset + 3 < buf.length, 'Trying to write beyond buffer length')
1723 verifsint(value, 0x7fffffff, -0x80000000)
1724 }
1725
1726 var len = buf.length
1727 if (offset >= len)
1728 return
1729
1730 if (value >= 0)
1731 _writeUInt32(buf, value, offset, littleEndian, noAssert)
1732 else
1733 _writeUInt32(buf, 0xffffffff + value + 1, offset, littleEndian, noAssert)
1734}
1735
1736Buffer.prototype.writeInt32LE = function (value, offset, noAssert) {
1737 _writeInt32(this, value, offset, true, noAssert)

Callers 1

mathbox-core.jsFile · 0.70

Calls 3

assertFunction · 0.70
verifsintFunction · 0.70
_writeUInt32Function · 0.70

Tested by

no test coverage detected