View lambda-img-to-webp.js
'use strict';
const whitelist = {
'/static/img/photo.jpg': '/static/img/photo.webp'
};
exports.handler = (event, context, callback) => {
// Grab HTTP request and it's headers
const request = event.Records[0].cf.request;
View app.js
const map = fn => list => list.map(fn);
const filter = fn => list => list.filter(fn);
const compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args)));
const tail = list => list.slice(1);
const fill = val => num => new Array(num).fill(val);
const getFileContents = file => require('fs').readFileSync(file, { encoding: 'utf8' });
const split = char => str => str.split(char);
const join = char => list => list.join(char);
View keybase.md

Keybase proof

I hereby claim:

  • I am branneman on github.
  • I am branneman (https://keybase.io/branneman) on keybase.
  • I have a public key ASBUXh5Xc1fnzeLViPT2_Wo268hlgsOINNiGJ7UzbkiVXQo

To claim this, I am signing this object:

View prefixEventListener.js
/**
* Capitalize
*/
const capitalize = string => {
return string.charAt(0).toUpperCase() + string.slice(1);
};
/**
* Prefix EventListener
*/
View executedBatched.js
/**
* Run a list of async tasks as promises and wait after each batch
* @param {Number} batchSize - Number of tasks to run in parallel
* @param {Number} waitTime - Time to wait after each batch, in milliseconds
* @param {Array<Function>} tasks - Promise executor functions (not promise objects!)
* @return {Promise<Array<*>>}
*/
function executeBatched(batchSize, waitTime, tasks) {
tasks = tasks.slice();
View modules.js
/**
* Globals
*/
var Carrousel = function(elem) { this.init() };
Carrousel.prototype = { init: function() {} };
new Carrousel();
/**
* Namespacing
* - No globals (only the namespace variable itself is global)
View es2015-returning-from-constructor.js
class Parent {
constructor() {
return new Promise(resolve => {
setTimeout(() => resolve({ data: 'important' }), 1e3);
});
}
}
class Child extends Parent {
constructor() {
View Observer.js
/**
* Used for inter-object communication.
* (Semi-)drop in replacement for Rik Schennink's Observer.
*
* Implementation differences:
* - ES6
* - The use of WeakMaps
* - inform() and conceal() don't return a boolean indicating success.
* - Subscription fn's are called with seperate arguments, instead of one data parameter. This is backwards compatible.
*
View public-key-crypto.js
const crypto = require('crypto');
const path = require('path');
const fs = require('fs');
// Expose module
module.exports = { encrypt, decrypt };
/**
* Encypt against public key
* @param {String} str - The string to encrypt
View implementation.js
/**
* Shallow merge objects
*/
function mergeObjectsShallow(target, ...sources) {
for (var i = 0; i < sources.length; i++) {
var source = sources[i];
for (var prop in source) {
if (!source.hasOwnProperty(prop)) continue;
target[prop] = source[prop];
}