Created
May 20, 2016 20:18
-
-
Save towerofnix/831ac7ceb763b82a2864809474f52c7e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// str should be a great big binary string, e.g. '01101010' | |
// the string gets split into 8 bits of ascii codes, and then | |
// the characters are gotten from those | |
str = str.split('').filter(c => c === '0' || c === '1').join('') | |
new Array(str.length / 8) | |
.fill('') | |
.map((_,i) => str.slice(i*8,i*8+8)) | |
.map((s) => String.fromCharCode(parseInt(s, 2))) | |
.join('') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
test case:
source