Skip to content

Instantly share code, notes, and snippets.

View adregan's full-sized avatar
🛶
My other car is a canoe

Duncan Regan adregan

🛶
My other car is a canoe
View GitHub Profile
const _Some = Symbol("some");
const _None = Symbol("none");
type Some<T> = {
type: typeof _Some;
value: T;
};
type None = {
type: typeof _None;
import { Machine } from "./machine";
import { Context, State } from "./models";
describe("Machine", () => {
describe("Machine.create(state)", () => {
test("it returns an instance of state machine", () => {
const machine = Machine.create({ value: "saying.hello", context: {} });
expect(machine).toBeInstanceOf(Machine);
});
});
@adregan
adregan / result-v2.ts
Last active October 28, 2025 15:42 — forked from duncan-rheaply/result.test.ts
Result
interface IResult<T, E> {
isOk(): boolean;
isErr(): boolean;
map<U>(fn: (value: T) => U): Result<U, E>;
flatMap<U, F>(fn: (value: T) => Result<U, F>): Result<U, E | F>;
match<U, F>(params: { onOk: (value: T) => U; onErr: (error: E) => F }): U | F;
unwrap(): T;
unwrapOr<D>(defaultValue: D): T | D;
}