https://github.com/argeento/bit-crusher
Javascript dictionary encoder
https://github.com/argeento/bit-crusher
codegolf js1k jscrush
Last synced: about 2 months ago
JSON representation
Javascript dictionary encoder
- Host: GitHub
- URL: https://github.com/argeento/bit-crusher
- Owner: Argeento
- License: mit
- Created: 2020-09-08T11:19:57.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-10-10T01:11:51.000Z (over 4 years ago)
- Last Synced: 2025-03-30T01:04:47.156Z (2 months ago)
- Topics: codegolf, js1k, jscrush
- Language: TypeScript
- Homepage:
- Size: 17.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Bit crusher
Javascript URL-friendly [dictionary encoder](https://en.wikipedia.org/wiki/Dictionary_coder) created to **code-golfing** competition## Example crush
Before: **253** chars
```js
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
```js
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,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)
```Copy scaned text to browser address bar and see the result!
## Instalation
```
npm i bit-crush
```## Usage
Node:
```js
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)
```