I hereby claim:
- I am suddenlygiovanni on github.
- I am suddenlygiovanni (https://keybase.io/suddenlygiovanni) on keybase.
- I have a public key ASAOE4zpUCOvYULqE6CHqpKRUBTF8Ip4Xha8yWXU8icyzwo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
import * as React from 'react' | |
enum EnumStatuses { | |
IDLE = 'idle', | |
PENDING = 'pending', | |
RESOLVED = 'resolved', | |
REJECTED = 'rejected', | |
} | |
type Statuses = 'idle' | 'pending' | 'resolved' | 'rejected' |
/* eslint-disable max-lines-per-function */ | |
/* eslint-disable max-statements */ | |
type Routes = [string, string][] | |
type FindRoutes = (routes: Routes) => string | |
class Stack<T> { | |
items: T[] | |
constructor() { | |
this.items = [] |
/** | |
* merges two list together into a new list maintaining the correct type | |
* @param {[...A]} a first list of any | |
* @param {[...B]} b second list of any | |
* @returns {[...A, ...B]} | |
*/ | |
export function concat<A extends unknown[], B extends unknown[]>( | |
a: [...A], | |
b: [...B] |
/** | |
* pipe :: ((a -> b), (b -> c), ..., (y -> z)) -> a -> z | |
*/ | |
export const pipe = (...fns) => (...args) => | |
fns.reduce((res, fn) => [fn.call(null, ...res)], args)[0] | |
/** | |
* @param {string} message | |
* @returns {<T>(x:T)=> T} | |
*/ |
/** | |
* compose :: ((y -> z), ..., (b -> c), (a -> b)) -> a -> z | |
*/ | |
export const compose = (...fns) => (...args) => | |
fns.reduceRight((res, fn) => [fn.call(null, ...res)], args)[0] | |
/** | |
* @param {string} message | |
* @returns {<T>(x:T)=> T} | |
*/ |
type AssertEqual<T, Expected> = T extends Expected ? (Expected extends T ? true : never) : never | |
type UnaryFn<A, B> = (a: A) => B | |
type BinaryFn<A, B, C> = (a: A, b: B) => C | |
type TernaryFn<A, B, C, D> = (a: A, b: B, c: C) => D | |
type QuaternaryFn<A, B, C, D, E> = (a: A, b: B, c: C, d: D) => E | |
type QuinaryFn<A, B, C, D, E, F> = (a: A, b: B, c: C, d: D, e: E) => F | |
type Curry2 = <A, B, C>(f: BinaryFn<A, B, C>) => Curried2<A, B, C> | |
type Curried2<A, B, C> = (a: A) => (b: B) => C |
// let's pretend that Array.prototype.filter does not exist | |
describe('filter', () => { | |
const array = [0, 1, undefined, 2, null, 3, 'four', ''] | |
describe('with baked in filtering behavior', () => { | |
function filter<T>(array: T[]): T[] { | |
const arr = [] | |
for (let index = 0; index < array.length; index++) { | |
const element = array[index] | |
if (element === null || element === undefined) { |
Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.