@@ -2306,6 +2306,101 @@ module TestDetect {
2306
2306
result = _ ( dictionary ) . detect < { a : number } , TResult > ( { a : 42 } ) ;
2307
2307
}
2308
2308
2309
+ // _.each
2310
+ module TestEach {
2311
+ let array : TResult [ ] ;
2312
+ let list : _ . List < TResult > ;
2313
+ let dictionary : _ . Dictionary < TResult > ;
2314
+
2315
+ let stringIterator : ( char : string , index : number , string : string ) => boolean | void ;
2316
+ let listIterator : ( value : TResult , index : number , collection : _ . List < TResult > ) => boolean | void ;
2317
+ let dictionaryIterator : ( value : TResult , key : string , collection : _ . Dictionary < TResult > ) => boolean | void ;
2318
+
2319
+ {
2320
+ let result : string ;
2321
+
2322
+ _ . each ( '' , stringIterator ) ;
2323
+ _ . each ( '' , stringIterator , any ) ;
2324
+ }
2325
+
2326
+ {
2327
+ let result : TResult [ ] ;
2328
+
2329
+ _ . each < TResult > ( array , listIterator ) ;
2330
+ _ . each < TResult > ( array , listIterator , any ) ;
2331
+ }
2332
+
2333
+ {
2334
+ let result : _ . List < TResult > ;
2335
+
2336
+ _ . each < TResult > ( list , listIterator ) ;
2337
+ _ . each < TResult > ( list , listIterator , any ) ;
2338
+ }
2339
+
2340
+ {
2341
+ let result : _ . Dictionary < TResult > ;
2342
+
2343
+ _ . each < TResult > ( dictionary , dictionaryIterator ) ;
2344
+ _ . each < TResult > ( dictionary , dictionaryIterator , any ) ;
2345
+ }
2346
+
2347
+ {
2348
+ let result : _ . LoDashImplicitWrapper < string > ;
2349
+
2350
+ _ ( '' ) . each ( stringIterator ) ;
2351
+ _ ( '' ) . each ( stringIterator , any ) ;
2352
+ }
2353
+
2354
+ {
2355
+ let result : _ . LoDashImplicitArrayWrapper < TResult > ;
2356
+
2357
+ _ ( array ) . each ( listIterator ) ;
2358
+ _ ( array ) . each ( listIterator , any ) ;
2359
+ }
2360
+
2361
+ {
2362
+ let result : _ . LoDashImplicitObjectWrapper < _ . List < TResult > > ;
2363
+
2364
+ _ ( list ) . each < TResult > ( listIterator ) ;
2365
+ _ ( list ) . each < TResult > ( listIterator , any ) ;
2366
+ }
2367
+
2368
+ {
2369
+ let result : _ . LoDashImplicitObjectWrapper < _ . Dictionary < TResult > > ;
2370
+
2371
+ _ ( dictionary ) . each < TResult > ( dictionaryIterator ) ;
2372
+ _ ( dictionary ) . each < TResult > ( dictionaryIterator , any ) ;
2373
+ }
2374
+
2375
+ {
2376
+ let result : _ . LoDashExplicitWrapper < string > ;
2377
+
2378
+ _ ( '' ) . chain ( ) . each ( stringIterator ) ;
2379
+ _ ( '' ) . chain ( ) . each ( stringIterator , any ) ;
2380
+ }
2381
+
2382
+ {
2383
+ let result : _ . LoDashExplicitArrayWrapper < TResult > ;
2384
+
2385
+ _ ( array ) . chain ( ) . each ( listIterator ) ;
2386
+ _ ( array ) . chain ( ) . each ( listIterator , any ) ;
2387
+ }
2388
+
2389
+ {
2390
+ let result : _ . LoDashExplicitObjectWrapper < _ . List < TResult > > ;
2391
+
2392
+ _ ( list ) . chain ( ) . each < TResult > ( listIterator ) ;
2393
+ _ ( list ) . chain ( ) . each < TResult > ( listIterator , any ) ;
2394
+ }
2395
+
2396
+ {
2397
+ let result : _ . LoDashExplicitObjectWrapper < _ . Dictionary < TResult > > ;
2398
+
2399
+ _ ( dictionary ) . chain ( ) . each < TResult > ( dictionaryIterator ) ;
2400
+ _ ( dictionary ) . chain ( ) . each < TResult > ( dictionaryIterator , any ) ;
2401
+ }
2402
+ }
2403
+
2309
2404
// _.every
2310
2405
module TestEvery {
2311
2406
let array : TResult [ ] ;
@@ -2461,19 +2556,100 @@ result = <number>_([1, 2, 3, 4]).findLast(function (num) {
2461
2556
result = < IFoodCombined > _ ( foodsCombined ) . findLast ( { 'type' : 'vegetable' } ) ;
2462
2557
result = < IFoodCombined > _ ( foodsCombined ) . findLast ( 'organic' ) ;
2463
2558
2464
- result = < number [ ] > _ . forEach ( [ 1 , 2 , 3 ] , function ( num ) { console . log ( num ) ; } ) ;
2465
- result = < _ . Dictionary < number > > _ . forEach ( { 'one' : 1 , 'two' : 2 , 'three' : 3 } , function ( num ) { console . log ( num ) ; } ) ;
2466
- result = < IFoodType > _ . forEach < IFoodType , string > ( { name : 'apple' , type : 'fruit' } , function ( value , key ) { console . log ( value , key ) } ) ;
2559
+ // _.forEach
2560
+ module TestForEach {
2561
+ let array : TResult [ ] ;
2562
+ let list : _ . List < TResult > ;
2563
+ let dictionary : _ . Dictionary < TResult > ;
2564
+
2565
+ let stringIterator : ( char : string , index : number , string : string ) => boolean | void ;
2566
+ let listIterator : ( value : TResult , index : number , collection : _ . List < TResult > ) => boolean | void ;
2567
+ let dictionaryIterator : ( value : TResult , key : string , collection : _ . Dictionary < TResult > ) => boolean | void ;
2568
+
2569
+ {
2570
+ let result : string ;
2571
+
2572
+ _ . forEach ( '' , stringIterator ) ;
2573
+ _ . forEach ( '' , stringIterator , any ) ;
2574
+ }
2575
+
2576
+ {
2577
+ let result : TResult [ ] ;
2578
+
2579
+ _ . forEach < TResult > ( array , listIterator ) ;
2580
+ _ . forEach < TResult > ( array , listIterator , any ) ;
2581
+ }
2582
+
2583
+ {
2584
+ let result : _ . List < TResult > ;
2585
+
2586
+ _ . forEach < TResult > ( list , listIterator ) ;
2587
+ _ . forEach < TResult > ( list , listIterator , any ) ;
2588
+ }
2589
+
2590
+ {
2591
+ let result : _ . Dictionary < TResult > ;
2592
+
2593
+ _ . forEach < TResult > ( dictionary , dictionaryIterator ) ;
2594
+ _ . forEach < TResult > ( dictionary , dictionaryIterator , any ) ;
2595
+ }
2596
+
2597
+ {
2598
+ let result : _ . LoDashImplicitWrapper < string > ;
2599
+
2600
+ _ ( '' ) . forEach ( stringIterator ) ;
2601
+ _ ( '' ) . forEach ( stringIterator , any ) ;
2602
+ }
2603
+
2604
+ {
2605
+ let result : _ . LoDashImplicitArrayWrapper < TResult > ;
2467
2606
2468
- result = < number [ ] > _ . each ( [ 1 , 2 , 3 ] , function ( num ) { console . log ( num ) ; } ) ;
2469
- result = < _ . Dictionary < number > > _ . each ( { 'one' : 1 , 'two' : 2 , 'three' : 3 } , function ( num ) { console . log ( num ) ; } ) ;
2470
- result = < IFoodType > _ . each < IFoodType , string > ( { name : 'apple' , type : 'fruit' } , function ( value , key ) { console . log ( value , key ) } ) ;
2607
+ _ ( array ) . forEach ( listIterator ) ;
2608
+ _ ( array ) . forEach ( listIterator , any ) ;
2609
+ }
2610
+
2611
+ {
2612
+ let result : _ . LoDashImplicitObjectWrapper < _ . List < TResult > > ;
2613
+
2614
+ _ ( list ) . forEach < TResult > ( listIterator ) ;
2615
+ _ ( list ) . forEach < TResult > ( listIterator , any ) ;
2616
+ }
2617
+
2618
+ {
2619
+ let result : _ . LoDashImplicitObjectWrapper < _ . Dictionary < TResult > > ;
2620
+
2621
+ _ ( dictionary ) . forEach < TResult > ( dictionaryIterator ) ;
2622
+ _ ( dictionary ) . forEach < TResult > ( dictionaryIterator , any ) ;
2623
+ }
2624
+
2625
+ {
2626
+ let result : _ . LoDashExplicitWrapper < string > ;
2627
+
2628
+ _ ( '' ) . chain ( ) . forEach ( stringIterator ) ;
2629
+ _ ( '' ) . chain ( ) . forEach ( stringIterator , any ) ;
2630
+ }
2631
+
2632
+ {
2633
+ let result : _ . LoDashExplicitArrayWrapper < TResult > ;
2634
+
2635
+ _ ( array ) . chain ( ) . forEach ( listIterator ) ;
2636
+ _ ( array ) . chain ( ) . forEach ( listIterator , any ) ;
2637
+ }
2638
+
2639
+ {
2640
+ let result : _ . LoDashExplicitObjectWrapper < _ . List < TResult > > ;
2641
+
2642
+ _ ( list ) . chain ( ) . forEach < TResult > ( listIterator ) ;
2643
+ _ ( list ) . chain ( ) . forEach < TResult > ( listIterator , any ) ;
2644
+ }
2471
2645
2472
- result = < _ . LoDashImplicitArrayWrapper < number > > _ ( [ 1 , 2 , 3 ] ) . forEach ( function ( num ) { console . log ( num ) ; } ) ;
2473
- result = < _ . LoDashImplicitObjectWrapper < _ . Dictionary < number > > > _ ( < { [ index : string ] : number ; } > { 'one' : 1 , 'two' : 2 , 'three' : 3 } ) . forEach ( function ( num ) { console . log ( num ) ; } ) ;
2646
+ {
2647
+ let result : _ . LoDashExplicitObjectWrapper < _ . Dictionary < TResult > > ;
2474
2648
2475
- result = < _ . LoDashImplicitArrayWrapper < number > > _ ( [ 1 , 2 , 3 ] ) . each ( function ( num ) { console . log ( num ) ; } ) ;
2476
- result = < _ . LoDashImplicitObjectWrapper < _ . Dictionary < number > > > _ ( < { [ index : string ] : number ; } > { 'one' : 1 , 'two' : 2 , 'three' : 3 } ) . each ( function ( num ) { console . log ( num ) ; } ) ;
2649
+ _ ( dictionary ) . chain ( ) . forEach < TResult > ( dictionaryIterator ) ;
2650
+ _ ( dictionary ) . chain ( ) . forEach < TResult > ( dictionaryIterator , any ) ;
2651
+ }
2652
+ }
2477
2653
2478
2654
result = < number [ ] > _ . forEachRight ( [ 1 , 2 , 3 ] , function ( num ) { console . log ( num ) ; } ) ;
2479
2655
result = < _ . Dictionary < number > > _ . forEachRight ( { 'one' : 1 , 'two' : 2 , 'three' : 3 } , function ( num ) { console . log ( num ) ; } ) ;
@@ -2851,18 +3027,10 @@ done = _.after(saves.length, function () {
2851
3027
console . log ( 'Done saving!' ) ;
2852
3028
} ) ;
2853
3029
2854
- _ . forEach ( saves , function ( type ) {
2855
- asyncSave ( { 'type' : type , 'complete' : done } ) ;
2856
- } ) ;
2857
-
2858
3030
done = _ ( saves . length ) . after ( function ( ) {
2859
3031
console . log ( 'Done saving!' ) ;
2860
3032
} ) . value ( ) ;
2861
3033
2862
- _ . forEach ( saves , function ( type ) {
2863
- asyncSave ( { 'type' : type , 'complete' : done } ) ;
2864
- } ) ;
2865
-
2866
3034
// _.ary
2867
3035
result = < number [ ] > [ '6' , '8' , '10' ] . map ( _ . ary < ( s : string ) => number > ( parseInt , 1 ) ) ;
2868
3036
result = < number [ ] > [ '6' , '8' , '10' ] . map ( _ ( parseInt ) . ary < ( s : string ) => number > ( 1 ) . value ( ) ) ;
0 commit comments