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
type Callback<A> = (a: A) => void; | |
/** | |
* Delays stuff for ensuring fairness. | |
*/ | |
export function yieldRunLoop(): Promise<void> { | |
const fn: (cb: (() => void)) => void = typeof setImmediate !== 'undefined' | |
? setImmediate | |
: cb => setTimeout(cb, 0) | |
return new Promise(fn) |
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
class Producer[+X](x: X) { | |
def produce: X = x | |
} | |
class Consumer[-X](name: String) { | |
def consume(x: X): Unit = println(s">>> $name is consuming $x polimorfically") | |
} | |
//-------------------------------------- |
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
"Monads are Monoids in the Category of Endofunctors" | |
If you are a functional programmer, you've probably heard this statement before. | |
To understand it, first we need to understand its component parts: | |
. Category | |
. Monoid | |
. Endofunctor | |
After this, we will glue those parts together piece by piece to grasp the whole. |
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
function getUrlParams(search) { | |
const hashes = search.slice(search.indexOf('?') + 1).split('&') | |
const params = {} | |
hashes.map(hash => { | |
const [key, val] = hash.split('=') | |
params[key] = decodeURIComponent(val) | |
}) | |
return params | |
} |