Code coverage report for function/compose.js

Statements: 100% (10 / 10)      Branches: 100% (0 / 0)      Functions: 100% (4 / 4)      Lines: 100% (9 / 9)     

All files » function/ » compose.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 241           1 1 1       3 3 6   3       1      
define(function () {
 
    /**
     * Returns a function that composes multiple functions, passing results to
     * each other.
     */
    function compose() {
        var fns = arguments;
        return function(arg){
            // only cares about the first argument since the chain can only
            // deal with a single return value anyway. It should start from
            // the last fn.
            var n = fns.length;
            while (n--) {
                arg = fns[n].call(this, arg);
            }
            return arg;
         };
     }
 
     return compose;
 
});