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

Function _writeUInt16

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

Source from the content-addressed store, hash-verified

48301}
48302
48303function _writeUInt16 (buf, value, offset, littleEndian, noAssert) {
48304 if (!noAssert) {
48305 assert(value !== undefined && value !== null, 'missing value')
48306 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
48307 assert(offset !== undefined && offset !== null, 'missing offset')
48308 assert(offset + 1 < buf.length, 'trying to write beyond buffer length')
48309 verifuint(value, 0xffff)
48310 }
48311
48312 var len = buf.length
48313 if (offset >= len)
48314 return
48315
48316 for (var i = 0, j = Math.min(len - offset, 2); i < j; i++) {
48317 buf[offset + i] =
48318 (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
48319 (littleEndian ? i : 1 - i) * 8
48320 }
48321}
48322
48323Buffer.prototype.writeUInt16LE = function (value, offset, noAssert) {
48324 _writeUInt16(this, value, offset, true, noAssert)

Callers 2

mathbox-bundle.jsFile · 0.70
_writeInt16Function · 0.70

Calls 2

assertFunction · 0.70
verifuintFunction · 0.70

Tested by

no test coverage detected