An open API service indexing awesome lists of open source software.

https://github.com/darcyclarke/javascripting-golf

⛳️ Solving NodeSchool's "javascripting" workshopper with the least amount of code
https://github.com/darcyclarke/javascripting-golf

fun golf javascript nodejs

Last synced: 6 months ago
JSON representation

⛳️ Solving NodeSchool's "javascripting" workshopper with the least amount of code

Awesome Lists containing this project

README

          

[![build status](https://api.travis-ci.org/darcyclarke/javascripting-golf.svg?branch=master)](https://travis-ci.org/darcyclarke/javascripting-golf/) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)

## JavaScripting as code golf ⛳

An attempt at solving [`javascripting`](https://github.com/workshopper/javascripting) with the least amount of code possible

### Why?

For fun!

### Notes
- drop spaces and semicolons where possible
- drop `var`,`let`,`const`,`new`,`function` keywords where possible
- make use of one letter variable names, eg: `a=[]`
- utilize ternary and `&&` to do ["FP"](https://en.wikipedia.org/wiki/Functional_programming) _things_, eg: `x&&y()` vs `if(x)y()`
- concat vs using `toString()`, eg: `''+d` vs `d.toString()`
- `+` vs `Number()`, eg: `+'200'` vs `Number('200')`
- store as ref if something is being used more than once, eg: `l=console.log;l(a);l(b)`
- consider above when accessing object methods, eg: `f='forEach';a[f](a=>…);b[f](b=>…)`
- use node internals, eg: `.Server()` vs `.createServer()`
- use multiple lines if the column gets too wide
- loose equality vs strict
- replace `true` and `false` with `1` and `0`

### Contributing

Can you do better? Make a PR! If you can get the solutions down to less characters, be sure to run `npm run build:mock && npm run test:mock && npm run test:solutions` (this will create a new mock file with character counts and ensure both tests pass!). After that be sure to run `npm run build:readmes` to generate new README.md files for your newly added solutions.

### Tests

run all tests:
`npm t`

test all solutions:
`npm run test:solutions`

test character counts:
`npm run test:mock`

### Credit
This repo is based on the work of [Ricky Miller](http://github.com/rickycodes/learnyounode-golf) & the wider [NodeSchool Toronto](http://github.com/nodeschool/toronto) mentor group.

### License

MIT License

Copyright © 2018 Darcy Clarke

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.