A sample collection of TypeScript 's Array extension method.
- Node.js 14.x
- TypeScript 4.5.x
- jest 27.x (Unit Test)
| Extension Method | TypeScript file | C# LINQ | Overview |
|---|---|---|---|
| select | ./src/ext/array/alias-linq.ts | Select | Project each element of the array to a new array. |
| where | ./src/ext/array/alias-linq.ts | Where | Extract the array under specified conditions. |
| all | ./src/ext/array/alias-linq.ts | All | Determines whether all elements of the array satisfy the condition. |
| skip | ./src/ext/array/alias-linq.ts | Skip | Skips the specified number of elements from the beginning and returns the remaining array. |
| take | ./src/ext/array/alias-linq.ts | Take | Returns the specified number of elements from the beginning of the array. |
| any | ./src/ext/array/any.ts | Any | True if there is even one case that matches the condition |
| sum | ./src/ext/array/calc.ts | Sum | Gets the total value of numeric array. |
| average | ./src/ext/array/calc.ts | Average | Gets the average value of numeric array. |
| max | ./src/ext/array/calc.ts | Max | Get the maximum value of a numeric array. |
| min | ./src/ext/array/calc.ts | Min | Get the minimum value of a numeric array. |
| deepCopy | ./src/ext/array/deep-copy.ts | - | Deep copy the Array. |
| distinct | ./src/ext/array/distinct.ts | Distinct | Remove array duplication. |
| distinctBy | ./src/ext/array/distinct.ts | - | We will eliminate duplicates from arrays by comparing judgment targets. |
| equalTo | ./src/ext/array/equal-to.ts | - | True if the contents of the array are the same |
| first | ./src/ext/array/first.ts | First | Get the first data of the array. |
| last | ./src/ext/array/last.ts | Last | Get the last data of the array. |
| orderBy | ./src/ext/array/orderby.ts | - | Sort based on the specified sort item. |
| selectMany | ./src/ext/array/select-many.ts | SelectMany | Combine the values returned by callbackfn and return them as an array. |
| toLookup | ./src/ext/array/to-lookup.ts | ToLookup | Convert array to Map<K, V[]> |
| toMap | ./src/ext/array/to-map.ts | ToMap | Convert array to Map. |
| toSet | ./src/ext/array/to-set.ts | - | |
| zip | ./src/ext/array/zip.ts | Zip | Applies one specified function to corresponding elements of two sequences, producing one sequence as a result. |
| trim | ./src/ext/array/trim.ts | - | Remove null or undefined in array. |
| Extension Method | TypeScript file | Overview |
|---|---|---|
| toArray | ./src/ext/map/to-array.ts | Convert Map to an Array. |
| Extension Method | TypeScript file | Overview |
|---|---|---|
| toggle | ./src/ext/boolean/toggle.ts | Toggle boolean true / false. |
| Extension Method | TypeScript file | Overview |
|---|---|---|
| deepCopy | ./src/ext/object/deep-copy.ts | Deep copy the Object. |
| equalTo | ./src/ext/object/equal-to.ts | True if the contents of the object are the same. |