Skip to content

Instantly share code, notes, and snippets.

@simlrh
simlrh / machine.js
Last active March 10, 2020 12:42
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@simlrh
simlrh / machine.js
Created March 13, 2020 13:39
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@simlrh
simlrh / getKeys.ts
Last active March 2, 2021 17:45
Miscellaneous TypeScript helpers
// Wrapper for Object.keys which sets the correct type
export function getKeys<T>(obj: T): Array<keyof T> {
return Object.keys(obj) as Array<keyof T>;
}
@simlrh
simlrh / composable.ts
Last active April 17, 2022 05:39
Typescript compose and pipe "infix operators"
interface Composable<B,C> {
(b: B): C;
I: <D>(f: (c: C) => D) => Composable<B,D>;
o: <A>(f: (a: A) => B) => Composable<A,C>;
}
/*
* Non-type safe internal function - type safety of result is guaranteed by
* allowing creation only through `I` and `o` functions and methods
*/