(string)
| 1 | export function stringToBinary(string) { |
| 2 | const encoder = new TextEncoder(); |
| 3 | const byteArray = encoder.encode(string); |
| 4 | let result = []; |
| 5 | |
| 6 | byteArray.forEach((value) => { |
| 7 | result.push(decimalToBinary(value).padStart(8, '0')); |
| 8 | }); |
| 9 | |
| 10 | return result.join('') |
| 11 | } |
| 12 | |
| 13 | export function hexToBinary(hex) { |
| 14 | let decimal = chunkString(hex, 2).map(value => parseInt(value, 16)); |
no test coverage detected