Skip to content

Instantly share code, notes, and snippets.

@Unitech
Created June 4, 2014 21:49
Show Gist options
  • Save Unitech/9615f685e86802469d78 to your computer and use it in GitHub Desktop.
Save Unitech/9615f685e86802469d78 to your computer and use it in GitHub Desktop.
Compose
/*
* Returns a function that is the composition of a list of functions,
* each consuming the return value of the function that follows.
*/
var slice = Array.prototype.slice;
var compose = function() {
var funcs = slice.call(arguments);
return function() {
var args = slice.call(arguments);
for (var i=funcs.length-1; i >= 0; i--) {
args = [funcs[i].apply(this, args)];
}
return args[0];
};
};
compose(
require('./test_exponentially_weighted_moving_average')
, require('./test_exponentially_decaying_sample')
, require('./test_uniform_sample')
, require('./meter')
, require('./histogram')
, require('./timer')
)();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment