Created
June 4, 2014 21:49
-
-
Save Unitech/9615f685e86802469d78 to your computer and use it in GitHub Desktop.
Compose
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
/* | |
* 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