Last active
January 3, 2017 01:40
-
-
Save jhoerr/40ab58e230c614edc55d to your computer and use it in GitHub Desktop.
Bingo!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// lightbulb | |
public static async Task<TOut> MapAsync<TIn,TOut>(this Task<TIn> @this, Func<TIn, Task<TOut>> fn) => await fn(await @this); | |
// all permutations | |
public static TOut Map<TIn,TOut>(this TIn @this, Func<TIn, TOut> fn) => fn(@this); | |
public static async Task<TOut> MapAsync<TIn,TOut>(this TIn @this, Func<TIn, Task<TOut>> fn) => await fn(@this); | |
public static async Task<TOut> MapAsync<TIn,TOut>(this Task<TIn> @this, Func<TIn, TOut> fn) => fn(await @this); | |
public static async Task<TOut> MapAsync<TIn,TOut>(this Task<TIn> @this, Func<TIn, Task<TOut>> fn) => await fn(await @this); | |
// example | |
var x = 1; | |
var i = await x.Map(H).MapAsync(G).MapAsync(F); // i == 9 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, im interested in using this, can you please tell me how to make it work on tampermonkey?
email me @ marineoverlord@gmail.com