Skip to main content
Deno 2 is finally here 🎉️
Learn more

Ahh

A collection of mostly rust-inspired stuff to help make TypeScript a litte easier to work with — if you don’t mind a little verbosity.

Example

This is an example on how you might use results:

import { Err, Ok, R, Result } from "./mod.ts";

function mustStartWith(s: string, start: string): Result<string, string> {
  if (s.startsWith(start)) {
    return Ok(s);
  } else {
    return Err(`string must start with "${start}"`);
  }
}

console.log(R.contains(mustStartWith("abc", "a"), "abc"));
console.log(
  R.containsErr(mustStartWith("bca", "a"), `string must start with "a"`),
);

Licence

This is licenced under the ISC Licence, see the LICENCE file for more information.