yeet-ts
v1.0.3
Published
A poor man's throw expression
Downloads
50
Readme
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/[email protected]/src/mod.ts";
Contribute
To install dependencies:
bun install
To build:
bun run build
To publish:
bun run pub