You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Linq methods for JavaScript/TypeScript for working with Arrays
3
+
Linq methods for JavaScript/TypeScript for working with arrays
4
4
5
-
This simple Extension works with array of complex Objects as well as simple arrays of strings etc. The whole thing is written in TypeScript but also usable in JavaScript
5
+
This simple extension works with array of complex objects as well as simple arrays of strings etc. The whole thing is written in TypeScript but also usable in JavaScript
6
6
7
7
## Advantages
8
8
9
-
This Extension is lightweight and fast and you can use your Lambda-Expression-Syntax to work with Arrays. The methods are mostly identically to .NET methods.
9
+
This extension is lightweight and fast and you can use your Lambda-Expression-Syntax to work with arrays. The methods are mostly identically to .NET methods.
10
10
11
-
As Expressions you can use the normal Function-Syntax:
11
+
As expressions you can use the normal Function-Syntax:
12
12
13
13
```javascript
14
14
array.Where(function(x){
@@ -28,7 +28,21 @@ or Lambda-Expressions as Strings (this Syntax works in IE):
28
28
array.Where("x => x.Name == 'Max'");
29
29
```
30
30
31
-
Conclusion:
31
+
### SQL-Like
32
+
33
+
Also a complete procedure as an sql-like string is supported
34
+
35
+
```
36
+
clone
37
+
reverse
38
+
where x => x.Age > 70
39
+
order by x => x.Name
40
+
then by x => x.FirstName descending
41
+
for each x => console.log(x)
42
+
select x => {x.Name}
43
+
```
44
+
45
+
### Conclusion
32
46
33
47
* Works with multiple Browsers (even IE)
34
48
* Angular Support (event directly in Views if using Strings as Expression-Syntax)
| ForEach | for each | for each x => console.log(x) |
770
+
| Count || count x => x.Id |
771
+
| All || all x => x.Age > 4 |
772
+
| Any || any x => x.Age > 4 |
773
+
| Take || take 3 |
774
+
| Skip || skip 3 |
775
+
| Min || min x => x.Age |
776
+
| Max || max x => x.Age |
777
+
| GroupBy | group by | group by x => x.Name |
778
+
| Distinct || distinct x => x.Id |
779
+
| FindLastIndex | find last index<br>find index ... last<br>findindex ... last | find index x => x.Age == 3 last |
780
+
| FindIndex | find index<br>find first index<br>findfirstindex<br>find index ... first<br>findindex ... first | find index x => x.Age == 3 first |
781
+
| OrderByDescending | order by ... descending<br>orderby ... descending<br>orderby descending<br>order by descending<br>orderbydescending | order by x => x.Age descending |
782
+
| OrderBy | order by ... ascending<br>orderby ... ascending<br>orderby ascending<br>order by ascending<br>orderbyascending<br>order by<br>orderby | order by x => x.Age ascending |
783
+
| FirstOrDefault | first or default | first or default |
784
+
| LastOrDefault | last or default | last or default |
785
+
| First || first |
786
+
| Last || last |
787
+
| ThenByDescending | thenby ... descending<br>then by ... descending<br>thenbydescending<br>then by descending | then by x => x.Name descending |
788
+
| ThenBy | thenby ... ascending<br>then by ... ascending<br>thenbyascending<br>then byascending<br>thenby<br>then by | then by x => x.Name ascending |
0 commit comments