(buf, string, offset, length)
| 887 | } |
| 888 | |
| 889 | function hexWrite (buf, string, offset, length) { |
| 890 | offset = Number(offset) || 0 |
| 891 | var remaining = buf.length - offset |
| 892 | if (!length) { |
| 893 | length = remaining |
| 894 | } else { |
| 895 | length = Number(length) |
| 896 | if (length > remaining) { |
| 897 | length = remaining |
| 898 | } |
| 899 | } |
| 900 | |
| 901 | var strLen = string.length |
| 902 | |
| 903 | if (length > strLen / 2) { |
| 904 | length = strLen / 2 |
| 905 | } |
| 906 | for (var i = 0; i < length; ++i) { |
| 907 | var parsed = parseInt(string.substr(i * 2, 2), 16) |
| 908 | if (numberIsNaN(parsed)) return i |
| 909 | buf[offset + i] = parsed |
| 910 | } |
| 911 | return i |
| 912 | } |
| 913 | |
| 914 | function utf8Write (buf, string, offset, length) { |
| 915 | return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) |
no test coverage detected
searching dependent graphs…