{"id":20330327,"url":"https://github.com/murphyne/iterationlimits","last_synced_at":"2026-05-07T12:33:42.967Z","repository":{"id":68752108,"uuid":"574422544","full_name":"murphyne/IterationLimits","owner":"murphyne","description":"Collection of methods to limit potentially infinite loops","archived":false,"fork":false,"pushed_at":"2023-11-13T19:30:29.000Z","size":37,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-14T15:20:55.882Z","etag":null,"topics":["infinite-loop"],"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/murphyne.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":null,"security":null,"support":null,"governance":null}},"created_at":"2022-12-05T09:25:16.000Z","updated_at":"2023-11-13T19:37:35.000Z","dependencies_parsed_at":"2023-05-21T15:45:18.525Z","dependency_job_id":null,"html_url":"https://github.com/murphyne/IterationLimits","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/murphyne%2FIterationLimits","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/murphyne%2FIterationLimits/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/murphyne%2FIterationLimits/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/murphyne%2FIterationLimits/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/murphyne","download_url":"https://codeload.github.com/murphyne/IterationLimits/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241851233,"owners_count":20030961,"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":["infinite-loop"],"created_at":"2024-11-14T20:15:55.075Z","updated_at":"2025-12-02T12:06:18.493Z","avatar_url":"https://github.com/murphyne.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# IterationLimits\n\nThis is a small library to help you limit potentially infinite loops in your code.\n\n\n## Features\n\nThe `Limits` class provides two ways to limit iterations:\n\n- `LimitCount` to limit the number of iterations.\n- `LimitTime` to limit the time duration of iterations.\n\nThe `Limits` class supports three types of iterations:\n\n- `Func\u003cbool\u003e` to limit based on condition.\n- `IEnumerator\u003cT\u003e` to limit enumerator.\n- `IEnumerable\u003cT\u003e` to limit enumerable.\n\nThe `LimitTime` method provides three overloads to measure time:\n\n- Use the value of `DateTime.Now` by omitting the 3rd argument.\n- Use the value of custom `Func\u003cDateTime\u003e` by providing argument of this type.\n- Use the value of custom `Func\u003cTimeSpan\u003e` by providing argument of this type.\n\n\n## Examples\n\n\u003e [!NOTE]\n\u003e More examples are available in `IterationLimitsExamples` project.\n\n`LimitCount(Func\u003cbool\u003e condition, int limit)`\n\n```csharp\nFunc\u003cbool\u003e condition = () =\u003e true;\nFunc\u003cbool\u003e conditionLimited = Limits.LimitCount(condition, 10);\n\nwhile (conditionLimited.Invoke()) {}\n```\n\n`LimitTime\u003cT\u003e(IEnumerator\u003cT\u003e enumerator, TimeSpan limit)`\n\n```csharp\nIEnumerator\u003cint\u003e enumerator = GetEnumerator();\nIEnumerator\u003cint\u003e enumeratorLimited = Limits.LimitTime(enumerator, TimeSpan.FromSeconds(1));\n\nwhile (enumeratorLimited.MoveNext()) {}\n```\n\n`LimitTime\u003cT\u003e(IEnumerable\u003cT\u003e enumerable, TimeSpan limit, Func\u003cDateTime\u003e measure)`\n\n```csharp\nIEnumerable\u003cint\u003e enumerable = GetEnumerable();\nIEnumerable\u003cint\u003e enumerableLimited = Limits.LimitTime(enumerable, TimeSpan.FromSeconds(1), () =\u003e DateTime.Now);\n\nforeach (var item in enumerableLimited) {}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmurphyne%2Fiterationlimits","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmurphyne%2Fiterationlimits","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmurphyne%2Fiterationlimits/lists"}