* Adds padding to binary/hex string representation * * @param {string} str - string representation (binary/hex) * @param {int} bits - total number of bits wanted * @return {string} - string representation padding with empty (0) bits * * @example * pad("10011", 8); // "00010011"
(str, bits)
| 19 | * pad("10011", 8); // "00010011" |
| 20 | */ |
| 21 | function pad(str, bits) { |
| 22 | let res = str |
| 23 | while (res.length % bits !== 0) { |
| 24 | res = '0' + res |
| 25 | } |
| 26 | return res |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * Separates string into chunks of the same size |
no outgoing calls
no test coverage detected