MCPcopy Index your code
hub / github.com/feross/buffer / hexWrite

Function hexWrite

index.js:826–850  ·  view source on GitHub ↗
(buf, string, offset, length)

Source from the content-addressed store, hash-verified

824}
825
826function hexWrite (buf, string, offset, length) {
827 offset = Number(offset) || 0
828 const remaining = buf.length - offset
829 if (!length) {
830 length = remaining
831 } else {
832 length = Number(length)
833 if (length > remaining) {
834 length = remaining
835 }
836 }
837
838 const strLen = string.length
839
840 if (length > strLen / 2) {
841 length = strLen / 2
842 }
843 let i
844 for (i = 0; i < length; ++i) {
845 const parsed = parseInt(string.substr(i * 2, 2), 16)
846 if (numberIsNaN(parsed)) return i
847 buf[offset + i] = parsed
848 }
849 return i
850}
851
852function utf8Write (buf, string, offset, length) {
853 return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)

Callers 1

index.jsFile · 0.85

Calls 1

numberIsNaNFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…