This file contains hidden or 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
# @hoxlux/bash | |
# 🗂 💡 🔑 🔐 🚨 🐙 🌴 🔥 🌈 🥥 🥚 ⏱ 🧰 🧪 🛍 🇬🇧 🇧🇷 | |
alias ga="git add ." | |
alias gc1="git commit -m 'commit inicial'" | |
alias gmaster="git switch master" | |
alias gnext="git switch next" | |
alias gprod="git switch production" | |
function parse_git_branch { |
This file contains hidden or 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 NotNullOrUndefined = string | number | boolean | symbol | object | |
interface IMaybe<T> { | |
type: symbol | |
has(): boolean | |
isJust(): boolean | |
isNothing(): boolean | |
unwrap(): T | never | |
map<U>(fn: (value: T) => U): IMaybe<U> | |
flatMap<U>(fn: (value: T) => U): T |
This file contains hidden or 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 CallbackFunction<T = unknown> = (...params: unknown[]) => T | |
export class Maybe<T> { | |
private constructor(private value: T | null) {} | |
static just<T>(a: any): Maybe<T> | |
static nothing<T>(): Maybe<T> | |
static fromValue<T>(value: T | undefined | null): Maybe<T> | |
isJust(): boolean | |
isNothing(): boolean | |
toString(): string |
This file contains hidden or 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
// a Haskell-like lazy-list | |
// adapted from this awesome gist: https://gist.github.com/gvergnaud/6e9de8e06ef65e65f18dbd05523c7ca9 | |
export class List { | |
constructor(generator, length) { | |
this[Symbol.iterator] = generator | |
this.length = length | |
} | |
// should be private |
This file contains hidden or 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
export const Identity = (x) => ({ | |
chain: (f) => f(x), | |
unwrap: () => x, | |
map: (f) => Identity(f(x)), | |
inspect: () => `Identity(${x})`, | |
}) |
This file contains hidden or 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
interface ITuple<F, S> { | |
fst(): F | |
snd(): S | |
toArray(): [F, S] | |
unwrap(): [F, S] | |
toJSON(): [F, S] | |
inspect(): string | |
toString(): string | |
equals(other: ITuple<F, S>): boolean | |
bimap<F2, S2>(f: (fst: F) => F2, g: (snd: S) => S2): ITuple<F2, S2> |
This file contains hidden or 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
export const List = (x) => ({ | |
emit: () => x, | |
head: () => x[0], | |
tail: () => List.of(x.splice(1)), | |
last: () => x[x.length - 1], | |
chain: (f) => x.map(f), | |
map: (f) => List.of(x.map(f)), | |
inspect: () => `List(${x})`, | |
concat: (a) => List.of(x.concat(a)) | |
}) |
This file contains hidden or 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
const makeReadOnly = (value) => Object.freeze(value) | |
const ResultType = { | |
Ok: Symbol(':ok'), | |
Err: Symbol(':err'), | |
} | |
const Ok = (val) => makeReadOnly({ | |
type: ResultType.Ok, | |
isOk: () => true, |
This file contains hidden or 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
import { isValid } from './utils' | |
const OptionType = { | |
Some: Symbol(':some'), | |
None: Symbol(':none'), | |
} | |
const makeSome = (val) => ({ | |
type: OptionType.Some, | |
isSome: () => true, |
This file contains hidden or 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
import { getStyles } from './test-helpers' | |
describe('styled-components', () => { | |
test('extended components keep their styles', () => { | |
const Box = styled.div` | |
margin: 16px; | |
` | |
const Card = styled(Box)` | |
color: tomato; | |
` |
OlderNewer