(buf, string, offset, length)
| 47812 | // ======================= |
| 47813 | |
| 47814 | function _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 | |
| 47842 | function _utf8Write (buf, string, offset, length) { |
| 47843 | var charsWritten = Buffer._charsWritten = |
no test coverage detected