{"id":24686891,"url":"https://github.com/ricardotondello/functionalenumerableextensions","last_synced_at":"2025-03-21T21:42:24.949Z","repository":{"id":187687405,"uuid":"677367237","full_name":"ricardotondello/FunctionalEnumerableExtensions","owner":"ricardotondello","description":"These extensions are designed to enhance memory efficiency and make common operations more convenient.  Whether you're converting to lists, arrays, or working with spans, these extensions aim to improve your code's performance and readability.","archived":false,"fork":false,"pushed_at":"2025-02-25T20:36:55.000Z","size":55,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-25T21:32:40.707Z","etag":null,"topics":["csharp","dotnet","dotnetcore","enumerable","extensions"],"latest_commit_sha":null,"homepage":"","language":"C#","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/ricardotondello.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-11T11:52:52.000Z","updated_at":"2025-02-25T20:36:58.000Z","dependencies_parsed_at":"2023-08-11T19:01:16.321Z","dependency_job_id":"2edf6763-fff9-4323-b164-e46913c9fa18","html_url":"https://github.com/ricardotondello/FunctionalEnumerableExtensions","commit_stats":null,"previous_names":["ricardotondello/functionalenumerableextensions"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ricardotondello%2FFunctionalEnumerableExtensions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ricardotondello%2FFunctionalEnumerableExtensions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ricardotondello%2FFunctionalEnumerableExtensions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ricardotondello%2FFunctionalEnumerableExtensions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ricardotondello","download_url":"https://codeload.github.com/ricardotondello/FunctionalEnumerableExtensions/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244874718,"owners_count":20524581,"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":["csharp","dotnet","dotnetcore","enumerable","extensions"],"created_at":"2025-01-26T16:17:01.601Z","updated_at":"2025-03-21T21:42:24.921Z","avatar_url":"https://github.com/ricardotondello.png","language":"C#","funding_links":["https://www.buymeacoffee.com/ricardotondello"],"categories":[],"sub_categories":[],"readme":"\n# FunctionalEnumerableExtensions 🌟\n\n[![Build](https://github.com/ricardotondello/FunctionalEnumerableExtensions/actions/workflows/dotnet.yml/badge.svg?branch=main)](https://github.com/ricardotondello/FunctionalEnumerableExtensions/actions/workflows/dotnet.yml)\n[![Quality Gate](https://sonarcloud.io/api/project_badges/measure?project=ricardotondello_FunctionalEnumerableExtensions\u0026metric=alert_status)](https://sonarcloud.io/dashboard?id=ricardotondello_FunctionalEnumerableExtensions)\n[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=ricardotondello_FunctionalEnumerableExtensions\u0026metric=coverage)](https://sonarcloud.io/component_measures?id=ricardotondello_FunctionalEnumerableExtensions\u0026metric=coverage)\n[![NuGet latest version](https://badgen.net/nuget/v/FunctionalEnumerableExtensions/latest)](https://nuget.org/packages/FunctionalEnumerableExtensions)\n[![NuGet downloads](https://img.shields.io/nuget/dt/FunctionalEnumerableExtensions)](https://www.nuget.org/packages/FunctionalEnumerableExtensions)\n\n`FunctionalEnumerableExtensions` is a C# class library that provides a set of extension methods for working with enumerable collections. \nThese extensions are designed to enhance memory efficiency and make common operations more convenient. \nWhether you're converting to lists, arrays, or working with spans, these extensions aim to improve your code's performance and readability.\n\n## Installation 🚀\n\nTo easily integrate the FunctionalEnumerableExtensions library into your project, you can use NuGet Package Manager.\nNuGet is a package manager for .NET that simplifies the process of adding, removing,\nand updating libraries in your applications.\n\nAfter that import the `FunctionalEnumerableExtensions` namespace in your code files where you want to use the provided extension methods:\n\n```csharp\nusing FunctionalEnumerableExtensions;\n```\n\n## Available Extension Methods 🛠️\n\n### `EnsureList`\n\nPrevent memory allocation when converting to a list using LINQ's `.ToList()`.\n\n**Usage:**\n```csharp\nList\u003cint\u003e myList = myEnumerable.EnsureList();\n```\n\n### `EnsureArray`\n\nPrevent memory allocation when converting to an array using LINQ's `.ToArray()`.\n\n**Usage:**\n```csharp\nT[] myArray = myEnumerable.EnsureArray();\n```\n\n### `AsSpan`\n\n**Warning: DO NOT use Span if you would change the list while looping into it, it can cause exceptions.**\n\nConvert the enumerable collection to a Span, suitable for in-place data processing.\n\n**Usage:**\n```csharp\nSpan\u003cT\u003e mySpan = myEnumerable.AsSpan();\n```\n\n### `EnsureHashSet`\n\nPrevent memory allocation by casting an IEnumerable to a HashSet\u003cT\u003e if it's already of that type, otherwise create a new HashSet\u003cT\u003e.\n\n**Usage:**\n```csharp\nHashSet\u003cT\u003e myHashSet = myEnumerable.EnsureHashSet();\n```\n\n### `CollectNonNulls`\n\nFilter out non-null items from the input IEnumerable\u003cT\u003e.\n\n**Usage:**\n```csharp\nvar myFilteredList = myEnumerable.CollectNonNulls();\n```\n\n### `EnsureEnumerable`\n\nPrevent the enumerable to be null.\n\n**Usage:**\n```csharp\nvar myNotNullEnumerable = myEnumerable.EnsureEnumerable();\n```\n\n### `SplitBy`\n\nSplits the list according to the predicate.\n\n**Usage:**\n```csharp\nvar (desiredItems, remainingItems) = enumerable.SplitBy(customer =\u003e customer.LoyaltyTimeInYears \u003e 20);\n```\n\n### `IsNullOrEmpty`\n\nChecks if the list is null or empty\n\n**Usage:**\n```csharp\nvar result = enumerable.IsNullOrEmpty();\n```\n\n### `WhereIf`\n\nIntroduces optional filtering, applying a predicate only if a specified condition holds true.\n\n**Usage:**\n```csharp\nvar result = enumerable.WhereIf(YourBooleanCondition(), w =\u003e w \u003e 0);\n```\n\n### `Stringify`\n\nConverts a collection of non-null objects to a string by concatenating their properties recursively, separated by commas.\n\n**Usage:**\n```csharp\nvar result = enumerable.Stringify();\n```\n\n### `EnumerateWithIndex`\n\nEnumerate an IEnumerable source and getting the Index and the Item returned in a ValueTuple.\n\n**Usage**\n```csharp\nvar result = enumerable.EnumerateWithIndex();\n```\n\n### `JoinString`\n\nChainable extensions that joins the separator string with the elements of your Enumerable.\n\n**Usage**\n```csharp\nvar result = list.Select(s =\u003e s.Name).JoinString();\n```\n\n### `OrderBy` and `OrderByDescending` with a delegate comparer\n\nSorts the elements of a sequence in ascending/descending order by using a specified comparer.\n\n**Usage**\n```csharp\nrecord Customer(string Name, int Age);\n\n//Order by name then by age\n//user OrderByDescending to order descendingly\nvar result = values.OrderBy(x =\u003e (x.Name, x.Age), (a, b) =\u003e\n        {\n            var nameComparison = string.Compare(a.Name, b.Name, StringComparison.Ordinal);\n            return nameComparison != 0 ? nameComparison : a.Age.CompareTo(b.Age);\n        });\n```\n\n## Contributing 👥\n\nContributions are welcome! If you find a bug or have a feature request, please open an issue on GitHub.\nIf you would like to contribute code, please fork the repository and submit a pull request.\n\n## License 📄\n\nThis project is licensed under the MIT License.\nSee [LICENSE](https://github.com/ricardotondello/FunctionalEnumerableExtensions/blob/main/LICENSE) for more information.\n\n## Support ☕\n\n\u003ca href=\"https://www.buymeacoffee.com/ricardotondello\" target=\"_blank\"\u003e\u003cimg src=\"https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png\" alt=\"Buy Me A Coffee\" style=\"height: 60px !important;width: 217px !important;\" \u003e\u003c/a\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fricardotondello%2Ffunctionalenumerableextensions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fricardotondello%2Ffunctionalenumerableextensions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fricardotondello%2Ffunctionalenumerableextensions/lists"}