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