This repository has been archived on 2026-03-28. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files

20 lines
404 B
TypeScript

import { Err, Result } from "../result";
import { Type } from "../type";
export class Value<const T> extends Type<T> {
readonly val: T;
constructor(v: T) {
super();
this.val = v;
}
check(val: any): Result<T> {
if(val === this.val) return val;
return new Err(`${val} is not equal to ${this.val}`);
}
}
export function value<const T>(v: T): Value<T> {
return new Value(v);
}