MCPcopy Create free account
hub / github.com/microsoft/SandDance / hexWrite

Function hexWrite

docs/app/js/sanddance-app.js:113385–113401  ·  view source on GitHub ↗
(buf, string, offset, length)

Source from the content-addressed store, hash-verified

113383 return bidirectionalIndexOf(this, val, byteOffset, encoding, false);
113384};
113385function hexWrite(buf, string, offset, length) {
113386 offset = Number(offset) || 0;
113387 var remaining = buf.length - offset;
113388 if (!length) length = remaining;
113389 else {
113390 length = Number(length);
113391 if (length > remaining) length = remaining;
113392 }
113393 var strLen = string.length;
113394 if (length > strLen / 2) length = strLen / 2;
113395 for(var i = 0; i < length; ++i){
113396 var parsed = parseInt(string.substr(i * 2, 2), 16);
113397 if (numberIsNaN(parsed)) return i;
113398 buf[offset + i] = parsed;
113399 }
113400 return i;
113401}
113402function utf8Write(buf, string, offset, length) {
113403 return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length);
113404}

Callers 1

sanddance-app.jsFile · 0.70

Calls 1

numberIsNaNFunction · 0.70

Tested by

no test coverage detected