Message from JavaScript discussions

May 2017

— It's basically described as "HTML4 as XML1"

— 

Node -e "require('http').Server((req, res) => require('fs').createReadStream('.' + req.url).pipe(res)).listen(1778)"

— Single line node :D

— Ahaha, a lambda, clever

— Node -e "http.Server((req, res) => fs.createReadStream('.' + req.url).on('error', err => console.error(err.name + ': ' + err.message)).pipe(res)).on('error', err => console.error(err.name + ': ' + err.message)).listen(1778)"

Message permanent page

— With proper error handling it quickly becomes a mess

— 

http.Server((req, res) =>
fs.createReadStream('.' + req.url)
.on('error', err => console.error(err.name + ': ' + err.message))
.pipe(res))
.on('error', err => console.error(err.name + ': ' + err.message))
.listen(1778)

Message permanent page

— As it often goes in unsegmented functional programming, you need some OOP and encapsulation eventually to reduce complexity

Message permanent page

— An event bus and scheduler, specifically

— 

const safe = (e) => (e.on('error', err => console.error(err.name + ': ' + err.message)), e);

safe(http.Server((req, res) =>
safe(fs.createReadStream('.' + req.url))
.pipe(res)))
.listen(1778)

Message permanent page

— Very lispy

— Sexy