lawrence-laz / poem Goto Github PK
View Code? Open in Web Editor NEWA selection of useful extension methods to write fluent code.
License: MIT License
A selection of useful extension methods to write fluent code.
License: MIT License
public static IEnumerable<T> ForEach<T>(this IEnumerable<T> enumerable, Action<T> action)
Sometimes we have a LINQ chain that check's something and we want to execute an action depending on the boolean value the LINQ returns. This could be achieved with something like static bool IfTrue(this bool value, Action action)
.
There's sometimes a need to set all array values to one specific value. There should be an extension method targeting arrays that does this. Something like:
SetAll<T>(this T[] array, T value)
Sometimes you have a set of data that should be prefixed with some string, but not all entries are. Add a method that easily handles this. Something like string.EnsurePrefix("Prefix_")
.
Sometimes dictionary is a just a part of a compound structure. In such cases a method like .GetOrAdd(TKey, Func<TVal>)
would be useful.
Currently dotnet allows to trim character(s) using string TrimEnd(char trimChar)
.
Usually there's a need to trim a word or a collection of words. This method should also be an extension method returning a result.
Currently dotnet provides a simple static method to compare two strings while ignoring casing:
int Compare(string? strA, string? strB, bool ignoreCase)
But there is no extension method for this.
GetFilesOrEmpty()
- should not throw if DirectoryInfo.Exists == false
Currently Poem provides .TrimEnd(string)
only. But there is the same need for .TrimStart(string)
and .Trim(string)
.
They now require a using System;
and it does not get suggested by intellisense.
Currently dotnet allows to joing string using a simple static method string Join(char separator, params object?[] values)
.
There should be an extension method on IEnumerable<T>
that joins and returns a result.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.