{"id":19990046,"url":"https://github.com/morrisjdev/Linq4JS","last_synced_at":"2025-05-04T09:34:19.646Z","repository":{"id":15589927,"uuid":"78444868","full_name":"morrisjdev/Linq4JS","owner":"morrisjdev","description":"Linq methods for JavaScript/TypeScript","archived":false,"fork":false,"pushed_at":"2022-12-09T15:40:05.000Z","size":1720,"stargazers_count":15,"open_issues_count":16,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-06T07:44:14.725Z","etag":null,"topics":["extension-methods","filter","javascript","lambda-expressions","linq","linq-methods","orderby","selector","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/morrisjdev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-09T16:05:36.000Z","updated_at":"2023-01-25T07:23:09.000Z","dependencies_parsed_at":"2022-07-22T12:17:01.884Z","dependency_job_id":null,"html_url":"https://github.com/morrisjdev/Linq4JS","commit_stats":null,"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morrisjdev%2FLinq4JS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morrisjdev%2FLinq4JS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morrisjdev%2FLinq4JS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morrisjdev%2FLinq4JS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/morrisjdev","download_url":"https://codeload.github.com/morrisjdev/Linq4JS/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224391390,"owners_count":17303609,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["extension-methods","filter","javascript","lambda-expressions","linq","linq-methods","orderby","selector","typescript"],"created_at":"2024-11-13T04:50:55.148Z","updated_at":"2024-11-13T04:51:07.689Z","avatar_url":"https://github.com/morrisjdev.png","language":"TypeScript","readme":"# Linq4JS [![Build Status](https://travis-ci.org/morrisjdev/Linq4JS.svg?branch=master)](https://travis-ci.org/morrisjdev/Linq4JS) [![Known Vulnerabilities](https://snyk.io/test/github/morrisjdev/Linq4JS/badge.svg?targetFile=package.json)](https://snyk.io/test/github/morrisjdev/Linq4JS?targetFile=package.json)\n\nLinq methods for JavaScript/TypeScript for working with arrays\n\nThis 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\n\n## Advantages\n\nThis 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.\n\nAs expressions you can use the normal Function-Syntax:\n\n```javascript\narray.Where(function(x){\n\treturn x.Name == \"Max\";\n});\n```\n\nLambda-Expressions (IE isn't compatible with this Lambda-Expressions):\n\n```javascript\narray.Where(x =\u003e x.Name == \"Max\");\n```\n\nor Lambda-Expressions as Strings (this Syntax works in IE):\n\n```javascript\narray.Where(\"x =\u003e x.Name == 'Max'\");\n```\n\n### SQL-Like\n\nAlso a complete procedure as an sql-like string is supported\n\n```\narray.Evaluate(\"select x =\u003e x.Id sum\");\n```\n\n```\nclone\nreverse\nwhere x =\u003e x.Age \u003e 70\norder by x =\u003e x.Name\nthen by x =\u003e x.FirstName descending\nfor each x =\u003e console.log(x)\nselect x =\u003e {x.Name}\n```\n\n### Conclusion\n\n* Works with multiple Browsers (even IE)\n* Angular Support (event directly in Views if using Strings as Expression-Syntax)\n* Lightweight\n* Fast\n* Syntax from .NET\n* Build on top of array-prototype and no changes in code are required for usage\n* Integrates seamlessly into the project\n* TypeScript definitions\n\n## Getting Started\n\n### Install using NPM\n\n```\nnpm install linq4js\n```\n\n### Install using Bower\n\n```\nbower install linq4js\n```\n\n### Using JavaScript\n\nInclude this line in your project\n\n```html\n\u003cscript type=\"text/javascript\" src=\"linq4js.js\"\u003e\u003c/script\u003e\n```\n\n### Using TypeScript\n\nUse\n\n```\nimport \"linq4js\";\n```\n\nor \n\n```html\n\u003cscript type=\"text/javascript\" src=\"linq4js.js\"\u003e\u003c/script\u003e\n```\n\nto import the scripts and optionally (if you are not using npm) install `@types/linq4js` to also get tooling support.\n\n## Usage\n\n### Clone\n\nCreates a copy of the array\n\n```javascript\nvar array = [\"item1\", \"item2\", \"item3\", \"item4\", \"no\"];\n\n//[\"item1\", \"item2\", \"item3\", \"item4\", \"no\"]\narray.Clone();\n```\n\n### FindIndex\n\nGets the index of the first item found by a filter\n\n```javascript\nvar array = [\"item1\", \"item2\", \"item3\", \"item4\", \"no\"];\n\n//2\narray.FindIndex(\"x =\u003e x == 'item3'\");\n```\n\n### FindLastIndex\n\nGets the index of the last item found by a filter\n\n```javascript\nvar array = [\"item1\", \"item2\", \"item3\", \"item2\", \"item4\", \"no\"];\n\n//3\narray.FindIndex(\"x =\u003e x == 'item2'\");\n```\n\n### Get\n\nGets the item with the index\n\n```javascript\nvar array = [\"item1\", \"item2\", \"item3\", \"item4\", \"no\"];\n\n//\"item3\"\narray.Get(2);\n```\n\n### Repeat\n\nRepeats an object in the array\n\n```javascript\nvar array = [\"item1\", \"item2\", \"item3\", \"item4\"];\n\n//[\"item1\", \"item2\", \"item3\", \"item4\", \"example\", \"example\", \"example\"]\narray.Repeat(\"example\", 3);\n```\n\n### ForEach\n\nExecutes a method for each item in the array\n\n```javascript\nvar array = [\"item1\", \"item2\", \"item3\", \"item4\", \"no\"];\narray.ForEach(\"i =\u003e console.log(i)\");\n```\n\n### Update \u0026 UpdateRange\n\nUpdates object(s) in the array\n\nBy default this method uses the property **Id** to identify the objects. If the property is not set this methods tries to compare the objects directly.\n\n```javascript\nvar array = [{Id: 1, Value: \"item1\"}, {Id: 2, Value: \"item2\"}];\n\t\n//[{Id: 1, Value: \"item3\"}, {Id: 2, Value: \"item2\"}]\narray.Update({Id: 1, Value: \"item3\"});\n```\n\nIf you want this method to use other fields for identification define a selector function as second parameter.\n\n```javascript\nvar array = [{OtherId: 1, Value: \"item1\"}, {OtherId: 2, Value: \"item2\"}];\n\t\n//[{Id: 1, Value: \"item3\"}, {Id: 2, Value: \"item2\"}]\narray.Update({OtherId: 1, Value: \"item3\"}, \"x =\u003e x.OtherId\");\n```\n\nYou can upgrade multiple objects simultaneously\n\n```javascript\nvar array = [{OtherId: 1, Value: \"item1\"}, {OtherId: 2, Value: \"item2\"}];\n\t\n//[{Id: 1, Value: \"item3\"}, {Id: 2, Value: \"item4\"}]\narray.UpdateRange(\n\t[{OtherId: 1, Value: \"item3\"}, {OtherId: 2, Value: \"item4\"}], \n\t\"x =\u003e x.OtherId\");\n```\n\n### Remove \u0026 RemoveRange\n\nRemoves item(s) from array\n\nBy default this method uses the property **Id** to identify the objects. If the property is not set this methods tries to compare the objects directly.\n\n```javascript\nvar array = [\"item1\", \"item2\", \"item3\", \"item4\", \"no\"];\n\n//[\"item1\", \"item2\", \"item3\", \"item4\"]\narray.Remove(\"no\");\n\t\n//[\"item1\", \"item2\"]\narray.RemoveRange([\"item4\", \"item3\"]);\n```\n\nIf you want this method to use other fields for identification define a selector function as second parameter.\n\n```javascript\nvar array = [{OtherId: 1, Value: \"item1\"}, {OtherId: 2, Value: \"item2\"}];\n\n//[{OtherId: 2, Value: \"item2\"}]\narray.Remove({OtherId: 1}, \"x =\u003e x.OtherId\");\n```\n\n### Add \u0026 AddRange\n\nAdds the item(s) to the array\n\n```javascript\nvar array = [\"item1\", \"item2\", \"item3\", \"item4\", \"no\"];\n\n//[\"item1\", \"item2\", \"item3\", \"item4\", \"no\", \"item5\"]\narray.Add(\"item5\");\n\n//[\"item1\", \"item2\", \"item3\", \"item4\", \"no\", \"item5\", \"item6\", \"item7\"]\narray.AddRange([\"item6\", \"item7\"]);\n```\n\n### Insert\n\nInserts an entry at a specific position\n\n```javascript\nvar array = [\"item1\", \"item2\", \"item3\", \"item4\"];\n\n//[\"item1\", \"item2\", \"item2.5\", \"item3\", \"item4\"]\narray.Insert(\"item2.5\", 2);\n```\n\n### Where\n\nSearches for all items in array that match the given filter\n\n```javascript\nvar array = [\"item1\", \"item2\", \"item3\", \"item4\", \"no\"];\n\n//[\"item1\", \"item2\", \"item3\", \"item4\"]\narray.Where(\"i =\u003e i.match(/item/gi)\");\n```\n\n### Range\n\nTakes items in a specific range\n\n```javascript\nvar array = [\"item1\", \"item2\", \"item3\", \"item4\"];\n\n//[\"item2\", \"item3\"]\narray.Range(1, 2);\n```\n\n### Count\n\nReturns the length of the array or if a filter is set the length of the resulting array\n\n```javascript\nvar array = [\"item1\", \"item2\", \"item3\", \"item4\", \"no\"];\n\n//5\narray.Count();\n\n//4\narray.Count(\"i =\u003e i.match(/item/gi)\");\n```\n\n### SequenceEqual\n\nCompares to sequences of objects\n\n```javascript\nvar array = [\"item1\", \"item2\", \"item3\"];\nvar array2 = [\"item1\", \"item2\", \"item3\"];\nvar array3 = [\"item\", \"item2\", \"item3\"];\n\n//true\narray.SequenceEqual(array2);\n\n//false\narray.SequenceEqual(array3);\n```\n\n### Any\n\nTests if any item is in the array and if a filter is set if any item of the array matches the filter\n\n```javascript\nvar array = [\"item1\", \"item2\", \"item3\", \"item4\", \"no\"];\n\n//true\narray.Any();\n\n//true\narray.Any(\"i =\u003e i.length \u003e 2\");\n\t\n//false\narray.Any(\"i =\u003e i == ''\");\n```\n\n### All\n\nTests if all items in the array match the condition\n\n```javascript\nvar array = [\"item1\", \"item2\", \"item3\", \"item4\", \"no\"];\n\n//false\narray.All(\"i =\u003e i.length \u003e 2\");\n```\n\n### Contains\n\nTests if array contains specific object\n\n```javascript\nvar array = [\"item1\", \"item2\", \"item3\", \"item4\", \"no\"];\n\n//false\narray.Contains(\"test\");\n```\n\n### Concat\n\nCombines two arrays\n\n```javascript\nvar array = [\"item1\", \"item2\", \"item3\"];\nvar array2 = [\"item4\", \"no\"];\n\n//[\"item1\", \"item2\", \"item3\", \"item4\", \"no\"]\narray.Concat(array2);\n```\n\n### Intersect\n\nCombines two arrays but only applies values that are in both arrays\n\n```javascript\nvar array = [\"item1\", \"item2\", \"item3\"];\nvar array2 = [\"item1\", \"unique\", \"item2\", \"item3\"];\n\n//[\"item1\", \"item2\", \"item3\"]\narray.Intersect(array2);\n```\n\n### Union\n\nCombines two arrays without duplicates\n\n```javascript\nvar array = [\"item1\", \"item2\", \"item3\"];\nvar array2 = [\"item1\", \"unique\", \"item2\", \"item3\"];\n\n//[\"item1\", \"item2\", \"item3\", \"unique\"]\narray.Union(array2);\n```\n\n### Join\n\nJoins the entries by the given char\n\n```javascript\nvar array = [\"item1\", \"item2\", \"item3\", \"item4\", \"no\"];\n\n//item1-item2-item3-item4-no\narray.Join(\"-\");\n\n//item1-item2-item3-item4\narray.Join(\"-\", \"x =\u003e x.length \u003e 2\");\n```\n\n### Aggregate\n\nCombines the entries using a custom function\n\n```javascript\nvar array = [\"item1\", \"item2\", \"item3\", \"item4\", \"no\"];\n\n//no-item4-item3-item2-item1\narray.Aggregate(\"(str, item) =\u003e item + '-' + item\");\n```\n\n### ToDictionary\n\nConverts the array to a dictionary\n\n```javascript\nvar array = [{OtherId: 1, Value: \"item1\"}, {OtherId: 2, Value: \"item2\"}];\n\n//{1: {OtherId: 1, Value: \"item1\"}, 2: {OtherId: 2, Value: \"item2\"}}\narray.ToDictionary(\"x =\u003e x.OtherId\");\n\n//{1: \"item1\", 2: \"item2\"}\narray.ToDictionary(\"x =\u003e x.OtherId\", \"x =\u003e x.Value\");\n```\n\n### Zip\n\nCombines the entries of two arrays using a custom function\n\n```javascript\nvar array = [0, 1, 2, 3, 4];\nvar array2 = [\"zero\", \"one\", \"two\", \"three\"];\n\n//[\"0 zero\", \"1 one\", \"2 two\", \"3 three\"]\narray.Zip(array2, \"(x, y) =\u003e x + ' ' + y\");\n```\n\n### Reverse\n\nReverses the array\n\n```javascript\nvar array = [\"item1\", \"item2\", \"item3\", \"item4\", \"no\"];\n\n//[\"no\", \"item4\", \"item3\", \"item2\", \"item1\"]\narray.Reverse();\n```\n\n### Average\n\nComputes the average of the elements\n\n```javascript\nvar array = [{val: 5}, {val: 3}, {val: 1}];\n\n//3\narray.Average(\"x =\u003e x.val\");\n\n//4\narray.Average(\"x =\u003e x.val\", \"x =\u003e x.val \u003e 1\");\n\n\nvar array2 = [3, 4, 5];\n\n//4\narray2.Average();\n```\n\n### Sum\n\nComputes the sum of the elements\n\n```javascript\nvar array = [{val: 5}, {val: 3}, {val: 1}];\n\n//9\narray.Sum(\"x =\u003e x.val\");\n\n//8\narray.Sum(\"x =\u003e x.val\", \"x =\u003e x.val \u003e 1\");\n\n\nvar array2 = [3, 4, 5];\n\n//12\narray2.Sum();\n```\n\n### First\n\nReturns the first item of the array and if a filter was set the first item that matches the filter - Throws an exception if no item was found\n\n```javascript\nvar array = [\"no\", \"item1\", \"item2\", \"item3\", \"item4\", \"no\"];\n\n//\"no\"\narray.First();\n\n//\"item1\"\narray.First(\"i =\u003e i.match(/item/gi)\");\n\n//Exception\narray.First(\"i =\u003e i == 'notgiven'\");\n```\n\n### FirstOrDefault\n\nReturns the first item of the array and if a filter was set the first item that matches the filter - returns `null` if no suitable item was found\n\n```javascript\nvar array = [\"no\", \"item1\", \"item2\", \"item3\", \"item4\", \"no\"];\n\n//\"no\"\narray.FirstOrDefault();\n\n//\"item1\"\narray.FirstOrDefault(\"i =\u003e i.match(/item/gi)\");\n\n//null\narray.First(\"i =\u003e i == 'notgiven'\");\n```\n\n### Single\n\nReturns the only item of the array - Throws an exception if not exactly one item is in array\n\n```javascript\nvar array = [\"item1\"];\n\n//\"item1\"\narray.Single();\n\nvar array = [\"item1\", \"item2\"];\n\n//\"item1\"\narray.Single(\"x =\u003e x == 'item1'\");\n\n//Exception\narray.Single();\n```\n\n### SingleOrDefault\n\nReturns the only item of the array - Throws an exception if not only one item is in array\n\n```javascript\nvar array = [\"item1\"];\n\n//\"item1\"\narray.Single();\n\nvar array = [\"item1\", \"item2\"];\n\n//\"item1\"\narray.Single(\"x =\u003e x == 'item1'\");\n\n//Exception\narray.Single();\n\n//null\narray.Single(\"x =\u003e x == 'item3'\");\n```\n\n### Min\n\nReturns the smallest element in array\n\n```javascript\nvar array = [0, 8, 1, 5, -3];\n\n//-3\narray.Min();\n\nvar array = [{name: \"test\", age: 3}, {name: \"test2\", age: 18}];\n\n//{name: \"test\", age: 3}\narray.Min(\"x =\u003e x.age\");\n```\n\n### Last\n\nReturns 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\n\n```javascript\nvar array = [\"no\", \"item1\", \"item2\", \"item3\", \"item4\", \"no\"];\n\n//\"no\"\narray.Last();\n\n//\"item4\"\narray.Last(\"i =\u003e i.match(/item/gi)\");\n\n//Exception\narray.Last(\"i =\u003e i == 'notgiven'\");\n```\n\n### LastOrDefault\n\nReturns the last item of the array and if a filter was set the last item that matches the filter - returns `null` if no suitable item was found\n\n```javascript\nvar array = [\"no\", \"item1\", \"item2\", \"item3\", \"item4\", \"no\"];\n\n//\"no\"\narray.LastOrDefault();\n\n//\"item4\"\narray.LastOrDefault(\"i =\u003e i.match(/item/gi)\");\n\n//null\narray.LastOrDefault(\"i =\u003e i == 'notgiven'\");\n```\n\n### Max\n\nReturns the greates element in array\n\n```javascript\nvar array = [0, 8, 1, 5, -3];\n\n//8\narray.Max();\n\nvar array = [{name: \"test\", age: 3}, {name: \"test2\", age: 18}];\n\n//{name: \"test2\", age: 18}\narray.Max(\"x =\u003e x.age\");\n```\n\n### Select\n\nSelect the properties for a new array\n\n```javascript\nvar array = [{Id: 1, Value: \"item1\"}, {Id: 2, Value: \"item2\"}];\n\t\n//[\"item1\", \"item2\"]\narray.Select(\"i =\u003e i.Value\");\n\n//[{Custom: 1, Name: \"item1\"}, {Custom: 2, Name: \"item2\"}];\narray.Select(\"i =\u003e {Custom: i.Id, Name: i.Value}\");\n```\n\nWhen using the string syntax it is also possible to assign objects by the following methods\n```javascript\nvar array = [{Id: 1, Value: \"item1\"}, {Id: 2, Value: \"item2\"}];\n\t\n//[{Value: item1}, {Value: item2}]\narray.Select(\"i =\u003e {i.Value}\");\n\n//[{C: item1}, {C: item2}]\narray.Select(\"i =\u003e {C: i.Value}\");\n\n//[{C: item1}, {C: item2}]\narray.Select(\"i =\u003e {C = i.Value}\");\n```\n\n### SelectMany\n\nSelect the properties with an array as value and concats them\n\n```javascript\nvar array = [[\"item1\", \"item2\"], [\"item1\", \"item2\"]];\n\t\n//[\"item1\", \"item2\", \"item1\", \"item2\"]\narray.SelectMany(\"i =\u003e i\");\n```\n\n### Take\n\nLimits the number of entries taken\n\n```javascript\nvar array = [\"item1\", \"item2\", \"item3\", \"item4\"];\n\n//[\"item1\", \"item2\"]\narray.Take(2);\n```\n\n### TakeWhile\n\nTakes entries as long as a condition is true\n\n```javascript\nvar array = [\"item1\", \"item2\", \"item3\", \"item2\", \"item4\"];\nvar item2count = 0;\n\n//[\"item1\", \"item2\", \"item3\"]\narray.TakeWhile(function(x){\n\tif(x == \"item2\"){\n\t\titem2count++;\n\t}\n\n\treturn item2count \u003c 2;\n});\n```\n\nThis is the basic usage. But if you want conditional executes for e.g. with counting this can get a little bit messy.\n\n```javascript\nvar array = [\"item1\", \"item2\", \"item3\", \"item2\", \"item4\"];\n\n//[\"item1\", \"item2\", \"item3\"]\narray.TakeWhile(function(item, storage){\n\treturn item != \"item2\" || storage.count \u003c 1; //Condition\n}, function(storage){\n\tstorage.count = 0; //Init the Storage\n}, function(item, storage){\n\tif(item == \"item2\"){\n\t\tstorage.count++; //After executing the condition\n\t}\n});\n```\n\n### Skip\n\nSkips entries\n\n```javascript\nvar array = [\"item1\", \"item2\", \"item3\", \"item4\"];\n\n//[\"item3\", \"item4\"]\narray.Skip(2);\n```\n\n### GroupBy\n\nGroups array by property\n\n```javascript\nvar array = [\n\t{name: \"Max\", age: 17},\n\t{name: \"Emily\", age: 54},\n\t{name: \"max\", age: 32},\n\t{name: \"emily\", age: 12}\n];\n\n//[\n//\t[{name: \"Emily\", age: 54},{name: \"emily\", age: 12}],\n//\t[{name: \"Max\", age: 17},{name: \"max\", age: 32}]\n//]\narray.GroupBy(\"i =\u003e i.name.toLowerCase()\");\n```\n\n### OrderBy \u0026 OrderByDescending\n\nOrders array by property or value\n\n```javascript\nvar array = [\"item3\", \"item1\", \"item2\", \"item4\"];\n\t\n//[\"item4\", \"item3\", \"item2\", \"item1\"]\narray.OrderByDescending(\"i =\u003e i\");\n\t\n//[\"item1\", \"item2\", \"item3\", \"item4\"]\narray.OrderBy(\"i =\u003e i\");\n```\n\nAlso supports complex properties\n\n```javascript\nvar array = [\n\t{Name: \"Max\", Lastname: \"Mustermann\"},\n\t{Name: \"John\", Lastname: \"Doe\"},\n\t{Name: \"Erika\", Lastname: \"Mustermann\"}\n];\n\t\n//[{Name: \"Max\", Lastname: \"Mustermann\"},\n//{Name: \"Erika\", Lastname: \"Mustermann\"},\n//{Name: \"John\", Lastname: \"Doe\"}]\narray.OrderByDescending(\"i =\u003e i.Lastname\");\n\n//[{Name: \"John\", Lastname: \"Doe\"}, \n//{Name: \"Max\", Lastname: \"Mustermann\"},\n//{Name: \"Erika\", Lastname: \"Mustermann\"}]\narray.OrderBy(\"i =\u003e i.Lastname\");\n```\n\n### ThenBy \u0026 ThenByDescending\n\nOrders array by additional properties in combination with OrderBy/OrderByDescending\n\n```javascript\nvar array = [\n\t{Name: \"Max\", Lastname: \"Mustermann\"},\n\t{Name: \"John\", Lastname: \"Doe\"},\n\t{Name: \"Erika\", Lastname: \"Mustermann\"}\n];\n\t\n//[{Name: \"Erika\", Lastname: \"Mustermann\"},\n//{Name: \"Max\", Lastname: \"Mustermann\"},\n//{Name: \"John\", Lastname: \"Doe\"}]\narray.OrderByDescending(\"i =\u003e i.Lastname\").ThenBy(\"i =\u003e i.Name\");\n```\n\n### Move\n\nMoves an item from one index to another\n\n```javascript\nvar array = [\"item1\", \"item2\", \"item3\", \"item4\"];\n\n//[\"item1\", \"item3\", \"item4\", \"item2\"]\narray.Move(1, 3);\n```\n\n### Distinct\n\nMakes all values unique using the specified selector\n\n```javascript\nvar array = [\"item1\", \"item2\", \"item2\", \"item3\", \"item4\"];\n\n//[\"item1\", \"item2\", \"item3\", \"item4\"]\narray.Distinct(\"x =\u003e x\");\narray.Distinct();\n```\n\n### Evaluate\n\nEvaluates SQL-String for array\n\n```javascript\nvar array = [...];\n\narray.Evaluate(\"...\");\n```\n\nExample SQL-string\n\n```\nclone\nreverse\nwhere x =\u003e x.Age \u003e 70\norder by x =\u003e x.Name\nthen by x =\u003e x.FirstName descending\nfor each x =\u003e console.log(x)\nselect x =\u003e {x.Name}\n```\n\nSupported methods (the methodname and aliases are not case-sensitive)\n\n| Methodname        | Alias                                                                                                                                 | Examples                         |\n|-------------------|---------------------------------------------------------------------------------------------------------------------------------------|----------------------------------|\n| Clone             |                                                                                                                                       | clone                            |\n| Reverse           |                                                                                                                                       | reverse                          |\n| Contains          |                                                                                                                                       | contains 5                       |\n| Join              |                                                                                                                                       | join 5                           |\n| Sum               |                                                                                                                                       | sum                              |\n| Average           |                                                                                                                                       | average                          |\n| Where             |                                                                                                                                       | where x =\u003e x.Id \u003e 3              |\n| Select            |                                                                                                                                       | select x =\u003e x.Id                 |\n| SelectMany        | select many\u003cbr\u003e select ... many                                                                                                       | select many x =\u003e x.Pets          |\n| Get               |                                                                                                                                       | get 4                            |\n| ForEach           | for each                                                                                                                              | for each x =\u003e console.log(x)     |\n| Count             |                                                                                                                                       | count x =\u003e x.Id                  |\n| All               |                                                                                                                                       | all x =\u003e x.Age \u003e 4               |\n| Any               |                                                                                                                                       | any x =\u003e x.Age \u003e 4               |\n| Take              |                                                                                                                                       | take 3                           |\n| TakeWhile         | take while\u003cbr\u003e take ... while                                                                                                         | take while x =\u003e x.Age \u003e 10       |\n| Skip              |                                                                                                                                       | skip 3                           |\n| Min               |                                                                                                                                       | min x =\u003e x.Age                   |\n| Max               |                                                                                                                                       | max x =\u003e x.Age                   |\n| GroupBy           | group by                                                                                                                              | group by x =\u003e x.Name             |\n| Distinct          |                                                                                                                                       | distinct x =\u003e x.Id               |\n| FindLastIndex     | find last index\u003cbr\u003efind index ... last\u003cbr\u003efindindex ... last                                                                          | find index x =\u003e x.Age == 3 last  |\n| FindIndex         | find index\u003cbr\u003efind first index\u003cbr\u003efindfirstindex\u003cbr\u003efind index ... first\u003cbr\u003efindindex ... first                                       | find index x =\u003e x.Age == 3 first |\n| OrderByDescending | order by ... descending\u003cbr\u003eorderby ... descending\u003cbr\u003eorderby descending\u003cbr\u003eorder by descending\u003cbr\u003eorderbydescending                   | order by x =\u003e x.Age descending   |\n| OrderBy           | order by ... ascending\u003cbr\u003eorderby ... ascending\u003cbr\u003eorderby ascending\u003cbr\u003eorder by ascending\u003cbr\u003eorderbyascending\u003cbr\u003eorder by\u003cbr\u003eorderby | order by x =\u003e x.Age ascending    |\n| FirstOrDefault    | first or default                                                                                                                      | first or default                 |\n| LastOrDefault     | last or default                                                                                                                       | last or default                  |\n| SingleOrDefault   | single or default                                                                                                                     | single or default                |\n| First             |                                                                                                                                       | first                            |\n| Last              |                                                                                                                                       | last                             |\n| Single            |                                                                                                                                       | single                           |\n| ThenByDescending  | thenby ... descending\u003cbr\u003ethen by ... descending\u003cbr\u003ethenbydescending\u003cbr\u003ethen by descending                                             | then by x =\u003e x.Name descending   |\n| ThenBy            | thenby ... ascending\u003cbr\u003ethen by ... ascending\u003cbr\u003ethenbyascending\u003cbr\u003ethen byascending\u003cbr\u003ethenby\u003cbr\u003ethen by                             | then by x =\u003e x.Name ascending    |\n\n## Author\n\n[Morris Janatzek](http://morrisj.net) ([morrisjdev](https://github.com/morrisjdev))\n","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorrisjdev%2FLinq4JS","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmorrisjdev%2FLinq4JS","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorrisjdev%2FLinq4JS/lists"}