(buf, string, offset, length)
| 824 | } |
| 825 | |
| 826 | function 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 | |
| 852 | function utf8Write (buf, string, offset, length) { |
| 853 | return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) |
no test coverage detected
searching dependent graphs…