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
var app = (function() { | |
var app = (function () { | |
var cache = {}; | |
var getTopic = function (topic) { | |
return cache[topic] || (cache[topic] = []); | |
}; | |
var emitData = function(data, callback) { | |
callback.call(null, data); |
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() { | |
var split = {}, intervalData, | |
timeComponent = { | |
seconds: function (split) {return split.seconds * 6;}, | |
minutes: function (split) {return (split.minutes + (split.seconds / 60)) * 6;}, | |
hours: function (split) {return (split.hours % 12 * 30 ) + split.minutes / 2;} | |
}; | |
var SVG = (function() { | |
var SVG = function(config) { |
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
var first = (function() { | |
var chainNames = ["then", "andThen", "next"]; | |
var endChainNames = ["finally", "andFinally", "last"]; | |
var chain = function(fn) { | |
var f1 = function(g) { | |
var func = function() {return g.call(this, fn.apply(this, arguments));}; | |
chain(func); | |
return func; | |
}; | |
var f2 = function(g) { |
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.prototype.compose = function(g) { | |
var fn = this; | |
return function() { | |
return fn.call(this, g.apply(this, arguments)); | |
}; | |
}; | |
Function.prototype.pipe = function(g) { | |
var fn = this; | |
return function() { |
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
// clean and pure: | |
function cons(x, y) { | |
return function(pick) { | |
return pick(x, y); | |
} | |
} | |
// does more stuff: | |
function cons(x, y) { | |
var fn = function(pick) { |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"/> | |
<title>String#includes vs. String#indexOf vs. RegExp</title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script> | |
<script src="./suite.js"></script> | |
</head> | |
<body> | |
<h1>Open the console to view the results</h1> |
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
var R = require('./ramda'); | |
// Discussion at https://github.com/ramda/ramda/issues/1258 | |
var namedCurry = function(fn, argNames) { | |
// TODO: what if fn.length != argNames.length? | |
var f = R.curryN(fn.length, function() { | |
return fn.apply(this, arguments); | |
}); | |
f['secret-sauce'] = { |
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
var compose = function compose(f) { | |
var queue = f ? [f] : []; | |
var fn = function fn(g) { | |
if (arguments.length) { | |
queue.push(g); | |
return fn; | |
} | |
return function() { | |
var args = Array.prototype.slice.call(arguments); | |
queue.forEach(function(func) { |
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
// Based on a discussion with Michael Haufe: | |
// https://groups.google.com/group/jsmentors/browse_thread/thread/d028fb0041f93a27 | |
// Not really recommended for anything but the fun of knowing it can be done! | |
var omega = function() { | |
var queue = []; | |
var valueOf = Function.prototype.valueOf; | |
Function.prototype.valueOf = function() { | |
queue.push(this); | |
return 1; // not needed now, but could be used later to distinguish operators. |
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
const R = require('ramda'); | |
const permutations = (tokens, subperms = [[]]) => | |
R.isEmpty(tokens) ? | |
subperms : | |
R.addIndex(R.chain)((token, idx) => permutations( | |
R.remove(idx, 1, tokens), | |
R.map(R.append(token), subperms) | |
), tokens); |