1.0.3 • Published 4 years ago
bit-crush v1.0.3
Bit crusher
Javascript URL-friendly dictionary encoder created to code-golfing competition
Example crush
Before: 253 chars
console.log(`99 bottles of beer on the wall, 99 bottles of beer.
Take one down and pass it around, 98 bottles of beer on the wall.
98 bottles of beer on the wall, 98 bottles of beer.
Take one down and pass it around, 97 bottles of beer on the wall.`)
After: 167 chars
O=`console.log(\`99jv9m8j.
98jv8m7j.\`)jq on the wallmq.
Take one down and pass it aroundvq bottles of beerv, 9`;for(o of'vqmj')with(O.split(o))O=join(pop());eval(O)
Why URL-friendly?
Bit crusher does not use special URL character, so with a little modification you can put your script to QR-code!
Try it out!
data:text/html,<script>O=`alert(\`99jv9m8j.%0A
98jv8m7j.\`)jq on the wallmq.%0A
Take one down and pass it aroundvq bottles of beerv, 9`;for(o of'vqmj')with(O.split(o))O=join(pop());eval(O)</script>
Copy scaned text to browser address bar and see the result!
Instalation
npm i bit-crush
Usage
Node:
const bitCrush = require('bit-crush')
const code = `console.log(\`99 bottles of beer on the wall, 99 bottles of beer.
Take one down and pass it around, 98 bottles of beer on the wall.
98 bottles of beer on the wall, 98 bottles of beer.
Take one down and pass it around, 97 bottles of beer on the wall.\`)`
const crushed = bitCrush(code)
console.log(crushed)