This file contains 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 id(x) { | |
return x; | |
} | |
// Memoize a function -- creates a new function that will cache the results of | |
// the first return by serializing inputs as a key. | |
// | |
// * `fn`: the function to be memoized. | |
// * `hash`: a function to create the cache key. | |
// * `out`: a function to process memoized data on the way out. Useful if you need |
This file contains 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(exports) { | |
var modules = {} | |
var factories = {} | |
// Require a module by id. | |
function require(id) { | |
if (!(id in factories)) throw Error(id + ' module is not defined') | |
if (!(id in modules)) { | |
modules[id] = {} | |
factories[id](require, modules[id]) |
This file contains 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
// https://en.wikipedia.org/wiki/Linked_list | |
// https://blog.jcoglan.com/2007/07/23/writing-a-linked-list-in-javascript/ | |
// Reducible prototype for linked list node. | |
var __node__ = { | |
reduce: function reduceNodes(reducer, initial) { | |
var node = this; | |
var accumulated = initial; | |
do { | |
accumulated = reducer(accumulated, node); |
This file contains 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 uid() { | |
// Generate a unique and non-colliding id. | |
return Math.random().toString(36).slice(2); | |
} | |
// Create unique, non-colliding ID namespace. | |
var __id__ = uid(); | |
function idOf(thing) { | |
return (thing && typeof(thing) === ('object' || 'function')) ? |