Please leave your comments here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const KEY = { | |
LEFT: 37, | |
RIGHT: 39 | |
} | |
const cycle = (value, max) => (value + max) % max | |
const toTouchClientX = func => (event) => { | |
const { changedTouches: [first] } = event |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Replace requestAnimationFrame related API methods with mock object for testing. | |
* Extended fork from https://gist.github.com/ischenkodv/43934774f4509fcb5791 | |
* | |
* @type {Object} | |
*/ | |
const mockAnimationFrame = { | |
original: { | |
requestAnimationFrame: window.requestAnimationFrame, | |
cancelAnimationFrame: window.cancelAnimationFrame, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* In JavaScript, we can only return one value from a function. | |
* | |
* This restricts piping to unary functions -- we couldn't pipe, say, | |
* both the request and the response object, or the error and the data | |
* argument from one function to the next without wrapping them in | |
* another object or an array. Yuck. | |
* | |
* So we can't return them both, but we could call another function | |
* with both! Ok, now we just wrapped them in another function instead |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const createStore = (function () { | |
const scope = new WeakMap | |
const storeProto = { | |
subscribe (prop, fn) { | |
const ownScope = scope.get(this) | |
ownScope.subscribers[prop] = ownScope.subscribers[prop] || [] | |
ownScope.subscribers[prop].push(fn) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A collection of helper prototype for everyday DOM traversal, manipulation, | |
* and event binding. Sort of a minimalist jQuery, mainly for demonstration | |
* purposes. MIT @ m3g4p0p | |
*/ | |
window.$ = (function (undefined) { | |
/** | |
* Duration constants | |
* @type {Object} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const make = function make ({ | |
proto = {}, | |
self = {}, | |
init = function init (obj) { | |
Object.assign(this, obj) | |
return this | |
}, | |
mixins = [] | |
}) { | |
const mixProto = {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const curry = (fn, thisArg) => function accumulate (...args) { | |
return args.length < fn.length | |
? accumulate.bind(null, ...args) | |
: fn.apply(thisArg, args) | |
} | |
const fn = (a, b, c) => a + b + c | |
curry(fn)(1)(2)(3) // 6 | |
curry(fn)(1)(2, 3) // 6 etc... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Placeholder | |
const _ = function _ () {} | |
// Curry a given function, optionally specifying | |
// a context on which it should finally get called | |
const curry = function curry (fn, thisArg) { | |
// Accumulate the call arguments for the curried function | |
return function accumulate () { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function run (iterator) { | |
// Kick off the promise chain | |
Promise.resolve().then( | |
function resolved (value) { | |
// Get the next yielded iterator step, | |
// passing in the value from the last | |
// fulfillment | |
const next = iterator.next(value) |