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

Function _readUInt16

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

Source from the content-addressed store, hash-verified

48111}
48112
48113function _readUInt16 (buf, offset, littleEndian, noAssert) {
48114 if (!noAssert) {
48115 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
48116 assert(offset !== undefined && offset !== null, 'missing offset')
48117 assert(offset + 1 < buf.length, 'Trying to read beyond buffer length')
48118 }
48119
48120 var len = buf.length
48121 if (offset >= len)
48122 return
48123
48124 var val
48125 if (littleEndian) {
48126 val = buf[offset]
48127 if (offset + 1 < len)
48128 val |= buf[offset + 1] << 8
48129 } else {
48130 val = buf[offset] << 8
48131 if (offset + 1 < len)
48132 val |= buf[offset + 1]
48133 }
48134 return val
48135}
48136
48137Buffer.prototype.readUInt16LE = function (offset, noAssert) {
48138 return _readUInt16(this, offset, true, noAssert)

Callers 2

mathbox-bundle.jsFile · 0.70
_readInt16Function · 0.70

Calls 1

assertFunction · 0.70

Tested by

no test coverage detected