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
/** | |
/* An attempt to make the error handling process described on Khalil Stemmler's excellent | |
/* blog a little somewhat simpler. | |
/* https://khalilstemmler.com/articles/enterprise-typescript-nodejs/functional-error-handling/ | |
/** | |
// Left and Right classes, but more specific to error handling. | |
class Failure<L, A = any> { | |
readonly error: L; |
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
/** | |
* Simple, opinionated Logger for use with Node.js and Web Browsers with no | |
* additional dependencies. | |
* | |
* The logger supports and auto-detects the following environments: | |
* - Node.js (with and without JSDOM) | |
* = Browser | |
* - Electron | |
* - React Native - Logs to console or browser window depending on whether a debugger is connected | |
* - Unit Test & CI/CD - Logs are disabled by default |
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 StackOps<S, A> = { | |
init(): S | |
push(s: S, x: A): void | |
pop(s: S): A | |
size(s: S): number | |
} | |
type Stack<A> = <R>(go: <S>(ops: StackOps<S, A>) => R) => R | |
const arrayStack = <A>(): Stack<A> => |