@kangax created a new interesting quiz, this time devoted to ES6 (aka ES2015). I found this quiz very interesting and quite hard (made myself 3 mistakes on first pass).
Here we go with the explanations:
(function(x, f = () => x) {| ############################################################################# | |
| # Original code ported from the Java reference code by Bram Cohen, April 2001, | |
| # with the following statement: | |
| # | |
| # this code is public domain, unless someone makes | |
| # an intellectual property claim against the reference | |
| # code, in which case it can be made public domain by | |
| # deleting all the comments and renaming all the variables | |
| # | |
| class Rijndael(object): |
| var express = require('express'), | |
| httpProxy = require('http-proxy'), | |
| app = express(); | |
| var proxy = new httpProxy.RoutingProxy(); | |
| function apiProxy(host, port) { | |
| return function(req, res, next) { | |
| if(req.url.match(new RegExp('^\/api\/'))) { | |
| proxy.proxyRequest(req, res, {host: host, port: port}); |
@kangax created a new interesting quiz, this time devoted to ES6 (aka ES2015). I found this quiz very interesting and quite hard (made myself 3 mistakes on first pass).
Here we go with the explanations:
(function(x, f = () => x) {| description "PhanthomJS running as WebDriver" | |
| start on startup | |
| stop on shutdown | |
| respawn | |
| script | |
| /usr/bin/phantomjs --webdriver=4444 | |
| end script |
| // This gist aims to explain how it's possible that async functions inside React | |
| // using createFetcher(Promise).next(key) can work. | |
| // A possible implementation of the new createFetcher function | |
| // as shown by https://twitter.com/jamiebuilds/status/969169357094842368 | |
| // @param method, should be a function returning a Promise. | |
| // @returns an object with a property 'read', used to read values from the resolved 'cache'. | |
| const createFetcher = function(method) { | |
| // First create a Map for the resolved values. | |
| const resolved = new Map() |