File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -239,10 +239,7 @@ export function find(collection, callback) {
239
239
240
240
export function map < T > ( collection : T , callback ) : T {
241
241
var result = isArray ( collection ) ? [ ] : { } ;
242
-
243
- forEach ( collection , function ( val , i ) {
244
- result [ i ] = callback ( val , i ) ;
245
- } ) ;
242
+ forEach ( collection , ( val , i ) => result [ i ] = callback ( val , i ) ) ;
246
243
return < T > result ;
247
244
}
248
245
@@ -401,6 +398,20 @@ export function pattern(struct: Function[][]): Function {
401
398
402
399
export var isPromise = and ( isObject , pipe ( prop ( 'then' ) , isFunction ) ) ;
403
400
401
+ // Stolen: http://stackoverflow.com/questions/4394747/javascript-curry-function
402
+ export function curry ( fn : F ) : F {
403
+ var initial_args = [ ] . slice . apply ( arguments , [ 1 ] ) ;
404
+ var func_args_length = fn . length ;
405
+
406
+ function curried ( args ) {
407
+ if ( args . length >= func_args_length )
408
+ return fn . apply ( null , args ) ;
409
+ return function ( ) {
410
+ return curried ( args . concat ( [ ] . slice . apply ( arguments ) ) ) ;
411
+ } ;
412
+ }
413
+ return curried ( initial_args ) ;
414
+ }
404
415
/**
405
416
* @ngdoc overview
406
417
* @name ui.router.util
You can’t perform that action at this time.
0 commit comments