|
1 | | -Modern-Linq |
| 1 | +Fluent-Iter |
2 | 2 | ------- |
3 | | -Modern-Linq is a library that brings the C# linq functionality into JavaScript. It is based on the native Iterable funtionality in JavaScript. |
| 3 | +Fluent-Iter is a library that allows you to work with iterables in a fluent way. |
| 4 | +It is full written in TypeScript and has no dependencies. |
4 | 5 |
|
5 | 6 | Examples: |
6 | 7 | ```js |
@@ -39,75 +40,69 @@ for (const item of query) { |
39 | 40 | ``` |
40 | 41 | Remarks: |
41 | 42 |
|
42 | | -1. The data is processed in the moment when is requested. |
| 43 | +1. The data is processed at the moment when is requested. |
43 | 44 | 2. The sequence is immutable the output !== input |
44 | 45 |
|
| 46 | +Operators: |
45 | 47 |
|
46 | | -Some of the methods are using native Array implementation if the provided source is an Array |
47 | | -Methods with native fallback: |
48 | | -- `select`: uses Array.prototype.map |
49 | | -- `where`: uses Array.prototype.filter |
50 | | -- `take`: uses Array.prototype.slice |
51 | | -- `skip`: uses Array.prototype.slice |
52 | | -- `distinct`: if no comparer is provided it uses native Set class |
53 | | -- `count`: returns Array.prototype.length |
54 | | -- `orderBy`: Array.prototype.sort |
55 | | -- `concat`: uses spread operator |
| 48 | +Transformers |
| 49 | +- where : filter iterable by predicate |
| 50 | +- select : transform iterable using mapping function |
| 51 | +- selectMany : flatten an iterable and can transform it to another iterable |
| 52 | +- ofType : produces typed iterable, used to filter by type |
| 53 | +- ofClass: filters iterable for elements of a given class |
| 54 | +- orderBy : Order iterable ascending by a key |
| 55 | +- orderByDescending : Order iterable descending by a key |
| 56 | +- groupJoin: Do a group join (left join) between current and external iterable. For each item of current sequence get array of items from external sequence. |
| 57 | +- join: Do an inner join between current and external sequence. For each item of current sequence get a item from external sequence. |
| 58 | +- page: Split iterable into chunks of a given size. |
| 59 | +- reverse: Reverse iterable. |
56 | 60 |
|
57 | | -Methods implemented: |
58 | | -- `aggregate` |
59 | | -- `any` |
60 | | -- `all` |
61 | | -- `concat` |
62 | | -- `count` |
63 | | -- `distinct` |
64 | | -- `elementAt` |
65 | | -- `first` |
66 | | -- `firstOrDefault` |
67 | | -- `groupJoin` |
68 | | -- `join` |
69 | | -- `intersect` |
70 | | -- `last` |
71 | | -- `lastOrDefault` |
72 | | -- `max` |
73 | | -- `min` |
74 | | -- `ofType` |
75 | | -- `orderBy` |
76 | | -- `range` |
77 | | -- `repeat` |
78 | | -- `reverse` |
79 | | -- `select` |
80 | | -- `selectMany` |
81 | | -- `isEqual` ( sequenceEqual ) |
82 | | -- `single` |
83 | | -- `skip` |
84 | | -- `skipLast` |
85 | | -- `skipWhile` |
86 | | -- `sum` |
87 | | -- `take` |
88 | | -- `takeLast` |
89 | | -- `takeWhile` |
90 | | -- `union` |
91 | | -- `where` |
| 61 | +Slicing |
| 62 | +- take : take first n elements |
| 63 | +- takeWhile : take elements while predicate is true |
| 64 | +- takeLast : take last n elements |
| 65 | +- skip : skip first n elements |
| 66 | +- skipWhile : skip elements while predicate is true |
| 67 | +- skipLast : skip last n elements |
92 | 68 |
|
93 | | -- `toArray` ( toList ) |
94 | | -- `toMap` ( toDictionary ) |
95 | | -- `toSet` |
| 69 | +Combinations: |
| 70 | +- concat: Concat this iterable with another |
| 71 | +- distinct: removes duplicate elements |
| 72 | +- zip: zip two iterables together, where the result is an iterable of tuples, finishes when one of the iterables is finished. |
| 73 | +- union: Produce a union of two iterables where the result is distinct values from both. |
| 74 | +- intersect: Return an intersection of two iterables where the result is distinct values. |
| 75 | +- difference: Return elements from the first iterable that are not in the second. Only distinct values are returned. |
| 76 | +- except: Return elements from the first iterable that are not in the second. (TODO) |
| 77 | +- symmetricDifference: Return a symmetric difference ( distinct values except intersection ) of two iterables where the result is distinct values. |
96 | 78 |
|
97 | | -Waiting for implementation: |
98 | | -- `contains` |
99 | | -- `except` |
100 | | -- `zip` |
| 79 | +Aggregators: |
| 80 | +- toArray(): convert iterable to array |
| 81 | +- toMap(): Create a map object from sequence |
| 82 | +- toSet(): Creates a set from current sequence |
| 83 | +- first : first element in iterable or first element that satisfies predicate |
| 84 | +- firstOrDefault: like first but with default value |
| 85 | +- firstOrThrows: like first but throws if no element is found |
| 86 | +- firstIndex: like first but returns index of element |
| 87 | +- last: last element in iterable or last element that satisfies predicate |
| 88 | +- lastOrDefault: like last but with default value |
| 89 | +- lastOrThrows: like last but throws if no element is found |
| 90 | +- lastIndex: like last but returns index of element |
| 91 | +- single: single element in iterable or single element that satisfies predicate. Throws if more than one element is found. |
| 92 | +- singleOrDefault: like single but with default value when nothing found. Throws if more than one element is found. |
| 93 | +- all: check if all elements in iterable satisfy predicate |
| 94 | +- allAndEvery: like all but requires to have at least one element |
| 95 | +- any: check if at least one element in iterable satisfies predicate |
| 96 | +- count: count elements in iterable or count of elements that satisfy predicate |
| 97 | +- aggregate: Produce single value form sequence values. The initial value is the second argument. |
| 98 | +- sum: Sum all elements in iterable |
| 99 | +- product: Multiply all elements in iterable |
| 100 | +- min: Get minimum value in iterable |
| 101 | +- max: Get maximum value in iterable |
| 102 | +- join: join all items from iterable with string concatenation |
| 103 | +- elementAt: get element at index |
101 | 104 |
|
102 | | -Extra methods |
103 | | -- `isElementsEqual`: checks if two sequences have same elements, no matter of the position. |
104 | | -- `product`: get the product of sequence. |
105 | | -- `join` (with string argument): join all elements of sequence and concat with separator |
106 | | -- `allAndEvery`: check a condition against all elements of sequence and sequence should not be empty. |
107 | | -- `firstOrThrow`: returns first element if none throw error. |
108 | | -- `lastOrThrow`: returns last element if none throw error. |
109 | | -- `fistIndex`: return index of first element which is true for a predicate |
110 | | -- `lastIndex`: return index of last element which is true for a predicate |
111 | | - |
112 | | -Build status: |
113 | | -[](https://travis-ci.com/Indomitable/modern-linq) |
| 105 | +Misc: |
| 106 | +- forEach: iterate over iterable and execute a function for each element |
| 107 | +- isEqual: check if two iterables are equal. Same elements and order. |
| 108 | +- isElementsEqual: check if two iterables are equal. Same elements but order can be different. |
0 commit comments