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 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 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
| /* | |
| n-vector.js | |
| Copyright (c) 2014 Gordon Brander | |
| Released under the MIT license | |
| http://opensource.org/licenses/MIT | |
| Generic, efficient JavaScript vector math using ordinary arrays | |
| or indexed objects. |
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
| /* | |
| This document has been created with Marked.app <http://markedapp.com>, Copyright 2011 Brett Terpstra | |
| Please leave this notice in place, along with any additional credits below. | |
| --------------------------------------------------------------- | |
| Title: Highlighter | |
| Author: Gordon Brander http://gordonbrander.com | |
| Description: Minimal theme with careful typographic scale and highlighed bold. | |
| */ | |
| /* http://retinart.net/typography/typographicscale/ */ | |
| html { |
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
| // Minimal FRP Behaviors and Events. | |
| // An event function is any function of shape `function (next) { ... }` where | |
| // `next(value)` is a callback to be called by event function. Transformations | |
| // of event are accomplished by wrapping event with another event function, | |
| // and consuming original event within (CPS). | |
| // A behavior is any function of shape `function (time) { ... }`, where | |
| // `time` is current time. Behaviors may capture state, return value from time, | |
| // or be constant. Behaviors must always return a value, but value may |
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(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 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
| // Reduce any arraylike object. | |
| function reduceIndexed(indexed, next, initial) { | |
| var accumulated = initial; | |
| for (var i = 0; i < indexed.length; i += 1) | |
| accumulated = next(accumulated, indexed[i]); | |
| return accumulated; | |
| } |
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
| // Enumerate over an object's own keys/values, accumulating a value. | |
| // `initial` defines the initial value for the accumulation. Reference is an | |
| // optional additional argument that make a common case -- comparing 2 | |
| // objects -- easy and more efficient. | |
| function enumerate(object, next, initial, reference) { | |
| var accumulated = initial; | |
| for (var key in object) | |
| // Test for own keys with `hasOwnProperty` instead of `Object.keys` to | |
| // avoid garbage creation. | |
| // |
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
| // 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 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
| // Accumulators | |
| // ============================================================================= | |
| // | |
| // A tiny library for reactive programming that offers blazing fast generic | |
| // collection manipulation, asyncronous flow control and the ability to | |
| // represent infinitely large collections. | |
| // | |
| // Copyright Gordon Brander, 2013. Released under the terms of the [MIT license](http://opensource.org/licenses/MIT). | |
| // | |
| // Background: |
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
| var nil = 'indicating a nil value'; | |
| function reducePredicatePair(reduction, pair) { | |
| // If no reduction has yet been found and the predicate | |
| // matches, run the assocated function. | |
| if(reduction[0] === nil && pair[0].apply(null, reduction[1])) { | |
| reduction[0] = pair[1].apply(null, reduction[1]); | |
| } | |
| return reduction; | |
| } |