{"id":22421997,"url":"https://github.com/rephidock/rephidock.generalutilities","last_synced_at":"2025-03-27T05:22:22.561Z","repository":{"id":220150414,"uuid":"749562146","full_name":"Rephidock/Rephidock.GeneralUtilities","owner":"Rephidock","description":"A package with general utilities that may be useful","archived":false,"fork":false,"pushed_at":"2024-05-18T21:56:11.000Z","size":119,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-08-04T09:27:10.009Z","etag":null,"topics":["general","helper","math","random","util","utils"],"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/Rephidock.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-28T23:09:58.000Z","updated_at":"2024-05-18T23:28:22.000Z","dependencies_parsed_at":"2024-02-22T00:33:05.525Z","dependency_job_id":"0ccb8984-6066-4f27-9a52-cd71b857069c","html_url":"https://github.com/Rephidock/Rephidock.GeneralUtilities","commit_stats":null,"previous_names":["rephidock/rephidock.generalutilities"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rephidock%2FRephidock.GeneralUtilities","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rephidock%2FRephidock.GeneralUtilities/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rephidock%2FRephidock.GeneralUtilities/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rephidock%2FRephidock.GeneralUtilities/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Rephidock","download_url":"https://codeload.github.com/Rephidock/Rephidock.GeneralUtilities/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245786460,"owners_count":20671760,"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":["general","helper","math","random","util","utils"],"created_at":"2024-12-05T17:10:38.892Z","updated_at":"2025-03-27T05:22:22.517Z","avatar_url":"https://github.com/Rephidock.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GeneralUtilities\n\n[![GitHub License Badge](https://img.shields.io/github/license/Rephidock/Rephidock.GeneralUtilities)](https://github.com/Rephidock/Rephidock.GeneralUtilities/blob/main/LICENSE) [![Nuget Version Badge](https://img.shields.io/nuget/v/Rephidock.GeneralUtilities?logo=nuget)](https://www.nuget.org/packages/Rephidock.GeneralUtilities)\n\nA collection of general utilities useful for other projects.\n\n## Contents\n\nAll utilities are split into the following sub-namespaces:\n\n### `.Maths` namespace\n\nThe package provides utilities for arithmetic, including work with arbitrary bases.\n\nAll of the listed methods are static.\n\nNote: extension methods also exit for other numeric types when applicable. Additionally overloads for `BigInteger` exist.\n\n| Method (`MoreMath`)           | Summary                                           |\n| ----------------------------- | ------------------------------------------------- |\n| (extension) `int.PosMod`      | Calculates modulo (`%` but always positive)       |\n| (extension) `int.Wrap`        | Wraps value into given range                      |\n| (extension) `int.GetFactors`  | Performs integer factorization                    |\n| `MoreMath.Lerp`               | Linearly interpolates between 2 values            |\n| `MoreMath.InverseLerp`        | Inverse of `Lerp` (returns lerp %-age form value) |\n| `MoreMath.TabShift`           | Returns column position of a character after tab  |\n| `MoreMath.AngleDifference`    | Calculates the shortest distance between 2 angles |\n| (extension) `float.DegToRad`  | Converts angle in degrees to radians              |\n| (extension) `float.RadToDeg`  | Converts angle in radians to degrees              |\n| (extension) `BigInteger.Sqrt` | Returns a square root of `BigInteger` as `double` |\n\n| Method (`RadixMath`)             | Summary                                          |\n| -------------------------------- | ------------------------------------------------ |\n| (extension) `int.DigitalRoot`    | Calculates digital root (repeated digit sum)     |\n| (extension) `int.ToDigits`       | Converts a value into an array of digits         |\n| `RadixMath.FromDigits`           | Converts an array of digits into a value         |\n| `RadixMath.BigIntegerFromDigits` | Same as `FromDigits` but returns a `BigInteger`  |\n| `RadixMath.CountAllAscending`    | Enumerates all numbers with a given places count |\n\n\n\n### `.Collections` namespace\n\nThe following methods for work with enumerables exist:\n\n| Method (`GeneralEnumerableExtensions`)  | Summary                                 |\n| --------------------------------------- | --------------------------------------- |\n| (extension) `T.Yield\u003cT\u003e`                | Wraps anything in a `IEnumerable\u003cT\u003e`    |\n| (extension) `IEnumerable\u003cT\u003e.JoinString` | A fluent way to call `string.Join`      |\n| (extension) `char[].JoinString`         | A fluent way to call string constructor |\n| (extension) `T[].SplitIntoSegments`     | \"Splits\" array into `ArraySegment\u003cT\u003e`s  |\n\n\nThis package also implements some methods that were added in .NET7 as extensions for .NET6\n\n| .NET6 Extension Method (`ReadOnlyExtensions`) | Summary                              |\n| --------------------------------------------- | ------------------------------------ |\n| `IList\u003cT\u003e.AsReadOnly`                         | Constructs a `ReadOnlyCollection\u003cT\u003e` |\n| `IDictionary\u003cTKey, TValue\u003e.AsReadOnly`        | Constructs a `ReadOnlyDictionary\u003cT\u003e` |\n\n\n\n### `.Randomness` namespace\n\nThe `.Randomness` namespace relates to `System.Random`\n\n| Class             | Summary                                                    |\n| ----------------- | ---------------------------------------------------------- |\n| `ShuffleIndexMap` | The index map of a shuffle (to track where items ended up) |\n\n| Method (`RandomnessExtensions`)        | Summary                                             |\n| -------------------------------------- | --------------------------------------------------- |\n| (extension) `Random.NextUInt31`        | Returns a random int in range of [0, int.MaxValue]  |\n| (extension) `Random.Chance`            | Returns `true` with %-chance                        |\n| (extension) `Random.GetItem`           | Randomly picks an item from a list or span          |\n| (extension) `Random.GetDifferentItems` | Randomly picks multiple different items             |\n| (extension) `Random.Shuffle`           | Shuffles items in-place                             |\n| (extension) `Random.ShuffleRemap`      | Shuffles items in-place \u0026 returns `ShuffleIndexMap` |\n\nThe following methods also exist and are extensions on collection interfaces to allow fluent syntax:\n\n| Collection extension method                    | Above equivalent           |\n| ---------------------------------------------- | -------------------------- |\n| `IReadOnlyList\u003cT\u003e.PickRandom`                  | `Random.GetItem`           |\n| `IReadOnlyCollection\u003cT\u003e.PickMultipleDifferent` | `Random.GetDifferentItems` |\n| `IList\u003cT\u003e.Shuffle`                             | `Random.Shuffle`           |\n| `IList\u003cT\u003e.ShuffleRemap`                        | `Random.ShuffleRemap`      |\n\n\n\n### `.Reflection` namespace\n\nThe `.Reflection` namespace contains reflections extensions and a generic enum \u003c-\u003e integer converter.\n\n| Method (`EnumConverter\u003cTEnum,TInt\u003e`) | Summary                                    |\n| ------------------------------------ | ------------------------------------------ |\n| `EnumConverter\u003cTEnum,TInt\u003e.ToInt`    | Converts an enum value to an integral type |\n| `EnumConverter\u003cTEnum,TInt\u003e.ToEnum`   | Converts an integral value to an enum type |\n\n| Method (`ReflectionExtensions`)       | Summary                                         |\n| ------------------------------------- | ----------------------------------------------- |\n| (extension) `Type.IsSubclassOrSelfOf` | Checks if a type is base type or subclass of it |\n| (extension) `MethodInfo.IsOverride`   | Checks if a method is an override               |\n| (extension) `IEnumerable.Cast`        | A Cast overload with a System.Type parameter    |\n\n\n\n*\\* - Reminder that extension methods are static methods and can be used as such.*\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frephidock%2Frephidock.generalutilities","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frephidock%2Frephidock.generalutilities","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frephidock%2Frephidock.generalutilities/lists"}