repl.txt (1163B)
1 2 {{alias}}( fcn[, arity][, thisArg] ) 3 Transforms a function into a sequence of functions each accepting a single 4 argument. 5 6 Until return value resolution, each invocation returns a new partially 7 applied curry function. 8 9 Parameters 10 ---------- 11 fcn: Function 12 Function to curry. 13 14 arity: integer (optional) 15 Number of parameters. Default: `fcn.length`. 16 17 thisArg: any (optional) 18 Evaluation context. 19 20 Returns 21 ------- 22 out: Function 23 Curry function. 24 25 Examples 26 -------- 27 > function add( x, y ) { return x + y; }; 28 > var f = {{alias}}( add ); 29 > var sum = f( 2 )( 3 ) 30 5 31 32 // Supply arity: 33 > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; 34 > f = {{alias}}( add, 2 ); 35 > sum = f( 2 )( 3 ) 36 5 37 38 // Provide function context: 39 > var obj = { 40 ... 'name': 'Ada', 41 ... 'greet': function greet( word1, word2 ) { 42 ... return word1 + ' ' + word2 + ', ' + this.name + '!' 43 ... } 44 ... }; 45 > f = {{alias}}( obj.greet, obj ); 46 > var str = f( 'Hello' )( 'there' ) 47 'Hello there, Ada!' 48 49 See Also 50 -------- 51