Yeet

One day, JavaScript will have throw expressions. Until then, yeet!

function save(filename = yeet("Argument required")) { ... }

const encoder = encoding === "utf8" ? new UTF8Encoder() 
              : encoding === "utf16le" ? new UTF16Encoder(false) 
              : encoding === "utf16be" ? new UTF16Encoder(true) 
              : yeet(TypeError, "Unsupported encoding");

class Product {
  get id() { return this._id; }
  set id(value) { this._id = value ?? yeet("Invalid value"); }
}

Install

NPM

npm install yeet-ts
# or
pnpm install yeet-ts
# or
bun install yeet-ts

... and then

import { yeet } from "yeet-ts";

Deno

import { yeet } from "https://deno.land/x/yeet@v1.0.3/src/mod.ts";

Contribute

To install dependencies:

bun install

To build:

bun run build

To publish:

bun run pub