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

Function _hexWrite

MathBox/mathbox-bundle.js:47814–47840  ·  view source on GitHub ↗
(buf, string, offset, length)

Source from the content-addressed store, hash-verified

47812// =======================
47813
47814function _hexWrite (buf, string, offset, length) {
47815 offset = Number(offset) || 0
47816 var remaining = buf.length - offset
47817 if (!length) {
47818 length = remaining
47819 } else {
47820 length = Number(length)
47821 if (length > remaining) {
47822 length = remaining
47823 }
47824 }
47825
47826 // must be an even number of digits
47827 var strLen = string.length
47828 assert(strLen % 2 === 0, 'Invalid hex string')
47829
47830 if (length > strLen / 2) {
47831 length = strLen / 2
47832 }
47833 for (var i = 0; i < length; i++) {
47834 var byte = parseInt(string.substr(i * 2, 2), 16)
47835 assert(!isNaN(byte), 'Invalid hex string')
47836 buf[offset + i] = byte
47837 }
47838 Buffer._charsWritten = i * 2
47839 return i
47840}
47841
47842function _utf8Write (buf, string, offset, length) {
47843 var charsWritten = Buffer._charsWritten =

Callers 1

mathbox-bundle.jsFile · 0.70

Calls 2

isNaNFunction · 0.85
assertFunction · 0.70

Tested by

no test coverage detected