MCPcopy Index your code
hub / github.com/stemkoski/stemkoski.github.com / _readInt16

Function _readInt16

MathBox/mathbox-bundle.js:48202–48219  ·  view source on GitHub ↗
(buf, offset, littleEndian, noAssert)

Source from the content-addressed store, hash-verified

48200}
48201
48202function _readInt16 (buf, offset, littleEndian, noAssert) {
48203 if (!noAssert) {
48204 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
48205 assert(offset !== undefined && offset !== null, 'missing offset')
48206 assert(offset + 1 < buf.length, 'Trying to read beyond buffer length')
48207 }
48208
48209 var len = buf.length
48210 if (offset >= len)
48211 return
48212
48213 var val = _readUInt16(buf, offset, littleEndian, true)
48214 var neg = val & 0x8000
48215 if (neg)
48216 return (0xffff - val + 1) * -1
48217 else
48218 return val
48219}
48220
48221Buffer.prototype.readInt16LE = function (offset, noAssert) {
48222 return _readInt16(this, offset, true, noAssert)

Callers 1

mathbox-bundle.jsFile · 0.70

Calls 2

assertFunction · 0.70
_readUInt16Function · 0.70

Tested by

no test coverage detected