@@ -2267,6 +2267,101 @@ module TestDetect {
2267
2267
result = _ ( dictionary ) . detect < { a : number } , TResult > ( { a : 42 } ) ;
2268
2268
}
2269
2269
2270
+ // _.each
2271
+ module TestEach {
2272
+ let array : TResult [ ] ;
2273
+ let list : _ . List < TResult > ;
2274
+ let dictionary : _ . Dictionary < TResult > ;
2275
+
2276
+ let stringIterator : ( char : string , index : number , string : string ) => boolean | void ;
2277
+ let listIterator : ( value : TResult , index : number , collection : _ . List < TResult > ) => boolean | void ;
2278
+ let dictionaryIterator : ( value : TResult , key : string , collection : _ . Dictionary < TResult > ) => boolean | void ;
2279
+
2280
+ {
2281
+ let result : string ;
2282
+
2283
+ _ . each ( '' , stringIterator ) ;
2284
+ _ . each ( '' , stringIterator , any ) ;
2285
+ }
2286
+
2287
+ {
2288
+ let result : TResult [ ] ;
2289
+
2290
+ _ . each < TResult > ( array , listIterator ) ;
2291
+ _ . each < TResult > ( array , listIterator , any ) ;
2292
+ }
2293
+
2294
+ {
2295
+ let result : _ . List < TResult > ;
2296
+
2297
+ _ . each < TResult > ( list , listIterator ) ;
2298
+ _ . each < TResult > ( list , listIterator , any ) ;
2299
+ }
2300
+
2301
+ {
2302
+ let result : _ . Dictionary < TResult > ;
2303
+
2304
+ _ . each < TResult > ( dictionary , dictionaryIterator ) ;
2305
+ _ . each < TResult > ( dictionary , dictionaryIterator , any ) ;
2306
+ }
2307
+
2308
+ {
2309
+ let result : _ . LoDashImplicitWrapper < string > ;
2310
+
2311
+ _ ( '' ) . each ( stringIterator ) ;
2312
+ _ ( '' ) . each ( stringIterator , any ) ;
2313
+ }
2314
+
2315
+ {
2316
+ let result : _ . LoDashImplicitArrayWrapper < TResult > ;
2317
+
2318
+ _ ( array ) . each ( listIterator ) ;
2319
+ _ ( array ) . each ( listIterator , any ) ;
2320
+ }
2321
+
2322
+ {
2323
+ let result : _ . LoDashImplicitObjectWrapper < _ . List < TResult > > ;
2324
+
2325
+ _ ( list ) . each < TResult > ( listIterator ) ;
2326
+ _ ( list ) . each < TResult > ( listIterator , any ) ;
2327
+ }
2328
+
2329
+ {
2330
+ let result : _ . LoDashImplicitObjectWrapper < _ . Dictionary < TResult > > ;
2331
+
2332
+ _ ( dictionary ) . each < TResult > ( dictionaryIterator ) ;
2333
+ _ ( dictionary ) . each < TResult > ( dictionaryIterator , any ) ;
2334
+ }
2335
+
2336
+ {
2337
+ let result : _ . LoDashExplicitWrapper < string > ;
2338
+
2339
+ _ ( '' ) . chain ( ) . each ( stringIterator ) ;
2340
+ _ ( '' ) . chain ( ) . each ( stringIterator , any ) ;
2341
+ }
2342
+
2343
+ {
2344
+ let result : _ . LoDashExplicitArrayWrapper < TResult > ;
2345
+
2346
+ _ ( array ) . chain ( ) . each ( listIterator ) ;
2347
+ _ ( array ) . chain ( ) . each ( listIterator , any ) ;
2348
+ }
2349
+
2350
+ {
2351
+ let result : _ . LoDashExplicitObjectWrapper < _ . List < TResult > > ;
2352
+
2353
+ _ ( list ) . chain ( ) . each < TResult > ( listIterator ) ;
2354
+ _ ( list ) . chain ( ) . each < TResult > ( listIterator , any ) ;
2355
+ }
2356
+
2357
+ {
2358
+ let result : _ . LoDashExplicitObjectWrapper < _ . Dictionary < TResult > > ;
2359
+
2360
+ _ ( dictionary ) . chain ( ) . each < TResult > ( dictionaryIterator ) ;
2361
+ _ ( dictionary ) . chain ( ) . each < TResult > ( dictionaryIterator , any ) ;
2362
+ }
2363
+ }
2364
+
2270
2365
// _.every
2271
2366
module TestEvery {
2272
2367
let array : TResult [ ] ;
@@ -2422,19 +2517,100 @@ result = <number>_([1, 2, 3, 4]).findLast(function (num) {
2422
2517
result = < IFoodCombined > _ ( foodsCombined ) . findLast ( { 'type' : 'vegetable' } ) ;
2423
2518
result = < IFoodCombined > _ ( foodsCombined ) . findLast ( 'organic' ) ;
2424
2519
2425
- result = < number [ ] > _ . forEach ( [ 1 , 2 , 3 ] , function ( num ) { console . log ( num ) ; } ) ;
2426
- result = < _ . Dictionary < number > > _ . forEach ( { 'one' : 1 , 'two' : 2 , 'three' : 3 } , function ( num ) { console . log ( num ) ; } ) ;
2427
- result = < IFoodType > _ . forEach < IFoodType , string > ( { name : 'apple' , type : 'fruit' } , function ( value , key ) { console . log ( value , key ) } ) ;
2520
+ // _.forEach
2521
+ module TestForEach {
2522
+ let array : TResult [ ] ;
2523
+ let list : _ . List < TResult > ;
2524
+ let dictionary : _ . Dictionary < TResult > ;
2525
+
2526
+ let stringIterator : ( char : string , index : number , string : string ) => boolean | void ;
2527
+ let listIterator : ( value : TResult , index : number , collection : _ . List < TResult > ) => boolean | void ;
2528
+ let dictionaryIterator : ( value : TResult , key : string , collection : _ . Dictionary < TResult > ) => boolean | void ;
2529
+
2530
+ {
2531
+ let result : string ;
2532
+
2533
+ _ . forEach ( '' , stringIterator ) ;
2534
+ _ . forEach ( '' , stringIterator , any ) ;
2535
+ }
2536
+
2537
+ {
2538
+ let result : TResult [ ] ;
2539
+
2540
+ _ . forEach < TResult > ( array , listIterator ) ;
2541
+ _ . forEach < TResult > ( array , listIterator , any ) ;
2542
+ }
2543
+
2544
+ {
2545
+ let result : _ . List < TResult > ;
2546
+
2547
+ _ . forEach < TResult > ( list , listIterator ) ;
2548
+ _ . forEach < TResult > ( list , listIterator , any ) ;
2549
+ }
2550
+
2551
+ {
2552
+ let result : _ . Dictionary < TResult > ;
2553
+
2554
+ _ . forEach < TResult > ( dictionary , dictionaryIterator ) ;
2555
+ _ . forEach < TResult > ( dictionary , dictionaryIterator , any ) ;
2556
+ }
2557
+
2558
+ {
2559
+ let result : _ . LoDashImplicitWrapper < string > ;
2560
+
2561
+ _ ( '' ) . forEach ( stringIterator ) ;
2562
+ _ ( '' ) . forEach ( stringIterator , any ) ;
2563
+ }
2564
+
2565
+ {
2566
+ let result : _ . LoDashImplicitArrayWrapper < TResult > ;
2428
2567
2429
- result = < number [ ] > _ . each ( [ 1 , 2 , 3 ] , function ( num ) { console . log ( num ) ; } ) ;
2430
- result = < _ . Dictionary < number > > _ . each ( { 'one' : 1 , 'two' : 2 , 'three' : 3 } , function ( num ) { console . log ( num ) ; } ) ;
2431
- result = < IFoodType > _ . each < IFoodType , string > ( { name : 'apple' , type : 'fruit' } , function ( value , key ) { console . log ( value , key ) } ) ;
2568
+ _ ( array ) . forEach ( listIterator ) ;
2569
+ _ ( array ) . forEach ( listIterator , any ) ;
2570
+ }
2571
+
2572
+ {
2573
+ let result : _ . LoDashImplicitObjectWrapper < _ . List < TResult > > ;
2574
+
2575
+ _ ( list ) . forEach < TResult > ( listIterator ) ;
2576
+ _ ( list ) . forEach < TResult > ( listIterator , any ) ;
2577
+ }
2578
+
2579
+ {
2580
+ let result : _ . LoDashImplicitObjectWrapper < _ . Dictionary < TResult > > ;
2581
+
2582
+ _ ( dictionary ) . forEach < TResult > ( dictionaryIterator ) ;
2583
+ _ ( dictionary ) . forEach < TResult > ( dictionaryIterator , any ) ;
2584
+ }
2585
+
2586
+ {
2587
+ let result : _ . LoDashExplicitWrapper < string > ;
2588
+
2589
+ _ ( '' ) . chain ( ) . forEach ( stringIterator ) ;
2590
+ _ ( '' ) . chain ( ) . forEach ( stringIterator , any ) ;
2591
+ }
2592
+
2593
+ {
2594
+ let result : _ . LoDashExplicitArrayWrapper < TResult > ;
2595
+
2596
+ _ ( array ) . chain ( ) . forEach ( listIterator ) ;
2597
+ _ ( array ) . chain ( ) . forEach ( listIterator , any ) ;
2598
+ }
2599
+
2600
+ {
2601
+ let result : _ . LoDashExplicitObjectWrapper < _ . List < TResult > > ;
2602
+
2603
+ _ ( list ) . chain ( ) . forEach < TResult > ( listIterator ) ;
2604
+ _ ( list ) . chain ( ) . forEach < TResult > ( listIterator , any ) ;
2605
+ }
2432
2606
2433
- result = < _ . LoDashImplicitArrayWrapper < number > > _ ( [ 1 , 2 , 3 ] ) . forEach ( function ( num ) { console . log ( num ) ; } ) ;
2434
- result = < _ . LoDashImplicitObjectWrapper < _ . Dictionary < number > > > _ ( < { [ index : string ] : number ; } > { 'one' : 1 , 'two' : 2 , 'three' : 3 } ) . forEach ( function ( num ) { console . log ( num ) ; } ) ;
2607
+ {
2608
+ let result : _ . LoDashExplicitObjectWrapper < _ . Dictionary < TResult > > ;
2435
2609
2436
- result = < _ . LoDashImplicitArrayWrapper < number > > _ ( [ 1 , 2 , 3 ] ) . each ( function ( num ) { console . log ( num ) ; } ) ;
2437
- result = < _ . LoDashImplicitObjectWrapper < _ . Dictionary < number > > > _ ( < { [ index : string ] : number ; } > { 'one' : 1 , 'two' : 2 , 'three' : 3 } ) . each ( function ( num ) { console . log ( num ) ; } ) ;
2610
+ _ ( dictionary ) . chain ( ) . forEach < TResult > ( dictionaryIterator ) ;
2611
+ _ ( dictionary ) . chain ( ) . forEach < TResult > ( dictionaryIterator , any ) ;
2612
+ }
2613
+ }
2438
2614
2439
2615
result = < number [ ] > _ . forEachRight ( [ 1 , 2 , 3 ] , function ( num ) { console . log ( num ) ; } ) ;
2440
2616
result = < _ . Dictionary < number > > _ . forEachRight ( { 'one' : 1 , 'two' : 2 , 'three' : 3 } , function ( num ) { console . log ( num ) ; } ) ;
@@ -2788,18 +2964,10 @@ done = _.after(saves.length, function () {
2788
2964
console . log ( 'Done saving!' ) ;
2789
2965
} ) ;
2790
2966
2791
- _ . forEach ( saves , function ( type ) {
2792
- asyncSave ( { 'type' : type , 'complete' : done } ) ;
2793
- } ) ;
2794
-
2795
2967
done = _ ( saves . length ) . after ( function ( ) {
2796
2968
console . log ( 'Done saving!' ) ;
2797
2969
} ) . value ( ) ;
2798
2970
2799
- _ . forEach ( saves , function ( type ) {
2800
- asyncSave ( { 'type' : type , 'complete' : done } ) ;
2801
- } ) ;
2802
-
2803
2971
// _.ary
2804
2972
result = < number [ ] > [ '6' , '8' , '10' ] . map ( _ . ary < ( s : string ) => number > ( parseInt , 1 ) ) ;
2805
2973
result = < number [ ] > [ '6' , '8' , '10' ] . map ( _ ( parseInt ) . ary < ( s : string ) => number > ( 1 ) . value ( ) ) ;
0 commit comments