mirror of
https://github.com/lewismoten/data-over-audio.git
synced 2026-03-20 09:15:21 +08:00
11 lines
237 B
JavaScript
11 lines
237 B
JavaScript
export const bitsToInt = (bits, bitLength) => {
|
|
parseInt(bits
|
|
// only grab the bits we need
|
|
.slice(0, bitLength)
|
|
// combine into string
|
|
.join('')
|
|
// Assume missing bits were zeros
|
|
.padEnd(bitLength, '0')
|
|
);
|
|
}
|