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 compose() { | |
var fns = Array.prototype.slice.call( arguments ); | |
return function( arg ) { | |
return fns.reduceRight(function( result, fn ) { | |
return fn( result ); | |
}, arg ); | |
}; | |
} | |
function double( n ) { |
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
// assuming `rec1` and `rec2` are both instances of Recorder... | |
var buf1L, buf1R, buf2L, buf2R, worker, count = 0; | |
// start a new worker | |
// we can't use Recorder directly, since it doesn't support what we're trying to do | |
worker = new Worker('recorderWorker.js'); | |
// initialize the new worker | |
worker.postMessage({ |
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
// KEWL TEMPLATING LIBRARY | |
function tmpl( fn ) { | |
return function( data ) { | |
return fn( data ); | |
}; | |
} | |
// DEMO... |
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
// needs to be required once per process to set up the hook | |
require('./yaml.js'); | |
// now i can require a yml file. yay! | |
console.log( require('./test') ); |
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.curry = function curry() { | |
var fn = this, | |
arity = fn.length, | |
slice = Array.prototype.slice, | |
args = slice.call( arguments ); | |
function accumulator() { | |
var locArgs = args; | |
if ( arguments.length > 0 ) { |
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 User = (function() { | |
var cache = new WeakMap(); | |
function User( name ) { | |
cache.set( this, {} ); | |
this.name = name; | |
} | |
User.prototype = { |
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 EventEmitter = (function() { | |
var cache = new WeakMap(); | |
function EventEmitter() { | |
cache.set( this, {} ); | |
} | |
EventEmitter.prototype = { | |
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 EventEmitter = (function() { | |
var cache = new WeakMap(); | |
function EventEmitter( obj ) { | |
cache.set( this, {} ); | |
} | |
EventEmitter.prototype = { | |
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 factorial( n ) { | |
if ( n === 1 ) { | |
return 1; | |
} | |
return n * factorial( n - 1 ); | |
} |
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 map( arr, fn ) { | |
if ( arr.length === 0 ) { | |
return []; | |
} | |
return [ fn( arr[ 0 ] ) ].concat( map( arr.slice( 1 ), fn ) ); | |
} |
OlderNewer