Tooling
Utilities, CLI, testing, and error types
Utilities
cruel.coin(0.5)
cruel.pick([1, 2, 3])
cruel.between(10, 100)
cruel.maybe(value, 0.5)
await cruel.delay(500)Stats
cruel.stats()
cruel.resetStats()Deterministic Mode
cruel.seed(12345)
cruel.coin(0.5) // same result every timeCLI
cruel test https://api.example.com --fail 0.1 --count 20
cruel test https://api.example.com --preset nightmare
cruel scenario outage --duration 5000
cruel presetsQuality Gate
bun run qaThis runs lint, type checks, package build/test, docs build, and no-key user smoke examples.
Testing
import { describe, test, beforeEach } from "bun:test"
import { cruel } from "cruel"
beforeEach(() => {
cruel.reset()
cruel.seed(12345)
})
test("handles failures", async () => {
cruel.enable({ fail: 1 })
await expect(api()).rejects.toThrow()
})Error Types
import {
CruelError,
CruelTimeoutError,
CruelNetworkError,
CruelHttpError,
CruelRateLimitError,
CruelAIError,
} from "cruel"