another-guy - Peppermint 1.0.1-b00002

Provides a bit of C# syntactic sugar

PM> Install-Package Peppermint -Version 1.0.1-b00002 -Source https://www.myget.org/F/another-guy/api/v3/index.json

Copy to clipboard

> nuget.exe install Peppermint -Version 1.0.1-b00002 -Source https://www.myget.org/F/another-guy/api/v3/index.json

Copy to clipboard

> dotnet add package Peppermint --version 1.0.1-b00002 --source https://www.myget.org/F/another-guy/api/v3/index.json

Copy to clipboard
<PackageReference Include="Peppermint" Version="1.0.1-b00002" />
Copy to clipboard
source https://www.myget.org/F/another-guy/api/v3/index.json

nuget Peppermint  ~> 1.0.1-b00002
Copy to clipboard

> choco install Peppermint --version 1.0.1-b00002 --source https://www.myget.org/F/another-guy/api/v2

Copy to clipboard
Import-Module PowerShellGet
Register-PSRepository -Name "another-guy" -SourceLocation "https://www.myget.org/F/another-guy/api/v2"
Install-Module -Name "Peppermint" -RequiredVersion "1.0.1-b00002" -Repository "another-guy" -AllowPreRelease
Copy to clipboard

Synopsis

Peppermint

Provides a bit of C# syntactic sugar

Code Example

StringToEnumExtension:

enum MyEnum
{
  One = 1,
  Two = 2
}

string @string = "One";
MyEnum value = @string.Parse<MyEnum>();

DictionaryExtensions:

IDictionary<string, object> dict = null;
dict = dict.NullToEmpty();
var size = dict.Count; // size == 0, no exception here.

IEnumerableExtensions:

new int[] { 1, 2, 3, 4, 5 }
	.TakeProject(
		item => item % 2 == 0,
		item => $"{item} Mississippi"); // ->  { "2 Mississippi", "4 Mississippi" }
		
		
new int[] { 1, 2, 3, 4, 5 }
	.SkipProject(
		item => item > 2,
		item => $"{item} Mississippi"); // ->  { "1 Mississippi", "2 Mississippi" }
		
new int[] { 1, 2 }
	.TakeProjectMany(
		item => item < 2,
		item => new int[] { item, item, item }); // ->  { 1, 1, 1 }
		
new int[] { 1, 2 }
	.SkipProjectMany(
		item => item < 2,
		item => new int[] { item, item, item }); // ->  { 2, 2, 2 }

ArrayExtensions:

string[] array = null;
array = array.NullToEmpty();
var length = array.Length; // length == 0, no exception here.

ListExtensions:

string[] ints = new[] { "Alice", "Bob" };
list.SwapAt(0, 1); // Swaps items in place. The array is now []{ "Bob", "Alice" }

Sequence:

// Other sequence types or even custom sequence generators can be used.
var integers = Sequence
	.WithoutDuplicates(Sequence.NaturalNumbers)
	.Take(5)
	.ToList(); // Results in a List<int>() { 1, 2, 3, 4, 5 }

// Sequence start number and sequence step can be explicitly provided if necessary.

Motivation

Syntax sugar is syntax sugar: it's not a necessary thing per se but it can improve code quality.

Installation

Peppermint is a available in a form of a NuGet package. Follow regular installation process to bring it to your project. https://www.nuget.org/packages/Peppermint/

Tests

Unit tests are available in Peppermint.Tests project.

License

The code is distributed under the MIT license.

Reporting an Issue

Reporting an issue, proposing a feature, or asking a question are all great ways to improve software quality.

Here are a few important things that package contributors will expect to see in a new born GitHub issue:

  • the relevant version of the package;
  • the steps to reproduce;
  • the expected result;
  • the observed result;
  • some code samples illustrating current inconveniences and/or proposed improvements.

Contributing

Contribution is the best way to improve any project!

  1. Fork it!
  2. Create your feature branch (git checkout -b my-new-feature).
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

...or follow steps described in a nice fork guide by Karl Broman

  • .NETStandard 1.6
    • NETStandard.Library (>= 1.6.0)
  • .NETStandard 1.6: 1.6.0.0

Owners

another-guy

Authors

Igor Soloydenko

Project URL

https://github.com/another-guy/Peppermint

License

MIT

Tags

Syntax,Sugar,C#

Info

92 total downloads
3 downloads for version 1.0.1-b00002
Download (4.93 KB)
Found on the current feed only

Package history

Version Size Last updated Downloads Mirrored?
1.5.0 10.49 KB Sat, 07 Jan 2017 08:48:08 GMT 2
1.5.0-b00052 10.49 KB Sat, 07 Jan 2017 08:47:20 GMT 1
1.4.0 10.31 KB Thu, 05 Jan 2017 09:48:34 GMT 1
1.4.0-b00050 10.32 KB Thu, 05 Jan 2017 09:47:44 GMT 3
1.3.0 10.29 KB Tue, 03 Jan 2017 23:25:16 GMT 1
1.3.0-b00048 10.29 KB Tue, 03 Jan 2017 23:24:19 GMT 1
1.2.2 9.97 KB Fri, 30 Dec 2016 07:30:34 GMT 1
1.2.2-b00046 9.97 KB Fri, 30 Dec 2016 07:29:54 GMT 1
1.2.1 9.93 KB Fri, 30 Dec 2016 06:15:58 GMT 1
1.2.1-b00044 9.94 KB Fri, 30 Dec 2016 06:15:01 GMT 3
1.2.0 10.07 KB Fri, 30 Dec 2016 02:43:19 GMT 3
1.2.0-b00042 10.08 KB Fri, 30 Dec 2016 02:42:32 GMT 1
1.1.0 9.99 KB Tue, 27 Dec 2016 03:15:03 GMT 2
1.1.0-b00041 10 KB Tue, 27 Dec 2016 17:17:15 GMT 0
1.1.0-b00039 9.99 KB Tue, 27 Dec 2016 03:14:09 GMT 3
1.0.10 8.87 KB Mon, 05 Dec 2016 16:45:56 GMT 4
1.0.10-b00037 8.88 KB Mon, 05 Dec 2016 16:44:32 GMT 0
1.0.9 8.81 KB Sat, 03 Dec 2016 10:05:29 GMT 2
1.0.9-b00035 8.87 KB Mon, 05 Dec 2016 16:39:27 GMT 4
1.0.9-b00033 8.82 KB Sat, 03 Dec 2016 10:04:40 GMT 2
1.0.8 8.75 KB Sat, 03 Dec 2016 08:45:48 GMT 1
1.0.8-b00031 8.76 KB Sat, 03 Dec 2016 08:44:48 GMT 1
1.0.7 8.61 KB Tue, 29 Nov 2016 08:26:31 GMT 3
1.0.7-b00030 8.76 KB Sat, 03 Dec 2016 08:43:17 GMT 1
1.0.7-b00029 8.78 KB Sat, 03 Dec 2016 08:29:16 GMT 2
1.0.7-b00027 8.61 KB Tue, 29 Nov 2016 08:24:54 GMT 1
1.0.6 8.47 KB Sat, 26 Nov 2016 05:47:06 GMT 1
1.0.6-b00025 8.48 KB Sat, 26 Nov 2016 05:43:31 GMT 2
1.0.5 8.33 KB Tue, 22 Nov 2016 08:05:47 GMT 4
1.0.5-b00024 8.48 KB Sat, 26 Nov 2016 05:37:55 GMT 2
1.0.4 8.33 KB Tue, 22 Nov 2016 07:58:12 GMT 1
1.0.3 8.23 KB Fri, 18 Nov 2016 06:24:47 GMT 1
1.0.3-b00019 8.23 KB Fri, 18 Nov 2016 06:23:40 GMT 0
1.0.2 8.21 KB Fri, 18 Nov 2016 00:29:48 GMT 2
1.0.2-b00018 8.23 KB Fri, 18 Nov 2016 06:22:22 GMT 1
1.0.2-b00017 8.22 KB Fri, 18 Nov 2016 00:46:16 GMT 3
1.0.2-b00015 8.22 KB Fri, 18 Nov 2016 00:17:23 GMT 2
1.0.1-b00013 6.69 KB Sun, 28 Aug 2016 04:19:53 GMT 3
1.0.1-b00012 6.69 KB Sat, 27 Aug 2016 03:51:14 GMT 3
1.0.1-b00011 6.7 KB Sat, 27 Aug 2016 03:44:40 GMT 4
1.0.1-b00010 6.69 KB Mon, 15 Aug 2016 03:52:12 GMT 4
1.0.1-b00006 6.38 KB Sun, 14 Aug 2016 07:02:38 GMT 3
1.0.1-b00005 6.17 KB Sat, 13 Aug 2016 02:44:19 GMT 3
1.0.1-b00004 4.95 KB Fri, 12 Aug 2016 18:35:48 GMT 2
1.0.1-b00003 4.93 KB Sun, 07 Aug 2016 22:40:34 GMT 3
1.0.1-b00002 4.93 KB Sat, 06 Aug 2016 02:07:50 GMT 3