@@ -97,6 +97,17 @@ var array = ["item1", "item2", "item3", "item4", "no"];
9797array .Get (2 );
9898```
9999
100+ ### Repeat
101+
102+ Repeats an object in the array
103+
104+ ``` javascript
105+ var array = [" item1" , " item2" , " item3" , " item4" ];
106+
107+ // ["item1", "item2", "item3", "item4", "example", "example", "example"]
108+ array .Repeat (" example" , 3 );
109+ ```
110+
100111### ForEach
101112
102113Executes a method for each item in the array
@@ -225,6 +236,22 @@ array.Count();
225236array .Count (" i => i.match(/item/gi)" );
226237```
227238
239+ ### SequenceEqual
240+
241+ Compares to sequences of objects
242+
243+ ``` javascript
244+ var array = [" item1" , " item2" , " item3" ];
245+ var array2 = [" item1" , " item2" , " item3" ];
246+ var array3 = [" item" , " item2" , " item3" ];
247+
248+ // true
249+ array .SequenceEqual (array2);
250+
251+ // false
252+ array .SequenceEqual (array3);
253+ ```
254+
228255### Any
229256
230257Tests if any item is in the array and if set matches the filter
@@ -276,6 +303,30 @@ var array2 = ["item4", "no"];
276303array .Concat (array2);
277304```
278305
306+ ### Intersect
307+
308+ Combines two arrays but only applies values that are in both arrays
309+
310+ ``` javascript
311+ var array = [" item1" , " item2" , " item3" ];
312+ var array2 = [" item1" , " unique" , " item2" , " item3" ];
313+
314+ // ["item1", "item2", "item3"]
315+ array .Intersect (array2);
316+ ```
317+
318+ ### Union
319+
320+ Combines two arrays without duplicates
321+
322+ ``` javascript
323+ var array = [" item1" , " item2" , " item3" ];
324+ var array2 = [" item1" , " unique" , " item2" , " item3" ];
325+
326+ // ["item1", "item2", "item3", "unique"]
327+ array .Union (array2);
328+ ```
329+
279330### Join
280331
281332Joins the entries by the given char
@@ -292,7 +343,7 @@ array.Join("-", "x => x.length > 2");
292343
293344### Aggregate
294345
295- Combines the entries by your definition
346+ Combines the entries using a custom function
296347
297348``` javascript
298349var array = [" item1" , " item2" , " item3" , " item4" , " no" ];
@@ -301,6 +352,32 @@ var array = ["item1", "item2", "item3", "item4", "no"];
301352array .Aggregate (" (str, item) => item + '-' + item" );
302353```
303354
355+ ### ToDictionary
356+
357+ Converts the array to a dictionary
358+
359+ ``` javascript
360+ var array = [{OtherId: 1 , Value: " item1" }, {OtherId: 2 , Value: " item2" }];
361+
362+ // {1: {OtherId: 1, Value: "item1"}, 2: {OtherId: 2, Value: "item2"}}
363+ array .ToDictionary (" x => x.OtherId" );
364+
365+ // {1: "item1", 2: "item2"}
366+ array .ToDictionary (" x => x.OtherId" , " x => x.Value" );
367+ ```
368+
369+ ### Zip
370+
371+ Combines the entries of two arrays using a custom function
372+
373+ ``` javascript
374+ var array = [0 , 1 , 2 , 3 , 4 ];
375+ var array2 = [" zero" , " one" , " two" , " three" ];
376+
377+ // ["0 zero", "1 one", "2 two", "3 three"]
378+ array .Zip (array2, " (x, y) => x + ' ' + y" );
379+ ```
380+
304381### Reverse
305382
306383Reverses the array
@@ -386,6 +463,22 @@ array.FirstOrDefault("i => i.match(/item/gi)");
386463array .First (" i => i == 'notgiven'" );
387464```
388465
466+ ### Min
467+
468+ Returns the smallest element in array
469+
470+ ``` javascript
471+ var array = [0 , 8 , 1 , 5 , - 3 ];
472+
473+ // -3
474+ array .Min ();
475+
476+ var array = [{name: " test" , age: 3 }, {name: " test2" , age: 18 }];
477+
478+ // {name: "test", age: 3}
479+ array .Min (" x => x.age" );
480+ ```
481+
389482### Last
390483
391484Returns the Last item of the array and if a filter was set the last item that matches the filter - Throws an Exception if no item was found
@@ -420,6 +513,22 @@ array.LastOrDefault("i => i.match(/item/gi)");
420513array .LastOrDefault (" i => i == 'notgiven'" );
421514```
422515
516+ ### Max
517+
518+ Returns the greates element in array
519+
520+ ``` javascript
521+ var array = [0 , 8 , 1 , 5 , - 3 ];
522+
523+ // 8
524+ array .Max ();
525+
526+ var array = [{name: " test" , age: 3 }, {name: " test2" , age: 18 }];
527+
528+ // {name: "test2", age: 18}
529+ array .Max (" x => x.age" );
530+ ```
531+
423532### Select
424533
425534Select the properties for a new array
@@ -445,6 +554,41 @@ var array = ["item1", "item2", "item3", "item4"];
445554array .Take (2 );
446555```
447556
557+ ### TakeWhile
558+
559+ Takes entries as long as a condition is true
560+
561+ ``` javascript
562+ var array = [" item1" , " item2" , " item3" , " item2" , " item4" ];
563+ var item2count = 0 ;
564+
565+ // ["item1", "item2", "item3"]
566+ array .TakeWhile (function (x ){
567+ if (x == " item2" ){
568+ item2count++ ;
569+ }
570+
571+ return item2count < 2 ;
572+ });
573+ ```
574+
575+ This is the basic usage. But if you want conditional executes for e.g. with counting this can get a little bit messy.
576+
577+ ``` javascript
578+ var array = [" item1" , " item2" , " item3" , " item2" , " item4" ];
579+
580+ // ["item1", "item2", "item3"]
581+ array .TakeWhile (function (item , storage ){
582+ return item != " item2" || storage .count < 1 ; // Condition
583+ }, function (storage ){
584+ storage .count = 0 ; // Init the Storage
585+ }, function (item , storage ){
586+ if (item == " item2" ){
587+ storage .count ++ ; // After executing the condition
588+ }
589+ });
590+ ```
591+
448592### Skip
449593
450594Skips entries
0 commit comments