Skip to content

Instantly share code, notes, and snippets.

💭
this is dumb

Kevin Ennis kevincennis

💭
this is dumb
Block or report user

Report or block kevincennis

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View composition.js
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 ) {
View mergebuffers.js
// 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({
View tmpl.js
// KEWL TEMPLATING LIBRARY
function tmpl( fn ) {
return function( data ) {
return fn( data );
};
}
// DEMO...
@kevincennis
kevincennis / index.js
Last active Aug 29, 2015
"Native" YAML `require()`
View index.js
// 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') );
View curry.js
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 ) {
View privacy.js
var User = (function() {
var cache = new WeakMap();
function User( name ) {
cache.set( this, {} );
this.name = name;
}
User.prototype = {
View EventEmitter.js
var EventEmitter = (function() {
var cache = new WeakMap();
function EventEmitter() {
cache.set( this, {} );
}
EventEmitter.prototype = {
View EventEmitter.js
var EventEmitter = (function() {
var cache = new WeakMap();
function EventEmitter( obj ) {
cache.set( this, {} );
}
EventEmitter.prototype = {
View map-usage.js
map([ 'a', 'b', 'c' ], function( value ) {
return value.toUpperCase();
}); // [ 'A', 'B', 'C' ]
View factorial.js
function factorial( n ) {
if ( n === 1 ) {
return 1;
}
return n * factorial( n - 1 );
}
You can’t perform that action at this time.